Page MenuHomePhabricator

[LLD][ELF][ARM] Add support for older Arm Architectures with smaller branch range
ClosedPublic

Authored by peter.smith on Jul 31 2018, 9:01 AM.

Details

Summary

The Thumb BL and BLX instructions on older Arm Architectures such as v5 and v6 have a constrained encoding that forces the J1 and J2 bits to be equal to 1. Later Architectures relaxed this restriction allowing J1 and J2 to be used to calculate a larger immediate.

This patch adds support for the old encoding when the build attributes for the input objects only contain older architectures. This permits the removal of the warning that LLD always uses the extended branch encoding. I've added --arm-add-build-attributes (generate build attributes from the --triple argument) to the llvm-mc arguments for existing tests that depend on the new encodings.

The J1 and J2 bits are defined in the Arm Architecture Reference Manual: https://developer.arm.com/products/architecture/cpu-architecture/a-profile/docs/ddi0406/latest/arm-architecture-reference-manual-armv7-a-and-armv7-r-edition (search for "BL, BLX (immediate)")

This is patch 1 of 2 to support Arm Architecture v5 and Arm Architecture v6 (as far as a linker is concerned there is no difference between v5 and v6). This will enable LLD to be used to target the first edition of the Raspberry Pi. Patch 2 adds v5/v6 compatible range extension Thunks.

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

peter.smith created this revision.Jul 31 2018, 9:01 AM
ruiu added a comment.Jul 31 2018, 1:17 PM

Overall looking good, but who sets Config->ARMJ1J2BranchEncoding to true? Looks like the flag is currently always false.

grimar added a comment.Aug 1 2018, 1:21 AM

Overall looking good, but who sets Config->ARMJ1J2BranchEncoding to true? Looks like the flag is currently always false.

It is set here: https://github.com/llvm-mirror/lld/blob/master/ELF/InputFiles.cpp#L570

Ping, I don't think that there are any outstanding comments that need addressing.

I have no comments here. It looks good to me either.

ruiu accepted this revision.Aug 20 2018, 1:36 AM

LGTM

This revision is now accepted and ready to land.Aug 20 2018, 1:36 AM
This revision was automatically updated to reflect the committed changes.