This is an archive of the discontinued LLVM Phabricator instance.

[COFF] Align ARM64 range extension thunks at instruction boundary
ClosedPublic

Authored by TomTan on Jan 9 2020, 12:05 PM.

Details

Summary

RangeExtensionThunkARM64 is created for out-of-range branches on Windows ARM64 because branch instructions has limited bits to encode target address. Currently, RangeExtensionThunkARM64 is appended to its referencing COFF section from object file at link time without any alignment requirement, so if size of the preceding COFF section is not aligned to instruction boundary (4 bytes), RangeExtensionThunkARM64 will emit thunk instructions at unaligned address which is never a valid branch target on ARM64, and usually trigger invalid instruction exception when branching to it.

This PR fixes it by requiring such thunks to align at 4 bytes.

Diff Detail

Event Timeline

TomTan created this revision.Jan 9 2020, 12:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 9 2020, 12:05 PM
mstorsjo accepted this revision.Jan 9 2020, 1:03 PM

LGTM, but I think we should do the same for RangeExtensionThunkARM as well (with alignment 2).

This revision is now accepted and ready to land.Jan 9 2020, 1:03 PM
This revision was automatically updated to reflect the committed changes.