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.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Looks fine to me, but could we have a test, please?
tools/llvm-objcopy/Object.cpp | ||
---|---|---|
358 ↗ | (On Diff #109243) | Not sure if there's a typical way of doing this, but I have a preference for an explicit comparison against nullptr (i.e. Segment->firstSection() != nullptr). I'm happy either way though. |
377 ↗ | (On Diff #109243) | Ditto. |
The binary being uploaded can be downloaded here: https://drive.google.com/file/d/0B3gtIAmiMwZXNlZzckpOcEJfYzA/view?usp=sharing
It was compiled by clang (which I think just uses llvm-mc) and linked using ld.lld. It has a sectionless segment that covers a PT_PHDR segment. I plan on using this binary for multiple tests involving this strange case.
The test ensures that exactly the .text and .data sections worth of data is copied. If the extra PT_LOAD segment was copied it would cause the size to increase by at least a page.