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: 0x1 R_X86_64_NONE foo 0x0
36 # LLVM-RELOCS-NEXT: 0x2 R_X86_64_NONE foo
37 # LLVM-RELOCS-NEXT: 0x4 R_X86_64_RELATIVE
38 # LLVM-RELOCS-NEXT: 0x8 R_X86_64_NONE foo
41 # GNU-RELOCS:'RELA' relocation section at offset 0x78 contains 24 bytes:
42 # GNU-RELOCS-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
43 # GNU-RELOCS-NEXT:0000000000000001 0000000100000000 R_X86_64_NONE 0000000000000000 foo + 0
45 # GNU-RELOCS-NEXT:'REL' relocation section at offset 0x90 contains 16 bytes:
46 # GNU-RELOCS-NEXT: Offset Info Type Symbol's Value Symbol's Name
47 # GNU-RELOCS-NEXT:0000000000000002 0000000100000000 R_X86_64_NONE 0000000000000000 foo
49 # GNU-RELOCS-NEXT:'RELR' relocation section at offset 0xa0 contains 8 bytes:
50 # GNU-RELOCS-NEXT: Offset Info Type Symbol's Value Symbol's Name
51 # GNU-RELOCS-NEXT:0000000000000004 0000000000000008 R_X86_64_RELATIVE {{$}}
53 # GNU-PLTREL-NEXT:'PLT' relocation section at offset 0xa8 contains 16 bytes:
54 # GNU-PLTREL-NEXT: Offset Info Type Symbol's Value Symbol's Name
55 # GNU-PLTREL-NEXT:0000000000000008 0000000100000000 R_X86_64_NONE 0000000000000000 foo
56 # GNU-PLTRELA-NEXT:'PLT' relocation section at offset 0xa8 contains 24 bytes:
57 # GNU-PLTRELA-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
58 # GNU-PLTRELA-NEXT:0000000000000008 0000000100000000 R_X86_64_NONE 0000000000000000 foo + 0
60 # GNU-RELOCS-NOT:{{.}}
84 Entries: [ 0x0000000000000004 ]
86 Type: [[PLTTYPE=SHT_REL]]
100 ## 0x18 == offset of .rel.dyn in the segment.
107 ## 0x28 == offset of .relr.dyn section in the segment.
114 ## 0x30 == offset of .plt section in the segment.
118 Value: [[DTPLTREL=17]] ## 17 == DT_REL
120 Value: [[PLTRELSZ=0x10]]
132 ## Check we report a warning when the value of the DT_PLTREL dynamic tag is invalid.
133 ## We currently accept DT_RELA(7) and DT_REL(17) values. This test case uses 0xff.
135 # RUN: yaml2obj --docnum=2 %s -DDTPLTREL=0xFF -o %t3
136 # RUN: llvm-readobj --dyn-relocations %t3 2>&1 | \
137 # RUN: FileCheck %s -DFILE=%t3 --implicit-check-not=warning: --check-prefix=PLTRELUNKNOWN-LLVM
138 # RUN: llvm-readelf --dyn-relocations %t3 2>&1 | \
139 # RUN: FileCheck %s -DFILE=%t3 --implicit-check-not=warning: --check-prefix=PLTRELUNKNOWN-GNU
141 # PLTRELUNKNOWN-LLVM: warning: '[[FILE]]': unknown DT_PLTREL value of 255
142 # PLTRELUNKNOWN-LLVM: Dynamic Relocations {
143 # PLTRELUNKNOWN-LLVM-NEXT: 0x1 R_X86_64_NONE foo 0x0
144 # PLTRELUNKNOWN-LLVM-NEXT: 0x2 R_X86_64_NONE foo{{$}}
145 # PLTRELUNKNOWN-LLVM-NEXT: 0x4 R_X86_64_RELATIVE -{{$}}
146 # PLTRELUNKNOWN-LLVM-NEXT: warning: '[[FILE]]': invalid DT_PLTRELSZ value (0x10) or PLTREL entry size (0x0)
147 # PLTRELUNKNOWN-LLVM-NEXT: }
149 # PLTRELUNKNOWN-GNU: warning: '[[FILE]]': unknown DT_PLTREL value of 255
150 # PLTRELUNKNOWN-GNU-EMPTY:
151 # PLTRELUNKNOWN-GNU-NEXT: 'RELA' relocation section at offset 0x78 contains 24 bytes:
152 # PLTRELUNKNOWN-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
153 # PLTRELUNKNOWN-GNU-NEXT: 0000000000000001 0000000100000000 R_X86_64_NONE 0000000000000000 foo + 0
154 # PLTRELUNKNOWN-GNU-EMPTY:
155 # PLTRELUNKNOWN-GNU-NEXT: 'REL' relocation section at offset 0x90 contains 16 bytes:
156 # PLTRELUNKNOWN-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name
157 # PLTRELUNKNOWN-GNU-NEXT: 0000000000000002 0000000100000000 R_X86_64_NONE 0000000000000000 foo
158 # PLTRELUNKNOWN-GNU-EMPTY:
159 # PLTRELUNKNOWN-GNU-NEXT: 'RELR' relocation section at offset 0xa0 contains 8 bytes:
160 # PLTRELUNKNOWN-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name
161 # PLTRELUNKNOWN-GNU-NEXT: 0000000000000004 0000000000000008 R_X86_64_RELATIVE
162 # PLTRELUNKNOWN-GNU-EMPTY:
163 # PLTRELUNKNOWN-GNU-NEXT: 'PLT' relocation section at offset 0xa8 contains 16 bytes:
164 # PLTRELUNKNOWN-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name
165 # PLTRELUNKNOWN-GNU-NEXT: warning: '[[FILE]]': invalid DT_PLTRELSZ value (0x10) or PLTREL entry size (0x0)