This test is currently triggering a segfault in lld, as reported in:
http://bugs.llvm.org/show_bug.cgi?id=31952
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Changing the code in InputFiles.cpp to avoid discarding SHT_GROUP sections in case when we're producing relocatable output fixes the crash. I'd be happy to upload that patch but I'm not 100% sure it's the best possible solution? Alternatively I can revert r294469 like you suggested and let @grimar look into it.
I do not really understand the issue yet, so I don't know how to fix this, but the basic rule is that if a change introduced a crash bug, it should be reverted and then re-submitted with a fix.
George,
Can you please take a look at this test and fix the issue? Petr tried to revert your change, but since other changes have been made on top of it, it couldn't be reverted cleanly, so we decided to not revert to avoid risk of regression. The crash bug is not super important but needs fixing. Thanks!
That probably would be bad idea to revert it. That is the case when change revealed bug, but not introduced.
Bug is next just in case:
- We have 2 object with SHT_GROUP sections foo. So that means "only one of the duplicate groups will be retained by the link-editor, and the members of the remaining groups will be discarded.".
- r294469 made the next change. During copyRelocations, it changed calculated offset for relocation from
P->r_offset = RelocatedSection->getOffset(Rel.r_offset);
to
P->r_offset = RelocatedSection->OutSec->Addr + RelocatedSection->getOffset(Rel.r_offset);
- And here is a problem RelocatedSection in the place of crash is InputSection<ELFT>::Discarded, because it is the member of one of duplicate groups which was discarded earlier by LLD in ObjectFile<ELFT>::initializeSections().
That way OurSec is null. Previous logic called getOffset of discarded section and did not crash. I believe that also was incorrect. Probably we should place asserts to check that methods of discarded sections are not called.
Fix is D29929. Looks caused by GNU as bug.