[PATCH] D107653: [llvm-objcopy][ELF] Avoid reordering section headers
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 9 22:11:58 PDT 2021
MaskRay added a comment.
D62620 <https://reviews.llvm.org/D62620> was related to section groups: "The section header table entry for a group section must appear in the section header table before the entries for any of the sections that are members of the group."
(ld.lld has dropped the limitation)
> That can corrupt section references in the dynamic symbol table because it is a loadable section and as such is not updated by the tool. Even though the section references are not required for loading the binary correctly, they are still handy for a user who analyzes the file.
All dynamic loaders I know only use 3 categories:
- SHN_UNDEF
- SHN_ABS
- other values
There are no behavior differences if an index of 1 is replaced with 2, but I agree that preserving the section index and making the output as close to the input as possible will be nice.
The approach looks good at a glance, but I'll need to look more closely tomorrow.
================
Comment at: llvm/test/tools/llvm-objcopy/ELF/dynsym-valid-refs.test:55
+ Sections:
+ - Name: dummy
+ - Name: .text
----------------
Add a comment that `dummy` is before `.text` by intention even if its offset is larger.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107653/new/
https://reviews.llvm.org/D107653
More information about the llvm-commits
mailing list