[lld] 5355b8c - [ELF] Restore arm-branch.s test

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 17 03:09:12 PDT 2021


Author: Igor Kudrin
Date: 2021-06-17T17:08:13+07:00
New Revision: 5355b8c6318c194ff15241b7a3217a51fc1a644b

URL: https://github.com/llvm/llvm-project/commit/5355b8c6318c194ff15241b7a3217a51fc1a644b
DIFF: https://github.com/llvm/llvm-project/commit/5355b8c6318c194ff15241b7a3217a51fc1a644b.diff

LOG: [ELF] Restore arm-branch.s test

After D77330, the comments are inconsistent with the disassembled code.
As the value of `far` has been changed, a thunk to reach it is now
generated, and target addresses of branch instructions are different
from what was initially expected.

The patch fixes that and makes the test closer to what it was originally.

Differential Revision: https://reviews.llvm.org/D104286

Added: 
    

Modified: 
    lld/test/ELF/Inputs/far-arm-abs.s
    lld/test/ELF/Inputs/far-long-arm-abs.s
    lld/test/ELF/arm-branch.s

Removed: 
    


################################################################################
diff  --git a/lld/test/ELF/Inputs/far-arm-abs.s b/lld/test/ELF/Inputs/far-arm-abs.s
index 47882592029ed..23361301c137d 100644
--- a/lld/test/ELF/Inputs/far-arm-abs.s
+++ b/lld/test/ELF/Inputs/far-arm-abs.s
@@ -1,7 +1,3 @@
-.global far
-.type far,%function
-far = 0x202001c
-
 .global too_far1
 .type too_far1,%function
 too_far1 = 0x2030008

diff  --git a/lld/test/ELF/Inputs/far-long-arm-abs.s b/lld/test/ELF/Inputs/far-long-arm-abs.s
index 61c11e6690c83..7cb350eeb0814 100644
--- a/lld/test/ELF/Inputs/far-long-arm-abs.s
+++ b/lld/test/ELF/Inputs/far-long-arm-abs.s
@@ -1,7 +1,3 @@
-.global far
-.type far,%function
-far = 0x202001c
-
 .global too_far1
 .type too_far1,%function
 too_far1 = 0x2030014
@@ -10,4 +6,4 @@ too_far1 = 0x2030014
 too_far2 = 0x2030020
 .global too_far3
 .type too_far3,%function
-too_far3 = 0x203002c
\ No newline at end of file
+too_far3 = 0x203002c

diff  --git a/lld/test/ELF/arm-branch.s b/lld/test/ELF/arm-branch.s
index 27d6313bd301f..4d3b6a5adec6c 100644
--- a/lld/test/ELF/arm-branch.s
+++ b/lld/test/ELF/arm-branch.s
@@ -1,13 +1,19 @@
+/// Test the Arm state R_ARM_CALL and R_ARM_JUMP24 relocation to Arm state destinations.
+/// R_ARM_CALL is used for branch and link (BL)
+/// R_ARM_JUMP24 is used for unconditional and conditional branches (B and B<cc>)
+/// Relocations defined in https://github.com/ARM-software/abi-aa/blob/main/aaelf32/aaelf32.rst
+/// Addend A is always -8 to cancel out Arm state PC-bias of 8 bytes
+
 // REQUIRES: arm
 // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
-// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/far-arm-abs.s -o %tfar
 // RUN: echo "SECTIONS { \
 // RUN:          . = 0xb4; \
 // RUN:          .callee1 : { *(.callee_low) } \
 // RUN:          .caller : { *(.text) } \
 // RUN:          .callee2 : { *(.callee_high) } } " > %t.script
-// RUN: ld.lld --script %t.script %t %tfar -o %t2
+// RUN: ld.lld --defsym=far=0x201001c --script %t.script %t -o %t2
 // RUN: llvm-objdump -d --no-show-raw-insn --triple=armv7a-none-linux-gnueabi %t2 | FileCheck  %s
+
  .syntax unified
  .section .callee_low, "ax",%progbits
  .align 2
@@ -38,22 +44,22 @@ callee_high:
  bx lr
 
 // CHECK: 00010000 <_start>:
-/// S(callee_low) = 0xb4 P = 0x10000 A = -8 = -0xff54 = -65364
+/// S(callee_low) = 0xb4; P = 0x10000; A = -8; S + A - P = -0xff54 = -65364
 // CHECK-NEXT:   10000:       bl      #-65364 <callee_low>
-/// S(callee_low) = 0xb4 P = 0x10004 A = -8 = -0xff58 = -65368
+/// S(callee_low) = 0xb4; P = 0x10004; A = -8; S + A - P = -0xff58 = -65368
 // CHECK-NEXT:   10004:       b       #-65368 <callee_low>
-/// S(callee_low) = 0xb4 P = 0x10008 A = -8 = -0xff5c -65372
+/// S(callee_low) = 0xb4; P = 0x10008; A = -8; S + A - P = -0xff5c = -65372
 // CHECK-NEXT:   10008:       beq     #-65372 <callee_low>
-/// S(callee_high) = 0x10028 P = 0x1000c A = -8 = 0x14 = 20
-// CHECK-NEXT:   1000c:       bl      #28 <callee_high>
-/// S(callee_high) = 0x10028 P = 0x10010 A = -8 = 0x10 = 16
-// CHECK-NEXT:   10010:       b       #24 <callee_high>
-/// S(callee_high) = 0x10028 P = 0x10014 A = -8 = 0x0c =12
-// CHECK-NEXT:   10014:       bne     #20 <callee_high>
-/// S(far) = 0x201001c P = 0x10018 A = -8 = 0x1fffffc = 33554428
-// CHECK-NEXT:   10018:       bl      #8
-/// S(far) = 0x201001c P = 0x1001c A = -8 = 0x1fffff8 = 33554424
-// CHECK-NEXT:   1001c:       b       #4
-/// S(far) = 0x201001c P = 0x10020 A = -8 = 0x1fffff4 = 33554420
-// CHECK-NEXT:   10020:       bgt     #0
+/// S(callee_high) = 0x10028; P = 0x1000c; A = -8; S + A - P = 0x14 = 20
+// CHECK-NEXT:   1000c:       bl      #20 <callee_high>
+/// S(callee_high) = 0x10028; P = 0x10010; A = -8; S + A - P = 0x10 = 16
+// CHECK-NEXT:   10010:       b       #16 <callee_high>
+/// S(callee_high) = 0x10028; P = 0x10014; A = -8; S + A - P = 0x0c = 12
+// CHECK-NEXT:   10014:       bne     #12 <callee_high>
+/// S(far) = 0x201001c; P = 0x10018; A = -8; S + A - P = 0x1fffffc = 33554428
+// CHECK-NEXT:   10018:       bl      #33554428
+/// S(far) = 0x201001c; P = 0x1001c; A = -8; S + A - P = 0x1fffff8 = 33554424
+// CHECK-NEXT:   1001c:       b       #33554424
+/// S(far) = 0x201001c; P = 0x10020; A = -8; S + A - P = 0x1fffff4 = 33554420
+// CHECK-NEXT:   10020:       bgt     #33554420
 // CHECK-NEXT:   10024:       bx      lr


        


More information about the llvm-commits mailing list