1// REQUIRES: arm 2// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o 3// RUN: ld.lld %t.o -o %t 4// RUN: llvm-readobj -S %t | FileCheck %s 5// RUN: llvm-readobj -S --symbols %t | FileCheck -check-prefix=SYMBOLS %s 6// RUN: llvm-objdump -d --no-show-raw-insn --triple=armv7a-none-linux-gnueabi %t | FileCheck --check-prefix=CODE %s 7 8// Test the R_ARM_GOT_PREL relocation 9 .syntax unified 10 .text 11 .globl _start 12 .align 2 13_start: 14 ldr r0, .LCPI0_0 15.LPC0_0: 16 ldr r0, [pc, r0] 17 ldr r0, [r0] 18 bx lr 19.LCPI0_0: 20.Ltmp0: 21 // Generate R_ARM_GOT_PREL 22 .long val(GOT_PREL)-((.LPC0_0+8)-.Ltmp0) 23 24 .data 25 .type val,%object 26 .globl val 27 .align 2 28val: 29 .long 10 30 .size val, 4 31 32// CHECK: Section { 33// CHECK: Name: .got 34// CHECK-NEXT: Type: SHT_PROGBITS 35// CHECK-NEXT: Flags [ 36// CHECK-NEXT: SHF_ALLOC 37// CHECK-NEXT: SHF_WRITE 38// CHECK-NEXT: ] 39// CHECK-NEXT: Address: 0x30128 40// CHECK-NEXT: Offset: 41// CHECK-NEXT: Size: 4 42// CHECK-NEXT: Link: 43// CHECK-NEXT: Info: 44// CHECK-NEXT: AddressAlignment: 4 45// CHECK-NEXT: EntrySize: 46 47// SYMBOLS: Name: val 48// SYMBOLS-NEXT: Value: 0x4012C 49// SYMBOLS-NEXT: Size: 4 50// SYMBOLS-NEXT: Binding: Global 51// SYMBOLS-NEXT: Type: Object 52// SYMBOLS-NEXT: Other: 53// SYMBOLS-NEXT: Section: .data 54 55// CODE: Disassembly of section .text: 56// CODE-EMPTY: 57// CODE-NEXT: <_start>: 58// CODE-NEXT: 20114: ldr r0, [pc, #8] 59// CODE-NEXT: 20118: ldr r0, [pc, r0] 60// CODE-NEXT: 2011c: ldr r0, [r0] 61// CODE-NEXT: 20120: bx lr 62// CODE: <$d.1>: 63// 0x11124 + 0x1008 + 8 = 0x12128 = .got 64// CODE-NEXT: 20124: 08 00 01 00 65