summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2021-02-12 17:37:27 -0800
committerJulius Werner <jwerner@chromium.org>2021-02-18 02:32:06 +0000
commit84446e6e54fa9df42fcbb8450c9a071feaf1f8d0 (patch)
treed300069dd3ff9f2cb59e86f9f320ce9018653196 /src
parenta2642d0ffe3ecba201a0bfe6b219e35b52c399ae (diff)
downloadcoreboot-84446e6e54fa9df42fcbb8450c9a071feaf1f8d0.tar.xz
rmodtool: Make memlayout symbols absolute and do not relocate them
Memlayout is a mechanism to define memory areas outside the normal program segment constructed by the linker. Therefore, it generally doesn't make sense to relocate memlayout symbols when the program is relocated. They tend to refer to things that are always in one specific spot, independent of where the program is loaded. This hasn't really hurt us in the past because the use case we have for rmodules (ramstage on x86) just happens to not really need to refer to any memlayout-defined areas at the moment. But that use case may come up in the future so it's still worth fixing. This patch declares all memlayout-defined symbols as ABSOLUTE() in the linker, which is then reflected in the symbol table of the generated ELF. We can then use that distinction to have rmodtool skip them when generating the relocation table for an rmodule. (Also rearrange rmodtool a little to make the primary string table more easily accessible to the rest of the code, so we can refer to symbol names in debug output.) A similar problem can come up with userspace unit tests, but we cannot modify the userspace relocation toolchain (and for unfortunate historical reasons, it tries to relocate even absolute symbols). We'll just disable PIC and make those binaries fully static to avoid that issue. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: Ic51d9add3dc463495282b365c1b6d4a9bf11dbf2 Reviewed-on: https://review.coreboot.org/c/coreboot/+/50629 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/include/memlayout.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/include/memlayout.h b/src/include/memlayout.h
index bf830b7d24..424a28a20a 100644
--- a/src/include/memlayout.h
+++ b/src/include/memlayout.h
@@ -31,7 +31,7 @@
#define SYMBOL(name, addr) \
SET_COUNTER(name, addr) \
- _##name = .;
+ _##name = ABSOLUTE(.);
#define REGION(name, addr, size, expected_align) \
SYMBOL(name, addr) \
@@ -40,8 +40,8 @@
SYMBOL(e##name, addr + size)
#define ALIAS_REGION(name, alias) \
- _##alias = _##name; \
- _e##alias = _e##name;
+ _##alias = ABSOLUTE(_##name); \
+ _e##alias = ABSOLUTE(_e##name); \
/* Declare according to SRAM/DRAM ranges in SoC hardware-defined address map. */
#define SRAM_START(addr) SYMBOL(sram, addr)
@@ -92,7 +92,7 @@
#if ENV_DECOMPRESSOR
#define DECOMPRESSOR(addr, sz) \
SYMBOL(decompressor, addr) \
- _edecompressor = _decompressor + sz; \
+ _edecompressor = ABSOLUTE(_decompressor + sz); \
_ = ASSERT(_eprogram - _program <= sz, \
STR(decompressor exceeded its allotted size! (sz))); \
INCLUDE "decompressor/lib/program.ld"
@@ -112,7 +112,7 @@
#if ENV_BOOTBLOCK
#define BOOTBLOCK(addr, sz) \
SYMBOL(bootblock, addr) \
- _ebootblock = _bootblock + sz; \
+ _ebootblock = ABSOLUTE(_bootblock + sz); \
_ = ASSERT(_eprogram - _program <= sz, \
STR(Bootblock exceeded its allotted size! (sz))); \
INCLUDE "bootblock/lib/program.ld"
@@ -124,7 +124,7 @@
#if ENV_ROMSTAGE
#define ROMSTAGE(addr, sz) \
SYMBOL(romstage, addr) \
- _eromstage = _romstage + sz; \
+ _eromstage = ABSOLUTE(_romstage + sz); \
_ = ASSERT(_eprogram - _program <= sz, \
STR(Romstage exceeded its allotted size! (sz))); \
INCLUDE "romstage/lib/program.ld"
@@ -136,7 +136,7 @@
#if ENV_RAMSTAGE
#define RAMSTAGE(addr, sz) \
SYMBOL(ramstage, addr) \
- _eramstage = _ramstage + sz; \
+ _eramstage = ABSOLUTE(_ramstage + sz); \
_ = ASSERT(_eprogram - _program <= sz, \
STR(Ramstage exceeded its allotted size! (sz))); \
INCLUDE "ramstage/lib/program.ld"
@@ -160,7 +160,7 @@
#if ENV_SEPARATE_VERSTAGE
#define VERSTAGE(addr, sz) \
SYMBOL(verstage, addr) \
- _everstage = _verstage + sz; \
+ _everstage = ABSOLUTE(_verstage + sz); \
_ = ASSERT(_eprogram - _program <= sz, \
STR(Verstage exceeded its allotted size! (sz))); \
INCLUDE "verstage/lib/program.ld"
@@ -179,7 +179,7 @@
#if ENV_POSTCAR
#define POSTCAR(addr, sz) \
SYMBOL(postcar, addr) \
- _epostcar = _postcar + sz; \
+ _epostcar = ABSOLUTE(_postcar + sz); \
_ = ASSERT(_eprogram - _program <= sz, \
STR(Aftercar exceeded its allotted size! (sz))); \
INCLUDE "postcar/lib/program.ld"