[objcopy] make objcopy follow program header standards
authorJulie Hockett <juliehockett@google.com>
Wed, 12 Sep 2018 17:56:31 +0000 (17:56 +0000)
committerJulie Hockett <juliehockett@google.com>
Wed, 12 Sep 2018 17:56:31 +0000 (17:56 +0000)
commit468722ee9f74cf4eedc4b6bf2db34e43be6b7ec7
tree6a0dc7df03eacc16b6b68d31e27c60788ab0830f
parentebd4c906d870bc0e64e63fdf0fec3169bc4fc7d0
[objcopy] make objcopy follow program header standards

Submitted on behalf of Armando Montanez (amontanez@google.com).

Objects with unused program headers copied by objcopy would always have
nonzero values for program header offset and program header entry size.
While technically valid, this atypical behavior triggers warnings in some
tools. This change sets the two fields to zero when the program header is
unused, better fitting the general expectations for unused program header
data.

Section headers behaved somewhat similarly (though only with the entry size),
and are fixed in this revision as well.

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

llvm-svn: 342065
llvm/test/tools/llvm-objcopy/binary-input-arch.test
llvm/test/tools/llvm-objcopy/many-sections.test
llvm/test/tools/llvm-objcopy/relocatable-phdr.test [new file with mode: 0644]
llvm/test/tools/llvm-objcopy/strip-sections.test
llvm/tools/llvm-objcopy/Object.cpp