Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / arm-got-relative.s
blob4add78feec90f58c871c31e8824bef89ab5f5e42
1 // REQUIRES: arm
2 // RUN: llvm-mc -position-independent -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
3 // RUN: ld.lld %t.o -shared -o %t
4 // RUN: llvm-readobj -S --symbols --dyn-relocations %t | FileCheck %s
5 // RUN: llvm-objdump --no-print-imm-hex -d --triple=armv7a-none-linux-gnueabi %t | FileCheck --check-prefix=CODE %s
6 .syntax unified
7 .text
8 .globl _start
9 .align 2
10 _start:
11 .type _start, %function
12 ldr r3, .LGOT
13 ldr r2, .LGOT+4
14 .LPIC:
15 add r0, pc, r3
16 bx lr
17 .align 2
18 .LGOT:
19 // gas implicitly uses (R_ARM_BASE_PREL) for _GLOBAL_OFFSET_TABLE_ in PIC
20 // llvm-mc generates R_ARM_REL32, this will need updating when MC changes
21 .word _GLOBAL_OFFSET_TABLE_ - (.LPIC+8)
22 .word function(GOT)
24 .globl function
25 .align 2
26 function:
27 .type function, %function
28 bx lr
30 // CHECK: Dynamic Relocations {
31 // CHECK-NEXT: 0x2020C R_ARM_GLOB_DAT function
33 // CHECK: Name: _GLOBAL_OFFSET_TABLE_
34 // CHECK-NEXT: Value: 0x2020C
35 // CHECK-NEXT: Size:
36 // CHECK-NEXT: Binding: Local
37 // CHECK-NEXT: Type: None
38 // CHECK-NEXT: Other [
39 // CHECK-NEXT: STV_HIDDEN
40 // CHECK-NEXT: ]
41 // CHECK-NEXT: Section: .got
43 // CODE: Disassembly of section .text:
44 // CODE-EMPTY:
45 // CODE-NEXT: <_start>:
46 // CODE-NEXT: 101a0: e59f3008 ldr r3, [pc, #8]
47 // CODE-NEXT: 101a4: e59f2008 ldr r2, [pc, #8]
48 // CODE-NEXT: 101a8: e08f0003 add r0, pc, r3
49 // CODE-NEXT: 101ac: e12fff1e bx lr
50 // (_GLOBAL_OFFSET_TABLE_ = 0x220c) - (0x11a8 + 8) = 0x105c
51 // CODE-NEXT: 101b0: 5c 00 01 00
52 // (Got(function) - GotBase = 0x0
53 // CODE-NEXT: 101b4: 00 00 00 00