This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][MachO] Drop a 2015 ld64 workaround avoiding local relocations
ClosedPublic

Authored by MaskRay on Jun 13 2023, 9:48 AM.

Details

Summary

Commit d6223a24718df3c30b67422c2eb6d0e93af9c4e8 introduced an ld64 workaround
that disables local relocations for many pointer-sized relocations (e.g.
relocations referencing __DATA,__literal*).

ld64 has been fixed long ago (2015). Drop this workaround so that the
behavior matches x86-64.

This change fixes the following assembler error by emitting an ARM64_RELOC_UNSIGNED referencing the section xray_instr_map

// error: unsupported relocation of local symbol 'Lxray_sleds_end1'. Must have non-local symbol earlier in section.
        .section        __DATA,xray_instr_map
Lxray_sleds_start1:
        .space  13
Lxray_sleds_end1:

        .section        __DATA,xray_fn_idx
        .quad   Lxray_sleds_start1
        .quad   Lxray_sleds_end1

.subsections_via_symbols

(Though we will make xray_fn_idx entries PC-relative (D152661) to avoid the
issue in another way).

Diff Detail

Event Timeline

MaskRay created this revision.Jun 13 2023, 9:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 9:48 AM
MaskRay requested review of this revision.Jun 13 2023, 9:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 9:48 AM
MaskRay updated this revision to Diff 530951.Jun 13 2023, 9:51 AM

remove a stale comment

MaskRay edited the summary of this revision. (Show Details)Jun 18 2023, 11:30 AM
MaskRay edited the summary of this revision. (Show Details)

@ilammy This patch will fix the .quad Lxray_sleds_end1 (error: unsupported relocation of local symbol 'Lxray_sleds_end1'. Must have non-local symbol earlier in section.) issue for arm64-apple-darwin XRay.
Though D152661 (PC-relative entries) will avoid this construct in the first place.

pete accepted this revision.Jun 29 2023, 5:41 PM

I don't even remember this bug from the ld64 side. But yeah, if things are good now then i don't see any issue with this. Thanks!

This revision is now accepted and ready to land.Jun 29 2023, 5:41 PM

I don't even remember this bug from the ld64 side. But yeah, if things are good now then i don't see any issue with this. Thanks!

Thanks! It may be a long-forgotten bug :)