Page MenuHomePhabricator

[AsmPrinter] Use linker-private symbols in xray_instr_map
Needs ReviewPublic

Authored by ilammy on Mar 11 2023, 8:03 AM.



When compiling with -fxray-instrument for Apple platforms, XRay pass
generates relocation entries that offend Mach-O linker on x86_64.

All emitted entries in xray_instr_map use local labels, so the entire
section ends up filled with local (r_extern=0) relocations, which is
not allowed on x86_64 in Mach-O.

The linker is able to figure it out as long as there is at least one
external relocation in the section, making all local relocations
piggyback on the external one before them. Indulge the linker with
some "private" symbols, which are considered external for relocation
purposes, but are otherwise local to object files (i.e., "static",
do not get globally exported and are generally removed after linking).

Depends on D145291

Diff Detail

Event Timeline

ilammy created this revision.Mar 11 2023, 8:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2023, 8:03 AM
ilammy requested review of this revision.Mar 11 2023, 8:03 AM