This is an archive of the discontinued LLVM Phabricator instance.

ELF: Do not use -1 to mark pieces of merge sections as being tail merged.
ClosedPublic

Authored by pcc on May 4 2016, 7:34 PM.

Details

Summary

We were previously using an output offset of -1 for both GC'd and tail
merged pieces. We need to distinguish these two cases in order to filter
GC'd symbols from the symbol table -- we were previously asserting when we
asked for the VA of a symbol pointing into a dead piece, which would end
up asking the tail merging string table for an offset even though we hadn't
initialized it properly.

This patch fixes the bug by using an offset of -1 to exclusively mean GC'd
pieces, using 0 for tail merges, and distinguishing the tail merge case from
an offset of 0 by asking the output section whether it is tail merge.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc updated this revision to Diff 56232.May 4 2016, 7:34 PM
pcc retitled this revision from to ELF: Do not use -1 to mark pieces of merge sections as being tail merged..
pcc updated this object.
pcc added reviewers: rafael, ruiu.
pcc added a subscriber: llvm-commits.
ruiu added inline comments.May 4 2016, 7:51 PM
ELF/Writer.cpp
1127–1129 ↗(On Diff #56232)

I may be missing something, but I don't think we gc pieces of mergeable sections. Instead, we gc a mergeable sections as a whole -- all the pieces in a mergeable section are gc'ed or not. So do you need this test?

pcc added inline comments.May 4 2016, 7:55 PM
ELF/Writer.cpp
1127–1129 ↗(On Diff #56232)

It looks like we're GCing pieces here: http://llvm-cs.pcc.me.uk/tools/lld/ELF/MarkLive.cpp#146

ruiu accepted this revision.May 4 2016, 7:57 PM
ruiu edited edge metadata.

Ah, ok, it's new code. Uses of 0 and -1 are a bit too mysterious. Please define constants for them. With that, LGTM.

This revision is now accepted and ready to land.May 4 2016, 7:57 PM
This revision was automatically updated to reflect the committed changes.