[PATCH] D51961: [objcopy] make objcopy follow program header standards
Jake Ehrlich via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 11 18:54:00 PDT 2018
jakehehrlich added inline comments.
================
Comment at: llvm/tools/llvm-objcopy/Object.cpp:1057
Ehdr.e_ehsize = sizeof(Elf_Ehdr);
Ehdr.e_shentsize = sizeof(Elf_Shdr);
if (WriteSectionHeaders) {
----------------
mcgrathr wrote:
> While you're at it, don't set shentsize when there are no sections.
You'll want to use `!WriteSectionHeaders || size(Obj.sections()) == 0` as the condition for that BTW. `WriteSectionHeaders` is normally true but is false when --strip-sections is used. WriteSectionHeaders isn't set to false when `size(Obj.sections()) == 0` is true
Thinking about it now the `if (WriteSectionHeaders)` below should probably be `WriteSectionHeaders && size(Obj.sections()) != 0` and then you can just set e_shentsize inside each branch of that if statement. That way if a sectionless object is input to llvm-objcopy it will output it with all those fields set to zero even though --strip-sections wasn't used.
https://reviews.llvm.org/D51961
More information about the llvm-commits
mailing list