@@ -128,3 +128,38 @@ ProgramHeaders:
128128 - Type: PT_LOAD
129129 FirstSec: .rela.dyn
130130 LastSec: .dynamic
131+
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.
134+
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
140+
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 0x0
145+ # PLTRELUNKNOWN-LLVM-NEXT: 0x4 R_X86_64_RELATIVE - 0x0
146+ # PLTRELUNKNOWN-LLVM-NEXT: warning: '[[FILE]]': invalid DT_PLTRELSZ value (0x10) or PLTREL entry size (0x0)
147+ # PLTRELUNKNOWN-LLVM-NEXT: }
148+
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)
0 commit comments