Skip to content

Code Models

Code models define placement and locality assumptions that assemblers, linkers, and compilers may use when selecting address materialization, displacement, GOT, PLT, and relocation forms. Bedrock 32-bit displacement and direct control-transfer forms are signed, so direct 32-bit relative references cover a -2 GiB to +2 GiB - 1 window.

Bedrock Code Models

Model Placement contract Default access strategy
low static addresses in 0x00000000..0x7fffffff signed 32-bit absolute data and direct transfers
small referenced code, data, GOT, and PLT fit one signed 32-bit relative window PC-relative access; GOT/PLT for interposable symbols
medium code, GOT, and PLT fit one signed 32-bit window; data placement is unrestricted direct code; GOT-resolved 64-bit data addresses
high static high image with internal references in a signed 32-bit displacement window image-base or PC-relative access with full-width fallback
large unrestricted 64-bit address space full-width materialization and indirect transfer

low Model Details

The low model is a static image model whose named code and data lie between 0x00000000 and 0x7fffffff. Code uses direct signed 32-bit branch or call payloads; data uses absolute or base-relative signed 32-bit payloads. The model permits omission of both GOT and PLT.

Its default relocation set is R_BEDROCK_ABS32S, R_BEDROCK_IMM32S, R_BEDROCK_DISP32S, R_BEDROCK_BRDISP32S, and R_BEDROCK_CALL32S. The linker may shrink a direct transfer or address materialization after final placement proves that the result fits a shorter encoding.

small Model Details

The small model is position-independent and assumes that local code, nearby data, the GOT, and the PLT fit the signed 32-bit relative window of the use site or selected base. Code uses direct signed 32-bit transfers; data uses PC-relative or GOTPCREL signed 32-bit materialization.

Its default relocations are R_BEDROCK_BRDISP32S, R_BEDROCK_CALL32S, R_BEDROCK_GOTPCREL32S, R_BEDROCK_PLT32S, and R_BEDROCK_TLSDESC_GOTPCREL32S. The linker may shrink a relative form or replace GOT/TLSDESC access with a direct form when the resolved symbol is local and in range.

medium Model Details

The medium model keeps code, GOT, and PLT within a signed 32-bit relative window but permits data objects anywhere in the 64-bit address space. Code uses direct signed 32-bit transfers. Data normally uses a GOT-resolved 64-bit address reached through a signed 32-bit GOT reference.

Its default relocations are R_BEDROCK_BRDISP32S, R_BEDROCK_CALL32S, R_BEDROCK_GOTPCREL32S, R_BEDROCK_GOT64, R_BEDROCK_PLT32S, and R_BEDROCK_TLSDESC_GOTPCREL32S. A linker may replace a GOT data reference with a direct relative reference when final placement puts the object in range.

high Model Details

The high model is a static high-address image. Internal code may use direct signed 32-bit transfers or image-base-relative addressing. Data uses a PC-relative GOT or an image-base-relative form when in range; the GOT and PLT are image-local or base-relative.

Its default relocations are R_BEDROCK_BRDISP32S, R_BEDROCK_CALL32S, R_BEDROCK_GOTPCREL32S, R_BEDROCK_ABS64, and R_BEDROCK_DISP64. Compact internal references are permitted when final placement proves the signed 32-bit range; full-width and base-relative sequences remain valid.

large Model Details

The large model permits arbitrary placement. Code uses full-width address materialization followed by an indirect transfer when necessary; data, GOT, and PLT addresses are full width.

Its default relocations are R_BEDROCK_ABS64, R_BEDROCK_PCREL64, R_BEDROCK_GOTPCREL64, R_BEDROCK_PLT64, and R_BEDROCK_TLSDESC_GOTPCREL64. Final placement may justify relaxing any full-width form to a shorter encoding.