[all-commits] [llvm/llvm-project] 686165: [llvm-objcopy][ELF] Avoid reordering section headers

Igor Kudrin via All-commits all-commits at lists.llvm.org
Thu Aug 12 03:22:23 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 68616584c3a5ce9352b37d24e408b171928f6840
      https://github.com/llvm/llvm-project/commit/68616584c3a5ce9352b37d24e408b171928f6840
  Author: Igor Kudrin <ikudrin at accesssoftek.com>
  Date:   2021-08-12 (Thu, 12 Aug 2021)

  Changed paths:
    R llvm/test/tools/llvm-objcopy/ELF/drawf-fission.test
    A llvm/test/tools/llvm-objcopy/ELF/dwarf-fission.test
    A llvm/test/tools/llvm-objcopy/ELF/dynsym-valid-refs.test
    R llvm/test/tools/llvm-objcopy/ELF/group-reorder.test
    M llvm/test/tools/llvm-objcopy/ELF/ihex-reader.test
    A llvm/test/tools/llvm-objcopy/ELF/layout-sections-by-original-offsets.test
    M llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test
    M llvm/test/tools/llvm-objcopy/ELF/shared-strtab-shstrtab.s
    M llvm/test/tools/llvm-objcopy/ELF/strip-dwo-groups.test
    M llvm/test/tools/llvm-objcopy/ELF/strip-dwo-inplace.test
    M llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
    M llvm/tools/llvm-objcopy/ELF/Object.cpp
    M llvm/tools/llvm-objcopy/ELF/Object.h

  Log Message:
  -----------
  [llvm-objcopy][ELF] Avoid reordering section headers

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 handy for a
user who analyzes the file.

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

Note that the patch removes sorting SHT_GROUP sections to the start of
the list, which was introduced in D62620 in order to ensure that they
come before the group members, along with the corresponding test. The
original issue was caused by the sorting of section headers, so dropping
the sorting also resolves the issue.

Differential Revision: https://reviews.llvm.org/D107653




More information about the All-commits mailing list