[all-commits] [llvm/llvm-project] b3336b: [llvm-objcopy][ELF] --only-keep-debug: set offset/...

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed May 5 10:27:23 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b3336bfa2e6a38f16c4ecf4d77bd0f97ec5a46eb
      https://github.com/llvm/llvm-project/commit/b3336bfa2e6a38f16c4ecf4d77bd0f97ec5a46eb
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-05-05 (Wed, 05 May 2021)

  Changed paths:
    M llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test
    M llvm/tools/llvm-objcopy/ELF/Object.cpp

  Log Message:
  -----------
  [llvm-objcopy][ELF] --only-keep-debug: set offset/size of segments with no sections to zero

PR50160: we currently ignore non-PT_PHDR segments with no sections, not
accounting for its p_offset and p_filesz: this can cause an out-of-bounds write
in `writeSegmentData` if the p_offset+p_filesz is larger than the total file
size.

This can be fixed by setting p_offset=p_filesz=0. The logic nicely unifies with
the logic added in D90897.

Reviewed By: jhenderson, rupprecht

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




More information about the All-commits mailing list