This is an archive of the discontinued LLVM Phabricator instance.

[ELF][AArch64] Fix unneeded thunk for branches to hidden undefined weak
ClosedPublic

Authored by MaskRay on Apr 13 2022, 6:22 PM.

Details

Summary

Similar to D119787 for PPC64.

A hidden undefined weak may change its binding to local before some
isUndefinedWeak code, so some isUndefinedWeak code needs to be changed to
isUndefined. The undefined non-weak case has been errored, so just using
isUndefined is fine.

The Linux kernel recently has a usage that a branch from 0xffff800008491ee0
references a hidden undefined weak symbol vfio_group_set_kvm.
It relies on the behavior that a branch to undefined weak resolving to the next
instruction, otherwise it'd see spurious relocation out of range errors.

Fixes https://github.com/ClangBuiltLinux/linux/issues/1624

Diff Detail

Event Timeline

MaskRay created this revision.Apr 13 2022, 6:22 PM
MaskRay requested review of this revision.Apr 13 2022, 6:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2022, 6:22 PM
MaskRay edited the summary of this revision. (Show Details)Apr 13 2022, 6:27 PM
peter.smith accepted this revision.Apr 14 2022, 5:50 AM

LGTM. One small suggestion for the comment.

lld/ELF/Arch/AArch64.cpp
260

Nit: An undefined non-weak symbol will have been errored.

This revision is now accepted and ready to land.Apr 14 2022, 5:50 AM
MaskRay marked an inline comment as done.Apr 14 2022, 11:32 AM