[all-commits] [llvm/llvm-project] 8bb74d: [llvm-objcopy/strip] Fix off-by-one error in SYMTA...

James Henderson via All-commits all-commits at lists.llvm.org
Thu Mar 4 02:24:38 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8bb74d16ef04d83f71b1873e7c2e652fb8287b29
      https://github.com/llvm/llvm-project/commit/8bb74d16ef04d83f71b1873e7c2e652fb8287b29
  Author: James Henderson <james.henderson at sony.com>
  Date:   2021-03-04 (Thu, 04 Mar 2021)

  Changed paths:
    A llvm/test/tools/llvm-objcopy/ELF/auto-remove-add-symtab-shndx.test
    R llvm/test/tools/llvm-objcopy/ELF/auto-remove-shndx.test
    R llvm/test/tools/llvm-objcopy/ELF/strict-no-add.test
    M llvm/tools/llvm-objcopy/ELF/Object.cpp

  Log Message:
  -----------
  [llvm-objcopy/strip] Fix off-by-one error in SYMTAB_SHNDX need check

The check for whether an extended symbol index table was required
dropped the first SHN_LORESERVE sections from the sections array before
checking whether the remaining sections had symbols. Unfortunately, the
null section header is not present in this list, so the check was
skipping the first section that might be important. If that section
contained a symbol, and no subsequent ones did, the .symtab_shndx
section would not be emitted, leading to a corrupt object.

Also consolidate and expand test coverage in the area to cover this bug
and other aspects of the SYMTAB_SHNDX section.

Reviewed by: alexshap, MaskRay

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




More information about the All-commits mailing list