This is an archive of the discontinued LLVM Phabricator instance.

[LLD] Add support for multiple segments with same name
AbandonedPublic

Authored by zatrazz on May 20 2015, 11:28 AM.

Details

Summary

This patch fixes lld wrong relocation for objects with multiples segments
with same name (mostly due C++ EH cases for COMDAT group sections).

The issue is due the mapping from segments to relocation only the segment's
name is considered. So for cases where the object file constains more than
one segment with same name (.text for instance), some segments relocations
are complete ignored.

The patch changes this by considering the segment index references in the
group section while creating the mapping. It also adds a small optimization
on handleSectionGroup by avoiding using the string name, but rather the segment
header in the sections mapping (it should be no code generation changes for
this change).

With this change I could see no more failures with SingleSource for x86_64
and only TLS one for aarch64 (which currently misses TLS handling in
backend). I will still creating testcases, since it will require changes
for yaml2obj and obj2yaml to correct parse and create objects with multiple
segment of the same name.

Diff Detail

Event Timeline

zatrazz updated this revision to Diff 26165.May 20 2015, 11:28 AM
zatrazz retitled this revision from to [LLD] Add support for multiple segments with same name.
zatrazz updated this object.
zatrazz edited the test plan for this revision. (Show Details)
zatrazz added reviewers: ruiu, shankar.easwaran.
zatrazz added a project: lld.
zatrazz added subscribers: Unknown Object (MLST), lld.
This revision is now accepted and ready to land.May 20 2015, 11:39 AM
ruiu edited edge metadata.May 20 2015, 11:48 AM

Please add a test.

The testcase is my next step, but I need first to add support for multiple segments with same on yam2obj and obj2yaml tools before being able to correct add a testcase. Should I hold this patch until I finish the support for the tools?

ruiu added a comment.May 20 2015, 12:42 PM

Yeah, it's probably better to check in a patch with a test unless it's
urgent.

zatrazz abandoned this revision.May 26 2015, 5:16 AM

You can trivially create the files you need with llvm-mc. You can also
check in binaries.