llvm-project/lld/test/ELF/arm-thumb-interwork-abs.s

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.5 KiB
ArmAsm
Raw Normal View History

[LLD][ELF][ARM] Do not substitute BL/BLX for non STT_FUNC symbols. Recommit of 0b4a047bfbd11fe1f5abda8da0e2391c1918162a (reverted in c29003813ab9bd6ea7b6de40ea8f1fe21979f13f) to incorporate subsequent fix and add a warning when LLD's interworking behavior has changed. D73474 disabled the generation of interworking thunks for branch relocations to non STT_FUNC symbols. This patch handles the case of BL and BLX instructions to non STT_FUNC symbols. LLD would normally look at the state of the caller and the callee and write a BL if the states are the same and a BLX if the states are different. This patch disables BL/BLX substitution when the destination symbol does not have type STT_FUNC. This brings our behavior in line with GNU ld which may prevent difficult to diagnose runtime errors when switching to lld. This change does change how LLD handles interworking of symbols that do not have type STT_FUNC from previous versions including the 10.0 release. This brings LLD in line with ld.bfd but there may be programs that have not been linked with ld.bfd that depend on LLD's previous behavior. We emit a warning when the behavior changes. A summary of the difference between 10.0 and 11.0 is that for symbols that do not have a type of STT_FUNC LLD will not change a BL to a BLX or vice versa. The table below enumerates the changes | relocation | STT_FUNC | bit(0) | in | 10.0- out | 11.0+ out | | R_ARM_CALL | no | 1 | BL | BLX | BL | | R_ARM_CALL | no | 0 | BLX | BL | BLX | | R_ARM_THM_CALL | no | 1 | BLX | BL | BLX | | R_ARM_THM_CALL | no | 0 | BL | BLX | BL | Differential Revision: https://reviews.llvm.org/D73542
2020-02-13 16:42:17 +08:00
// REQUIRES: arm
// RUN: llvm-mc --triple=armv7a-linux-gnueabihf -arm-add-build-attributes -filetype=obj -o %t.o %s
// RUN: ld.lld %t.o --defsym sym=0x13001 -o %t 2>&1 | FileCheck %s --check-prefix=WARN
// RUN: llvm-objdump --no-show-raw-insn -d %t | FileCheck %s
/// A similar test to arm-thumb-interwork-notfunc.s this time exercising the
/// case where a symbol does not have type STT_FUNC but it does have the bottom
/// bit set. We use absolute symbols to represent assembler labels as the
/// minimum alignment of a label in code is 2.
.syntax unified
.global sym
.global _start
.type _start, %function
.text
.balign 0x1000
_start:
arm_caller:
.arm
b sym
bl sym
// WARN: branch and link relocation: R_ARM_CALL to non STT_FUNC symbol: sym interworking not performed; consider using directive '.type sym, %function' to give symbol type STT_FUNC if interworking between ARM and Thumb is required
blx sym
.thumb
thumb_caller:
b sym
bl sym
blx sym
// WARN: branch and link relocation: R_ARM_THM_CALL to non STT_FUNC symbol: sym interworking not performed; consider using directive '.type sym, %function' to give symbol type STT_FUNC if interworking between ARM and Thumb is required
// CHECK: 00021000 <arm_caller>:
// CHECK-NEXT: 21000: b #-57352
// CHECK-NEXT: 21004: bl #-57356
// CHECK-NEXT: 21008: blx #-57360
[LLD][ELF][ARM] Do not substitute BL/BLX for non STT_FUNC symbols. Recommit of 0b4a047bfbd11fe1f5abda8da0e2391c1918162a (reverted in c29003813ab9bd6ea7b6de40ea8f1fe21979f13f) to incorporate subsequent fix and add a warning when LLD's interworking behavior has changed. D73474 disabled the generation of interworking thunks for branch relocations to non STT_FUNC symbols. This patch handles the case of BL and BLX instructions to non STT_FUNC symbols. LLD would normally look at the state of the caller and the callee and write a BL if the states are the same and a BLX if the states are different. This patch disables BL/BLX substitution when the destination symbol does not have type STT_FUNC. This brings our behavior in line with GNU ld which may prevent difficult to diagnose runtime errors when switching to lld. This change does change how LLD handles interworking of symbols that do not have type STT_FUNC from previous versions including the 10.0 release. This brings LLD in line with ld.bfd but there may be programs that have not been linked with ld.bfd that depend on LLD's previous behavior. We emit a warning when the behavior changes. A summary of the difference between 10.0 and 11.0 is that for symbols that do not have a type of STT_FUNC LLD will not change a BL to a BLX or vice versa. The table below enumerates the changes | relocation | STT_FUNC | bit(0) | in | 10.0- out | 11.0+ out | | R_ARM_CALL | no | 1 | BL | BLX | BL | | R_ARM_CALL | no | 0 | BLX | BL | BLX | | R_ARM_THM_CALL | no | 1 | BLX | BL | BLX | | R_ARM_THM_CALL | no | 0 | BL | BLX | BL | Differential Revision: https://reviews.llvm.org/D73542
2020-02-13 16:42:17 +08:00
// CHECK: 0002100c <thumb_caller>:
// CHECK-NEXT: 2100c: b.w #-57360
// CHECK-NEXT: 21010: bl #-57364
// CHECK-NEXT: 21014: blx #-57364