[PATCH] D74755: [llvm-objcopy] Attribute an empty section to a segment ending at its address
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 17 22:13:52 PST 2020
MaskRay created this revision.
MaskRay added reviewers: grimar, jhenderson, rupprecht, kongyi.
Herald added subscribers: llvm-commits, abrachet, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: alexshap.
Herald added a project: LLVM.
sectionWithinSegment treats an empty section as having a size of 1.
Due to the rule, an empty .tdata will not be attributed to an empty PT_TLS.
--only-keep-debug will not layout a segment with no section
(layoutSegmentsForOnlyKeepDebug), thus p_offset of PT_TLS can go past
the end of the file. The strange p_offset can trigger validation errors, e.g.
llvm-objcopy errors when reading back the separate debug file
(readProgramHeaders).
This special rule is actually unneeded. So just delete it.
(A section can be added to multiple nested segments, e.g. PT_TLS \subset
PT_GNU_RELRO \subset PT_LOAD.)
A side effect is that an empty non-SHF_ALLOC section following SHF_ALLOC
sections will be considered included by a segment. The added test in
strip-non-alloc.test documents this behavior change, which should be
benign.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D74755
Files:
llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test
llvm/test/tools/llvm-objcopy/ELF/strip-all.test
llvm/test/tools/llvm-objcopy/ELF/strip-non-alloc.test
llvm/tools/llvm-objcopy/ELF/Object.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74755.245082.patch
Type: text/x-patch
Size: 6300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200218/f6c6355c/attachment.bin>
More information about the llvm-commits
mailing list