1 ## Test that we are able to print dynamic relocations with --dyn-relocations.
3 ## Check what we print when there are no dynamic relocations in an object.
4 # RUN: yaml2obj --docnum=1 %s -o %t1
5 # RUN: llvm-readobj --dyn-relocations %t1 2>&1 | FileCheck %s --check-prefix=LLVM-NONE
6 # RUN: llvm-readelf --dyn-relocations %t1 2>&1 | FileCheck %s --implicit-check-not={{.}} --allow-empty
8 # LLVM-NONE: Dynamic Relocations {
10 # LLVM-NONE-NOT: {{.}}
18 ## Check that we dump all possbile dynamic relocation sections.
19 # RUN: yaml2obj --docnum=2 %s -o %t2.1
20 # RUN: llvm-readobj --dyn-relocations %t2.1 2>&1 | \
21 # RUN: FileCheck %s --implicit-check-not=warning: --check-prefix=LLVM-RELOCS
22 # RUN: llvm-readelf --dyn-relocations %t2.1 2>&1 | \
23 # RUN: FileCheck %s --implicit-check-not=warning: --strict-whitespace \
24 # RUN: --match-full-lines --check-prefixes=GNU-RELOCS,GNU-PLTREL
27 # RUN: yaml2obj --docnum=2 %s -DDTPLTREL=7 -DPLTTYPE=SHT_RELA -DPLTRELSZ=0x18 -o %t2.2
28 # RUN: llvm-readobj --dyn-relocations %t2.2 2>&1 | \
29 # RUN: FileCheck %s --implicit-check-not=warning: --check-prefix=LLVM-RELOCS
30 # RUN: llvm-readelf --dyn-relocations %t2.2 2>&1 | \
31 # RUN: FileCheck %s --implicit-check-not=warning: --strict-whitespace \
32 # RUN: --match-full-lines --check-prefixes=GNU-RELOCS,GNU-PLTRELA
34 # LLVM-RELOCS: Dynamic Relocations {
35 # LLVM-RELOCS-NEXT: 0x8 R_X86_64_64 foo 0x0
36 # LLVM-RELOCS-NEXT: 0x1 R_X86_64_NONE foo 0x0
37 # LLVM-RELOCS-NEXT: 0x2 R_X86_64_NONE foo
38 # LLVM-RELOCS-NEXT: 0x4 R_X86_64_RELATIVE -
39 # LLVM-RELOCS-NEXT: 0x8 R_X86_64_NONE foo
42 # GNU-RELOCS:'CREL' relocation section at offset 0xa8:
43 # GNU-RELOCS-NEXT: Offset Info Type Symbol's Value Symbol's Name
44 # GNU-RELOCS-NEXT:0000000000000008 0000000100000001 R_X86_64_64 0000000000000000 foo + 0
46 # GNU-RELOCS:'RELA' relocation section at offset 0x78 contains 24 bytes:
47 # GNU-RELOCS-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
48 # GNU-RELOCS-NEXT:0000000000000001 0000000100000000 R_X86_64_NONE 0000000000000000 foo + 0
50 # GNU-RELOCS-NEXT:'REL' relocation section at offset 0x90 contains 16 bytes:
51 # GNU-RELOCS-NEXT: Offset Info Type Symbol's Value Symbol's Name
52 # GNU-RELOCS-NEXT:0000000000000002 0000000100000000 R_X86_64_NONE 0000000000000000 foo
54 # GNU-RELOCS-NEXT:'RELR' relocation section at offset 0xa0 contains 8 bytes:
55 # GNU-RELOCS-NEXT: Offset Info Type Symbol's Value Symbol's Name
56 # GNU-RELOCS-NEXT:0000000000000004 0000000000000008 R_X86_64_RELATIVE {{$}}
58 # GNU-PLTREL-NEXT:'PLT' relocation section at offset 0xac contains 16 bytes:
59 # GNU-PLTREL-NEXT: Offset Info Type Symbol's Value Symbol's Name
60 # GNU-PLTREL-NEXT:0000000000000008 0000000100000000 R_X86_64_NONE 0000000000000000 foo
61 # GNU-PLTRELA-NEXT:'PLT' relocation section at offset 0xac contains 24 bytes:
62 # GNU-PLTRELA-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
63 # GNU-PLTRELA-NEXT:0000000000000008 0000000100000000 R_X86_64_NONE 0000000000000000 foo + 0
65 # GNU-RELOCS-NOT:{{.}}
89 Entries: [ 0x0000000000000004 ]
97 Type: [[PLTTYPE=SHT_REL]]
111 ## 0x18 == offset of .rel.dyn in the segment.
118 ## 0x28 == offset of .relr.dyn section in the segment.
125 ## 0x30 == offset of .crel.dyn section in the segment.
128 ## 0x34 == offset of .plt section in the segment.
132 Value: [[DTPLTREL=17]] ## 17 == DT_REL
134 Value: [[PLTRELSZ=0x10]]
146 ## Check we report a warning when the value of the DT_PLTREL dynamic tag is invalid.
147 ## We currently accept DT_RELA(7) and DT_REL(17) values. This test case uses 0xff.
149 # RUN: yaml2obj --docnum=2 %s -DDTPLTREL=0xFF -o %t3
150 # RUN: llvm-readobj --dyn-relocations %t3 2>&1 | \
151 # RUN: FileCheck %s -DFILE=%t3 --implicit-check-not=warning: --check-prefix=PLTRELUNKNOWN-LLVM
152 # RUN: llvm-readelf --dyn-relocations %t3 2>&1 | \
153 # RUN: FileCheck %s -DFILE=%t3 --implicit-check-not=warning: --check-prefix=PLTRELUNKNOWN-GNU
155 # PLTRELUNKNOWN-LLVM: warning: '[[FILE]]': unknown DT_PLTREL value of 255
156 # PLTRELUNKNOWN-LLVM: Dynamic Relocations {
157 # PLTRELUNKNOWN-LLVM-NEXT: 0x8 R_X86_64_64 foo 0x0
158 # PLTRELUNKNOWN-LLVM-NEXT: 0x1 R_X86_64_NONE foo 0x0
159 # PLTRELUNKNOWN-LLVM-NEXT: 0x2 R_X86_64_NONE foo{{$}}
160 # PLTRELUNKNOWN-LLVM-NEXT: 0x4 R_X86_64_RELATIVE -{{$}}
161 # PLTRELUNKNOWN-LLVM-NEXT: warning: '[[FILE]]': invalid DT_PLTRELSZ value (0x10) or PLTREL entry size (0x0)
162 # PLTRELUNKNOWN-LLVM-NEXT: }
164 # PLTRELUNKNOWN-GNU: warning: '[[FILE]]': unknown DT_PLTREL value of 255
165 # PLTRELUNKNOWN-GNU-EMPTY:
166 # PLTRELUNKNOWN-GNU-NEXT: 'CREL' relocation section at offset 0xa8:
167 # PLTRELUNKNOWN-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name
168 # PLTRELUNKNOWN-GNU-NEXT: 0000000000000008 0000000100000001 R_X86_64_64 0000000000000000 foo + 0
169 # PLTRELUNKNOWN-GNU-EMPTY:
170 # PLTRELUNKNOWN-GNU-NEXT: 'RELA' relocation section at offset 0x78 contains 24 bytes:
171 # PLTRELUNKNOWN-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
172 # PLTRELUNKNOWN-GNU-NEXT: 0000000000000001 0000000100000000 R_X86_64_NONE 0000000000000000 foo + 0
173 # PLTRELUNKNOWN-GNU-EMPTY:
174 # PLTRELUNKNOWN-GNU-NEXT: 'REL' relocation section at offset 0x90 contains 16 bytes:
175 # PLTRELUNKNOWN-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name
176 # PLTRELUNKNOWN-GNU-NEXT: 0000000000000002 0000000100000000 R_X86_64_NONE 0000000000000000 foo
177 # PLTRELUNKNOWN-GNU-EMPTY:
178 # PLTRELUNKNOWN-GNU-NEXT: 'RELR' relocation section at offset 0xa0 contains 8 bytes:
179 # PLTRELUNKNOWN-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name
180 # PLTRELUNKNOWN-GNU-NEXT: 0000000000000004 0000000000000008 R_X86_64_RELATIVE
181 # PLTRELUNKNOWN-GNU-EMPTY:
182 # PLTRELUNKNOWN-GNU-NEXT: 'PLT' relocation section at offset 0xac contains 16 bytes:
183 # PLTRELUNKNOWN-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name
184 # PLTRELUNKNOWN-GNU-NEXT: warning: '[[FILE]]': invalid DT_PLTRELSZ value (0x10) or PLTREL entry size (0x0)