This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Allow multiple comdats when producing relocatable output.
ClosedPublic

Authored by grimar on May 29 2017, 2:56 AM.

Details

Summary

Previously LLD would fail for case when there are multiple comdats and -r.

That happened because it merged all ".group" (SHT_GROUP) sections into single
output, producing broken result. Such sections may have similar name, alignment and flags
and other properties. I think all we need to do for fix is to produce separate output
section for each such input one.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.May 29 2017, 2:56 AM
grimar planned changes to this revision.May 29 2017, 10:02 AM

I think this is not correct. I'll revisit it tomorrow.

grimar updated this revision to Diff 100669.May 30 2017, 1:36 AM
grimar edited the summary of this revision. (Show Details)
ruiu edited edge metadata.Jun 5 2017, 7:55 AM

How can this happen? I believe we dedup SHT_GROUP sections even if the -r option is given, so we want to emit only one SHT_GROUP for each unique name, no?

grimar added a comment.Jun 5 2017, 8:16 AM
In D33643#772824, @ruiu wrote:

How can this happen? I believe we dedup SHT_GROUP sections even if the -r option is given, so we want to emit only one SHT_GROUP for each unique name, no?

Dedup does not help here, because groups are different. We have group A and section named ".group" + group .B with section ".group" too.
Afted deduplication we still have 2 sections named ".group". And idea is that we should emit different output sections for each, because
after deduplication we definetely know them are different groups.

ruiu accepted this revision.Jun 5 2017, 8:53 AM

LGTM with this change.

ELF/OutputSections.cpp
363–365 ↗(On Diff #100669)

Then this explanation doesn't capture why we are doing this.

Sections with the SHT_GROUP attribute reach here only when the -r option is given. Such sections define "section groups", and InputFiles.cpp has dedup'ed section groups by their signatures. For the -r, we want to pass through all SHT_GROUP sections without merging them because merging them creates broken section contents.
This revision is now accepted and ready to land.Jun 5 2017, 8:53 AM
This revision was automatically updated to reflect the committed changes.