This is an archive of the discontinued LLVM Phabricator instance.

[LLD][ELF][ARM] Fix case of patched unrelocated BLX
ClosedPublic

Authored by peter.smith on Jun 25 2021, 3:10 AM.

Details

Summary

There are a couple of problems with the code to patch unrelocated BLX instructions:

  • The calculation of the PC needs to take into account the alignment of the instruction. The Thumb BLX uses alignDown(PC, 4) for the source address.
  • The calculation of the PC bias is hard-coded to 4 which works for Thumb, but when there is a BLX the branch will be in Arm state so it needs an 8 byte PC bias.

No asssembler generates an unrelocated BLX instruction so these problems do not affect real world programs. However we should still fix them.

Depends on D104701 for objdump output of BLX

Diff Detail

Event Timeline

peter.smith created this revision.Jun 25 2021, 3:10 AM
ikudrin accepted this revision.Jun 28 2021, 3:29 AM

LGTM

This revision is now accepted and ready to land.Jun 28 2021, 3:29 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJun 30 2021, 6:08 AM