linux-IllusionX/tools/objtool
Michael Forney 86e1e054e0 objtool: Update section header before relocations
The libelf implementation from elftoolchain has a safety check in
gelf_update_rel[a] to check that the data corresponds to a section
that has type SHT_REL[A] [0]. If the relocation is updated before
the section header is updated with the proper type, this check
fails.

To fix this, update the section header first, before the relocations.
Previously, the section size was calculated in elf_rebuild_reloc_section
by counting the number of entries in the reloc_list. However, we
now need the size during elf_write so instead keep a running total
and add to it for every new relocation.

[0] https://sourceforge.net/p/elftoolchain/mailman/elftoolchain-developers/thread/CAGw6cBtkZro-8wZMD2ULkwJ39J+tHtTtAWXufMjnd3cQ7XG54g@mail.gmail.com/

Signed-off-by: Michael Forney <mforney@mforney.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20210509000103.11008-2-mforney@mforney.org
2021-10-06 20:11:57 -07:00
..
arch/x86 objtool: Make .altinstructions section entry size consistent 2021-10-05 12:03:20 -07:00
Documentation
include/objtool objtool: Remove redundant 'len' field from struct section 2021-10-05 12:03:21 -07:00
.gitignore
Build
builtin-check.c
builtin-orc.c
check.c objtool: Remove redundant 'len' field from struct section 2021-10-05 12:03:21 -07:00
elf.c objtool: Update section header before relocations 2021-10-06 20:11:57 -07:00
Makefile
objtool.c
orc_dump.c
orc_gen.c objtool: Remove redundant 'len' field from struct section 2021-10-05 12:03:21 -07:00
special.c objtool: Remove redundant 'len' field from struct section 2021-10-05 12:03:21 -07:00
sync-check.sh
weak.c