This is an archive of the discontinued LLVM Phabricator instance.

[SanitizerBinaryMetadata] Use weak __start_/__stop_ instead of dummy empty section
ClosedPublic

Authored by MaskRay on Dec 4 2022, 10:14 AM.

Details

Summary

D130887 uses a dummy empty section sanmd_covered (with the SHF_GNU_RETAIN flag on
ELF) to prevent undefined symbol: __start_sanmd_covered if all sanmd_covered
are discarded by ld --gc-sections (in -z start-stop-gc mode).

The dummy sanmd_covered does not have the SHF_LINK_ORDER flag, so mixing it
with SHF_LINK_ORDER sanmd_covered causes an issue to GNU ld<2.36
(https://sourceware.org/bugzilla/show_bug.cgi?id=26256).

Similar to D98903 for SanitizerCoverage, let's make encapsulation symbols
undefined weak instead. This additionally avoids size cost due to the dummy
section and symbol.

Diff Detail

Event Timeline

MaskRay created this revision.Dec 4 2022, 10:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 4 2022, 10:14 AM
MaskRay requested review of this revision.Dec 4 2022, 10:14 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptDec 4 2022, 10:14 AM
melver accepted this revision.Dec 4 2022, 2:54 PM

Thanks - yes this looks better.

This revision is now accepted and ready to land.Dec 4 2022, 2:54 PM
This revision was landed with ongoing or failed builds.Dec 4 2022, 3:06 PM
This revision was automatically updated to reflect the committed changes.