Skip to content

Commit 1e968bf

Browse files
samitolvanenjpoimboe
authored andcommitted
objtool: Use sh_info to find the base for .rela sections
ELF doesn't require .rela section names to match the base section. Use the section index in sh_info to find the section instead of looking it up by name. LLD, for example, generates a .rela section that doesn't match the base section name when we merge sections in a linker script for a binary compiled with -ffunction-sections. Signed-off-by: Sami Tolvanen <samitolvanen@google.com> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Reviewed-by: Kees Cook <keescook@chromium.org>
1 parent e000acc commit 1e968bf

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎tools/objtool/elf.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ static int read_relas(struct elf *elf)
508508
if (sec->sh.sh_type != SHT_RELA)
509509
continue;
510510

511-
sec->base = find_section_by_name(elf, sec->name + 5);
511+
sec->base = find_section_by_index(elf, sec->sh.sh_info);
512512
if (!sec->base) {
513513
WARN("can't find base section for rela section %s",
514514
sec->name);

0 commit comments

Comments
 (0)