[PATCH] D42872: Fix handling of zero-size segments in llvm-objcopy

vit9696 via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 7 01:57:19 PST 2018


vit9696 updated this revision to Diff 133171.
vit9696 added a comment.

Thanks for the comments!

I did not mean to offend lld or any other linker, the point was to state that the ELF was not something hand-crafted but actually a real-world example generated by a dedicated tool.

The reason I chose FileSize is entirely practical. A "non-marker" segment with FileSize of zero should be unable to affect any other segments, in my opinion. Even if such an ELF would be considered partially valid. From what I remember, there also exists GNU_RELRO, which overlaps a segment, but its VirtAddr won't be 0, and it is unrelated to the case.

Regarding the rest I included the comments and a test case.

Regarding the logic of the check, I should admit that:

- this will not result in any segment removal;
- the offset assigned to GNU_STACK will remain 0;
- memory addresses are unaffected.

So a both examples suggested by @jhenderson will be fine.


Repository:
  rL LLVM

https://reviews.llvm.org/D42872

Files:
  test/tools/llvm-objcopy/marker-segment.test
  tools/llvm-objcopy/Object.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42872.133171.patch
Type: text/x-patch
Size: 3952 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180207/f7a8a8cc/attachment.bin>


More information about the llvm-commits mailing list