x86/tools/relocs: Support >64K section headers
authorKristen Carlson Accardi <kristen@linux.intel.com>
Wed, 13 Oct 2021 17:57:39 +0000 (10:57 -0700)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 27 Oct 2021 09:07:58 +0000 (11:07 +0200)
commita54c401ae66fc78f3f0002938b3465ebd6379009
tree4b4baf60af608475167868cb59a53e4b47328ee0
parent541ac97186d9ea88491961a46284de3603c914fd
x86/tools/relocs: Support >64K section headers

While the relocs tool already supports finding the total number of
section headers if vmlinux exceeds 64K sections, it fails to read the
extended symbol table to get section header indexes for symbols, causing
incorrect symbol table indexes to be used when there are > 64K symbols.

Parse the ELF file to read the extended symbol table info, and then
replace all direct references to st_shndx with calls to sym_index(),
which will determine whether the value can be read directly or whether
the value should be pulled out of the extended table.

This is needed for future FGKASLR support, which uses a separate section
per function.

Signed-off-by: Kristen Carlson Accardi <kristen@linux.intel.com>
Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Acked-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Tested-by: Tony Luck <tony.luck@intel.com>
Link: https://lore.kernel.org/r/20211013175742.1197608-2-keescook@chromium.org
arch/x86/tools/relocs.c