Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ELF] Read ARM BuildAttributes section to determine supported features.
lld assumes some ARM features that are not available in all Arm processors. In particular: - The blx instruction present for interworking. - The movt/movw instructions are used in Thunks. - The J1=1 J2=1 encoding of branch immediates to improve Thumb wide branch range are assumed to be present. This patch reads the ARM Attributes section to check for the architecture the object file was compiled with. If none of the objects have an architecture that supports either of these features a warning will be given. This is most likely to affect armv6 as used in the first Raspberry Pi. Differential Revision: https://reviews.llvm.org/D36823 llvm-svn: 319169
- Loading branch information
Showing
5 changed files
with
152 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// RUN: llvm-mc -filetype=obj -triple=arm-none-linux-gnueabi %s -o %t | ||
// RUN: ld.lld %t -o %t2 2>&1 | FileCheck %s | ||
// Requires: arm | ||
|
||
// On Arm v6 the range of a Thumb BL instruction is only 4 megabytes as the | ||
// extended range encoding is not supported. The following example has a Thumb | ||
// BL that is out of range on ARM v6 and requires a range extension thunk. | ||
// As v6 does not support MOVT or MOVW instructions the Thunk must not | ||
// use these instructions either. At present we don't support v6 so we give a | ||
// warning for unsupported features. | ||
|
||
// CHECK: warning: lld uses extended branch encoding, no object with architecture supporting feature detected. | ||
// CHECK-NEXT: warning: lld may use movt/movw, no object with architecture supporting feature detected. | ||
// ARM v6 supports blx so we shouldn't see the blx not supported warning. | ||
// CHECK-NOT: warning: lld uses blx instruction, no object with architecture supporting feature detected. | ||
.text | ||
.syntax unified | ||
.cpu arm1176jzf-s | ||
.eabi_attribute 6, 6 @ Tag_CPU_arch | ||
.globl _start | ||
.type _start,%function | ||
.balign 0x1000 | ||
_start: | ||
bl thumbfunc | ||
bx lr | ||
|
||
.thumb | ||
.section .text.2, "ax", %progbits | ||
.globl thumbfunc | ||
.type thumbfunc,%function | ||
thumbfunc: | ||
bl farthumbfunc | ||
|
||
// 6 Megabytes, enough to make farthumbfunc out of range of caller on a v6 | ||
// Arm, but not on a v7 Arm. | ||
.section .text.3, "ax", %progbits | ||
.space 0x200000 | ||
|
||
.section .text.4, "ax", %progbits | ||
.space 0x200000 | ||
|
||
.section .text.5, "ax", %progbits | ||
.space 0x200000 | ||
|
||
.thumb | ||
.section .text.6, "ax", %progbits | ||
.balign 0x1000 | ||
.globl farthumbfunc | ||
.type farthumbfunc,%function | ||
farthumbfunc: | ||
bx lr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// RUN: llvm-mc -filetype=obj -triple=arm-none-linux-gnueabi %s -o %t | ||
// RUN: ld.lld %t -o %t2 2>&1 | FileCheck %s | ||
// REQUIRES: arm | ||
|
||
// On Arm v4t there is no blx instruction so all interworking must go via | ||
// a thunk. At present we don't support v4t so we give a warning for unsupported | ||
// features. | ||
|
||
// CHECK: warning: lld uses blx instruction, no object with architecture supporting feature detected. | ||
// CHECK-NEXT: warning: lld uses extended branch encoding, no object with architecture supporting feature detected. | ||
// CHECK-NEXT: warning: lld may use movt/movw, no object with architecture supporting feature detected. | ||
|
||
.text | ||
.syntax unified | ||
.cpu arm7tdmi | ||
.eabi_attribute 6, 2 @ Tag_CPU_arch | ||
.arm | ||
.globl _start | ||
.type _start,%function | ||
.p2align 2 | ||
_start: | ||
bl thumbfunc | ||
bx lr | ||
|
||
.thumb | ||
.section .text.2, "ax", %progbits | ||
.globl thumbfunc | ||
.type thumbfunc,%function | ||
thumbfunc: | ||
bx lr |