diff options
author | Julius Werner <jwerner@chromium.org> | 2020-08-25 16:00:44 -0700 |
---|---|---|
committer | Julius Werner <jwerner@chromium.org> | 2020-08-27 22:11:17 +0000 |
commit | 644a512e560147324ecf74ebce5e336bc57dd7bf (patch) | |
tree | ec9e63ea2fee79fb2be723568b4208fdcd35140a /src/include/symbols.h | |
parent | 8cc80d5e50c9382fb04041d7af9c1b59bba0184f (diff) |
symbols: Change implementation details of DECLARE_OPTIONAL_REGION()
It seems that GCC's LTO doesn't like the way we implement
DECLARE_OPTIONAL_REGION(). This patch changes it so that rather than
having a normal DECLARE_REGION() in <symbols.h> and then an extra
DECLARE_OPTIONAL_REGION() in the C file using it, you just say
DECLARE_OPTIONAL_REGION() directly in <symbols.h> (in place and instead
of the usual DECLARE_REGION()). This basically looks the same way in the
resulting object file but somehow LTO seems to like it better.
Signed-off-by: Julius Werner <jwerner@chromium.org>
Change-Id: I6096207b311d70c8e9956cd9406bec45be04a4a2
Reviewed-on: https://review.coreboot.org/c/coreboot/+/44791
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Jacob Garber <jgarber1@ualberta.ca>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: HAOUAS Elyes <ehaouas@noos.fr>
Diffstat (limited to 'src/include/symbols.h')
-rw-r--r-- | src/include/symbols.h | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/include/symbols.h b/src/include/symbols.h index fe3f46ab80..371d84bf9b 100644 --- a/src/include/symbols.h +++ b/src/include/symbols.h @@ -13,8 +13,20 @@ extern u8 _dram[]; extern u8 _##name[]; \ extern u8 _e##name[]; +/* + * Regions can be declared optional if not all configurations provide them in + * memlayout and you want code to be able to check for their existence at + * runtime. Not every region that is architecture or platform-specific should + * use this -- only declare regions optional if the code *accessing* them runs + * both on configurations that have the region and those that don't. That code + * should then check (REGION_SIZE(name) != 0) before accessing it. + */ +#define DECLARE_OPTIONAL_REGION(name) \ + __weak extern u8 _##name[]; \ + __weak extern u8 _e##name[]; + DECLARE_REGION(sram) -DECLARE_REGION(timestamp) +DECLARE_OPTIONAL_REGION(timestamp) DECLARE_REGION(preram_cbmem_console) DECLARE_REGION(cbmem_init_hooks) DECLARE_REGION(stack) @@ -53,24 +65,15 @@ DECLARE_REGION(ramstage) DECLARE_REGION(pagetables) DECLARE_REGION(ttb) -DECLARE_REGION(ttb_subtables) +DECLARE_OPTIONAL_REGION(ttb_subtables) DECLARE_REGION(dma_coherent) DECLARE_REGION(soc_registers) DECLARE_REGION(framebuffer) DECLARE_REGION(pdpt) -DECLARE_REGION(opensbi) -DECLARE_REGION(bl31) +DECLARE_OPTIONAL_REGION(opensbi) +DECLARE_OPTIONAL_REGION(bl31) DECLARE_REGION(transfer_buffer) -/* - * Put this into a .c file accessing a linker script region to mark that region - * as "optional". If it is defined in memlayout.ld (or anywhere else), the - * values from that definition will be used. If not, start, end and size will - * all evaluate to 0. (We can't explicitly assign the symbols to 0 in the - * assembly due to https://sourceware.org/bugzilla/show_bug.cgi?id=1038.) - */ -#define DECLARE_OPTIONAL_REGION(name) asm (".weak _" #name ", _e" #name) - /* Returns true when pre-RAM symbols are known to the linker. * (Does not necessarily mean that the memory is accessible.) */ static inline int preram_symbols_available(void) |