[llvm][llvm-objcopy] When outputting to binary don't output segments that cover no...
authorPetr Hosek <phosek@chromium.org>
Fri, 4 Aug 2017 23:18:18 +0000 (23:18 +0000)
committerPetr Hosek <phosek@chromium.org>
Fri, 4 Aug 2017 23:18:18 +0000 (23:18 +0000)
commitd53951d2ef7e3883a51680958b95d35a360c6562
treefc8adaa5620e095e7e583facdbf9cdbef36ab3cf
parentbe7a35769dbc850961818c405ef82189bda7225e
[llvm][llvm-objcopy] When outputting to binary don't output segments that cover no sections

Sometimes LLD will produce a PT_LOAD segment that only covers the
headers (and covers no sections). GNU objcopy does not output the
segment contents for these sections. In particular this is an issue in
building magenta because the final link step for the kernel would
produce just such a PT_LOAD segment. This change is to support this case
and to match what GNU objcopy does in this case.

Patch by Jake Ehrlich

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

llvm-svn: 310149
llvm/test/tools/llvm-objcopy/Inputs/pt-phdr.elf [new file with mode: 0644]
llvm/test/tools/llvm-objcopy/sectionless-segment.test [new file with mode: 0644]
llvm/tools/llvm-objcopy/Object.cpp