summaryrefslogtreecommitdiff
path: root/tests
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 /tests
parenta2642d0ffe3ecba201a0bfe6b219e35b52c399ae (diff)
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 'tests')
-rw-r--r--tests/Makefile.inc4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/Makefile.inc b/tests/Makefile.inc
index 56d557879e..a10e9bf73b 100644
--- a/tests/Makefile.inc
+++ b/tests/Makefile.inc
@@ -48,6 +48,10 @@ TEST_CFLAGS += -I$(cmockasrc)/include
TEST_LDFLAGS = -L$(cmockaobj)/src -lcmocka -Wl,-rpath=$(cmockaobj)/src
TEST_LDFLAGS += -Wl,--gc-sections
+# Some memlayout symbols don't work with userspace relocation -- disable it.
+TEST_CFLAGS += -fno-pie -fno-pic
+TEST_LDFLAGS += -no-pie
+
# Extra attributes for unit tests, declared per test
attributes:= srcs cflags mocks stage