2 ## The i386 psABI uses Elf64_Rela relocation entries. We produce
3 ## Elf32_Rel dynamic relocations by default, but can use Elf32_Rela with -z rela.
5 # RUN: llvm-mc -filetype=obj -triple=i386 %s -o %t.o
6 # RUN: ld.lld -shared %t.o -o %t.so --noinhibit-exec
7 # RUN: llvm-readobj -d -r -x .data -x .got.plt %t.so | FileCheck --check-prefix=REL %s
8 # RUN: ld.lld -shared -z rel %t.o -o %t1.so
9 # RUN: llvm-readobj -d -r -x .data -x .got.plt %t1.so | FileCheck --check-prefix=REL %s
12 # REL-NEXT: RELSZ 32 (bytes)
13 # REL-NEXT: RELENT 8 (bytes)
14 # REL-NEXT: RELCOUNT 1
15 # REL-NEXT: JMPREL {{.*}}
16 # REL-NEXT: PLTRELSZ 8 (bytes)
17 # REL-NEXT: PLTGOT {{.*}}
18 # REL-NEXT: PLTREL REL{{$}}
20 # REL-NEXT: R_386_RELATIVE -
21 # REL-NEXT: R_386_GLOB_DAT func
22 # REL-NEXT: R_386_TLS_TPOFF tls
23 # REL-NEXT: R_386_32 _start
25 # REL-NEXT: .rel.plt {
26 # REL-NEXT: R_386_JUMP_SLOT func
29 # REL-LABEL: Hex dump of section '.data':
30 # REL-NEXT: 0x000042d0 d0420000 2a000000
31 ## ^--- R_386_RELATIVE addend (0x42d0)
32 ## ^--- R_386_32 addend (0x2a)
33 # REL-LABEL: Hex dump of section '.got.plt':
34 # REL-NEXT: 0x000042d8 48320000 00000000 00000000 36120000
35 ## R_386_JUMP_SLOT target (0x1236) ---------------^
37 # RUN: ld.lld -shared -z rel -z rela %t.o -o %t2.so
38 # RUN: llvm-readobj -d -r -x .data -x .got.plt %t2.so | FileCheck --check-prefix=RELA %s
41 # RELA-NEXT: RELASZ 48 (bytes)
42 # RELA-NEXT: RELAENT 12 (bytes)
43 # RELA-NEXT: RELACOUNT 1
44 # RELA-NEXT: JMPREL {{.*}}
45 # RELA-NEXT: PLTRELSZ 12 (bytes)
46 # RELA-NEXT: PLTGOT {{.*}}
47 # RELA-NEXT: PLTREL RELA
49 # RELA-NEXT: R_386_RELATIVE - 0x42F0
50 # RELA-NEXT: R_386_GLOB_DAT func 0x0
51 # RELA-NEXT: R_386_TLS_TPOFF tls 0x0
52 # RELA-NEXT: R_386_32 _start 0x2A
54 # RELA-NEXT: .rela.plt {
55 # RELA-NEXT: R_386_JUMP_SLOT func 0x0
58 # RELA-LABEL: Hex dump of section '.data':
59 # RELA-NEXT: 0x000042f0 00000000 2a000000
60 ## ^--- R_386_32 addend (0x2a)
61 ## TODO: we should probably clear the R_386_32 addend that was copied from the .o?
62 ## no addend written for R_386_RELATIVE
63 # RELA-LABEL: Hex dump of section '.got.plt':
64 # RELA-NEXT: 0x000042f8 68320000 00000000 00000000 56120000
65 ## R_386_JUMP_SLOT target (0x1256) ----------------^
70 movl func@GOT
(%eax
), %eax
73 movl tls@GOTNTPOFF
(%eax
), %eax