diff options
author | Julius Werner <jwerner@chromium.org> | 2020-12-30 15:51:10 -0800 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2021-02-19 08:39:26 +0000 |
commit | 82d16b150ce3287f4e9f33e86bdde32bc455b193 (patch) | |
tree | f3110d34e3eebb4a57ca429152c1262e65e9f2f4 /src/lib | |
parent | 422501fb14780090527c9a45bcca6628cd6bba71 (diff) |
memlayout: Store region sizes as separate symbols
This patch changes the memlayout macro infrastructure so that the size
of a region "xxx" (i.e. the distance between the symbols _xxx and _exxx)
is stored in a separate _xxx_size symbol. This has the advantage that
region sizes can be used inside static initializers, and also saves an
extra subtraction at runtime. Since linker symbols can only be treated
as addresses (not as raw integers) by C, retain the REGION_SIZE()
accessor macro to hide the necessary typecast.
Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: Ifd89708ca9bd3937d0db7308959231106a6aa373
Reviewed-on: https://review.coreboot.org/c/coreboot/+/49332
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/program.ld | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/program.ld b/src/lib/program.ld index 7027747bd5..8180d9f1dc 100644 --- a/src/lib/program.ld +++ b/src/lib/program.ld @@ -29,22 +29,26 @@ _cbmem_init_hooks = .; KEEP(*(.rodata.cbmem_init_hooks)); _ecbmem_init_hooks = .; + RECORD_SIZE(cbmem_init_hooks) #endif . = ALIGN(ARCH_POINTER_ALIGN_SIZE); _rsbe_init_begin = .; KEEP(*(.rsbe_init)); _ersbe_init_begin = .; + RECORD_SIZE(rsbe_init_begin) #if ENV_RAMSTAGE . = ALIGN(ARCH_POINTER_ALIGN_SIZE); _pci_drivers = .; KEEP(*(.rodata.pci_driver)); _epci_drivers = .; + RECORD_SIZE(pci_drivers) . = ALIGN(ARCH_POINTER_ALIGN_SIZE); _cpu_drivers = .; KEEP(*(.rodata.cpu_driver)); _ecpu_drivers = .; + RECORD_SIZE(cpu_drivers) #endif . = ALIGN(ARCH_POINTER_ALIGN_SIZE); @@ -52,6 +56,7 @@ *(.rodata.*); . = ALIGN(ARCH_POINTER_ALIGN_SIZE); _etext = .; + RECORD_SIZE(text) } : to_load #if ENV_RAMSTAGE && (CONFIG(COVERAGE) || CONFIG(ASAN_IN_RAMSTAGE)) @@ -82,6 +87,7 @@ _rmodule_params = .; KEEP(*(.module_parameters)); _ermodule_params = .; + RECORD_SIZE(rmodule_params) #endif *(.data); @@ -92,6 +98,7 @@ #if ENV_ROMSTAGE_OR_BEFORE PROVIDE(_preram_cbmem_console = .); PROVIDE(_epreram_cbmem_console = _preram_cbmem_console); + PROVIDE(_preram_cbmem_console_size = ABSOLUTE(0)); #elif ENV_RAMSTAGE . = ALIGN(ARCH_POINTER_ALIGN_SIZE); _bs_init_begin = .; @@ -99,10 +106,12 @@ LONG(0); LONG(0); _ebs_init_begin = .; + RECORD_SIZE(bs_init_begin) #endif . = ALIGN(ARCH_POINTER_ALIGN_SIZE); _edata = .; + RECORD_SIZE(data) } #endif @@ -116,6 +125,7 @@ *(.sbss.*) . = ALIGN(ARCH_POINTER_ALIGN_SIZE); _ebss = .; + RECORD_SIZE(bss) } #endif @@ -126,6 +136,7 @@ . += (ENV_RMODULE ? __heap_size : CONFIG_HEAP_SIZE); . = ALIGN(ARCH_POINTER_ALIGN_SIZE); _eheap = .; + RECORD_SIZE(heap) } #endif @@ -135,6 +146,7 @@ #endif _eprogram = .; +RECORD_SIZE(program) /* Discard the sections we don't need/want */ |