Run test arm-fpic-got.s (simplified ouput):
$ bin/llvm-lit --filter=arm-fpic-got -a tools/lld/test
...
RUN: at line 2: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi arm-fpic-got.s -o arm-fpic-got.s.tmp.o
RUN: at line 3: ld.lld arm-fpic-got.s.tmp.o -o arm-fpic-got.s.tmp
...
Input object:
$ llvm-objdump --disassemble --section=.text arm-fpic-got.s.tmp.o
Disassembly of section .text:
00000000 <_start>:
0: e59f0008 ldr r0, [pc, #0x8] @ 0x10 <_start+0x10>
4: e79f0000 ldr r0, [pc, r0]
8: e5900000 ldr r0, [r0]
c: e12fff1e <unknown>
10: 04 00 00 00 .word 0x00000004
$ llvm-objdump -r arm-fpic-got.s.tmp.o
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000010 R_ARM_GOT_PREL val
$ llvm-objdump --syms arm-fpic-got.s.tmp.o
SYMBOL TABLE:
00000000 g .text 00000000 _start
00000000 g O .data 00000004 val
Linked binary:
$ llvm-objdump --disassemble --section=.text arm-fpic-got.s.tmp
Disassembly of section .text:
00020114 <_start>:
20114: e59f0008 ldr r0, [pc, #0x8] @ 0x20124 <_start+0x10>
20118: e79f0000 ldr r0, [pc, r0]
2011c: e5900000 ldr r0, [r0]
20120: e12fff1e <unknown>
20124: 08 00 01 00 .word 0x00010008
$ llvm-objdump --full-contents --section=.got arm-fpic-got.s.tmp
Contents of section .got:
30128 2c010400 ,...
$ llvm-objdump --syms arm-fpic-got.s.tmp
SYMBOL TABLE:
00020114 g .text 00000000 _start
0004012c g O .data 00000004 val
Calculation:
20114: (pc + 0x08) + 0x08 == 0x0002011c + 0x00000008 == 0x00020124 --> r0 = 0x00010008
20118: (pc + 0x08) + r0 == 0x00020120 + 0x00010008 == 0x00030128 --> r0 = 0x0004012c (little-endian of 2c010400)