[PATCH] D107653: [llvm-objcopy][ELF] Avoid reordering section headers

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 6 08:28:35 PDT 2021


ikudrin created this revision.
ikudrin added reviewers: MaskRay, jakehehrlich, rupprecht, evgeny777.
ikudrin added a project: LLVM.
Herald added subscribers: abrachet, emaste.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a reviewer: jhenderson.
ikudrin requested review of this revision.

As for now, `llvm-objcopy` sorts section headers according to the offsets of the sections in the input file. 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 helpful for a user who analyzes the file.

While the patch removes global reordering of section headers, it layouts the sections the same way as before, i.e. according to their original offsets. All that helps the output file to resemble the input closely.

Note that the patch drops sorting of group sections to the start of the list that was introduced in D62620 <https://reviews.llvm.org/D62620>, along with the corresponding test. The original issue was caused by the sorting of section headers, so this patch resolves it in its own way.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107653

Files:
  llvm/test/tools/llvm-objcopy/ELF/drawf-fission.test
  llvm/test/tools/llvm-objcopy/ELF/dwarf-fission.test
  llvm/test/tools/llvm-objcopy/ELF/dynsym-valid-refs.test
  llvm/test/tools/llvm-objcopy/ELF/group-reorder.test
  llvm/test/tools/llvm-objcopy/ELF/ihex-reader.test
  llvm/test/tools/llvm-objcopy/ELF/layout-sections-by-original-offsets.test
  llvm/test/tools/llvm-objcopy/ELF/shared-strtab-shstrtab.s
  llvm/test/tools/llvm-objcopy/ELF/strip-dwo-groups.test
  llvm/test/tools/llvm-objcopy/ELF/strip-dwo-inplace.test
  llvm/tools/llvm-objcopy/ELF/Object.cpp
  llvm/tools/llvm-objcopy/ELF/Object.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107653.364805.patch
Type: text/x-patch
Size: 25273 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210806/47f90ffc/attachment.bin>


More information about the llvm-commits mailing list