[coreboot] Doubts about link scripts

Julius Werner jwerner at chromium.org
Wed Jul 25 08:15:54 CEST 2018


> I try to read link scripts of coreboot.
> In addition to the x86 platform, code segments and data segments are contiguous during the bootblock/romstage phase.

There is no data segment for bootblock/romstage on x86. You are not
allowed to use global (or static local) variables. The build system
will enforce this. You can see that
https://review.coreboot.org/cgit/coreboot.git/tree/src/arch/x86/include/arch/memlayout.h
defines ARCH_STAGE_HAS_DATA_SECTION and ARCH_STAGE_HAS_BSS_SECTION to
0, so the .data and .bss sections in
https://review.coreboot.org/cgit/coreboot.git/tree/src/lib/program.ld
get removed by the preprocessor.

There is the special mechanism of a CAR_GLOBAL variable which needs to
be marked as such in the code and only accessed through the
car_get_var()/car_set_var() macros (from
https://review.coreboot.org/cgit/coreboot.git/tree/src/arch/x86/include/arch/early_variables.h).
They are placed in a special section that gets linked to the CAR
address space by the
https://review.coreboot.org/cgit/coreboot.git/tree/src/arch/x86/car.ld
script.

On other architectures (like Arm), we don't have any systems that
execute directly from flash (yet). We always load code and data into
SRAM before executing so they can be contiguous in there.



More information about the coreboot mailing list