diff options
author | Julius Werner <jwerner@chromium.org> | 2021-02-12 17:37:27 -0800 |
---|---|---|
committer | Julius Werner <jwerner@chromium.org> | 2021-02-18 02:32:06 +0000 |
commit | 84446e6e54fa9df42fcbb8450c9a071feaf1f8d0 (patch) | |
tree | d300069dd3ff9f2cb59e86f9f320ce9018653196 /util/cbfstool/rmodule.h | |
parent | a2642d0ffe3ecba201a0bfe6b219e35b52c399ae (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 'util/cbfstool/rmodule.h')
-rw-r--r-- | util/cbfstool/rmodule.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/util/cbfstool/rmodule.h b/util/cbfstool/rmodule.h index a62562b98f..ec0971e27e 100644 --- a/util/cbfstool/rmodule.h +++ b/util/cbfstool/rmodule.h @@ -29,6 +29,8 @@ struct rmod_context { struct parsed_elf pelf; /* Program segment. */ Elf64_Phdr *phdr; + /* Symbol string table. */ + char *strtab; /* Collection of relocation addresses fixup in the module. */ Elf64_Xword nrelocs; |