This is an archive of the discontinued LLVM Phabricator instance.

Fully precise gc handling of __start and __stop symbols
ClosedPublic

Authored by rafael on Mar 2 2017, 11:55 AM.

Details

Reviewers
ruiu
Summary

This puts us at parity with bfd, which could already gc this case.

I noticed the sections not being gced when linking a modified freebsd kernel. A section that was not gced and not mentioned in the linker script would end up breaking the expected layout. Since fixing the gc is relatively simple and an improvement, that seems better than trying to hack the orphan placement code.

There are 173 input section in the entire link whose names are valid C identifiers, so a std::vector is probably better than a multimap.

Diff Detail

Event Timeline

rafael created this revision.Mar 2 2017, 11:55 AM
ruiu added inline comments.Mar 2 2017, 12:16 PM
ELF/MarkLive.cpp
69

Can you .reset() this at beginning of markLive() so that markLive is safe to run more than once.

Maybe DenseSet instead of a vector? It is a set of strings, so a set seems more natural.

rafael updated this revision to Diff 90720.Mar 6 2017, 9:59 AM

Use a DenseMap and clear it.

Not that this has to be a map to a std::vector since it has to include multiple sections. If we hit an undefined reference to __start_foo, we have to mark live all sections named foo.

ruiu added inline comments.Mar 6 2017, 10:06 AM
ELF/MarkLive.cpp
253

Can you simplify resolveReloc if you add two entries ("__start_" + Sec->Name and "__end_" + Sec->Name) for one section?

rafael updated this revision to Diff 90723.Mar 6 2017, 10:39 AM

Simplify by mapping from symbol name to section.

ruiu accepted this revision.Mar 6 2017, 10:41 AM

LGTM

This revision is now accepted and ready to land.Mar 6 2017, 10:41 AM
espindola closed this revision.Mar 14 2018, 4:15 PM
espindola added a subscriber: espindola.

297049