Page MenuHomePhabricator

[ELF] Restore GC handling of LINK_ORDER, C-named sections
ClosedPublic

Authored by eugenis on Mar 14 2017, 6:17 PM.

Details

Summary

start_xxx symbol keeps section xxx alive only if it is not
SHF_LINK_ORDER. Such sections can be used for user metadata, when
start_xxx is used to iterate over section contents at runtime, and
the liveness is determined solely by the linked (associated) section.

This was earlier implemented in r294592, and broken in r296723.

Diff Detail

Repository
rL LLVM

Event Timeline

eugenis created this revision.Mar 14 2017, 6:17 PM
ruiu added a subscriber: ruiu.Mar 14 2017, 8:20 PM

This seems correct, but I'm not totally convinced that this is the right thing to do, because I could probably argue the other way. How did you notice this, and why do you want this behavior?

grimar added a subscriber: grimar.Mar 15 2017, 3:45 AM

This testcase passes and without applying the patch.

test/ELF/gc-sections-metadata-startstop.s
8 ↗(On Diff #91806)

what is zz ? there is no such section in testcase.

eugenis updated this revision to Diff 91931.Mar 15 2017, 2:11 PM

Fix the test.

In D30964#701308, @ruiu wrote:

This seems correct, but I'm not totally convinced that this is the right thing to do, because I could probably argue the other way. How did you notice this, and why do you want this behavior?

See D30121 and related commits.
ASan is using this to emit metadata for global variables. Metadata sections have LINK_ORDER pointing to the corresponding global section, with the intention that the presence of metadata does not affect the liveness of globals in any way, and at runtime start_asan_globals .. stop_asan_globals can be used to enumerate metadata for the surviving globals.

eugenis updated this revision to Diff 92049.Mar 16 2017, 1:51 PM

Extend the test case with a check for __start_yy.

ruiu accepted this revision.Mar 16 2017, 5:43 PM

LGTM

This revision is now accepted and ready to land.Mar 16 2017, 5:43 PM
This revision was automatically updated to reflect the committed changes.