Skip to content

Commit 29fd44f

Browse files
committed
include the section size into the warning about address overrun
1 parent 1d75f4c commit 29fd44f

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

llvm/test/tools/llvm-readobj/COFF/pseudoreloc.test

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ DEFINE: %{sym1_x64} = 0x20E8
66
DEFINE: %{sym3_x64} = 0x20D8
77
DEFINE: %{relocbegin} = 8
88
DEFINE: %{relocend} = 80
9+
DEFINE: %{rdatasize} = 254
910

1011
RUN: yaml2obj -o %t.exe-x86_64 %p/Inputs/pseudoreloc.x86_64.yaml
1112
RUN: llvm-readobj %t.exe-x86_64 --coff-pseudoreloc 2>&1 | \
@@ -81,7 +82,7 @@ INVALIDSYMBOL-NEXT: Target: 0x[[#%X,LOCAL1A+8]]
8182

8283
; Assume the position of the section and the relocation list for further tests.
8384
RUN: FileCheck --input-file=%p/Inputs/pseudoreloc.i386.yaml %s --check-prefix=RELOCPOS --match-full-lines \
84-
RUN: -DTHEBEGIN=%{relocbegin} -DTHEEND=%{relocend}
85+
RUN: -D#RDATASIZE=%{rdatasize} -DTHEBEGIN=%{relocbegin} -DTHEEND=%{relocend}
8586

8687
RELOCPOS: sections:
8788
RELOCPOS-NOT: - Name:
@@ -90,6 +91,7 @@ RELOCPOS-NOT: - Name:
9091
RELOCPOS: - Name: .rdata
9192
RELOCPOS-NEXT: Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ]
9293
RELOCPOS-NEXT: VirtualAddress: 8192
94+
RELOCPOS-NEXT: VirtualSize: [[#%d,RDATASIZE]]
9395
RELOCPOS: - Name: .data
9496
RELOCPOS-NEXT: Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
9597
RELOCPOS-NEXT: VirtualAddress: 12288
@@ -143,11 +145,11 @@ RUN: FileCheck %s --check-prefixes=EMPTY,WARN-LOWEREND -D#BEGIN=%{relocend} -D
143145
; Test that llvm-readobj warns if the marker symbol points out of the section space.
144146
RUN: yaml2obj -o %t.outofrange-both.exe-i386 %p/Inputs/pseudoreloc.i386.yaml -DBEGIN=8888 -DEND=9999
145147
RUN: llvm-readobj %t.outofrange-both.exe-i386 --coff-pseudoreloc 2>&1 | \
146-
RUN: FileCheck %s --check-prefixes=EMPTY,WARN-OUTOFRANGE --match-full-lines
148+
RUN: FileCheck %s --check-prefixes=EMPTY,WARN-OUTOFRANGE --match-full-lines -D#RDATASIZE=%{rdatasize}
147149

148150
RUN: yaml2obj -o %t.outofrange-end.exe-i386 %p/Inputs/pseudoreloc.i386.yaml -DEND=8888
149151
RUN: llvm-readobj %t.outofrange-end.exe-i386 --coff-pseudoreloc 2>&1 | \
150-
RUN: FileCheck %s --check-prefixes=EMPTY,WARN-OUTOFRANGE --match-full-lines
152+
RUN: FileCheck %s --check-prefixes=EMPTY,WARN-OUTOFRANGE --match-full-lines -D#RDATASIZE=%{rdatasize}
151153

152154
; Test that llvm-readobj warns if the marker symbols point different sections.
153155
RUN: yaml2obj -o %t.section-differs.exe-i386 %p/Inputs/pseudoreloc.i386.yaml -DSECTION_OF_BEGIN=1
@@ -161,7 +163,7 @@ EMPTY-NEXT: PseudoReloc [
161163
WARN-MISSINGMARKER-NEXT: {{.*}}warning: {{.*}}: the marker symbols for runtime pseudo-relocation were not found
162164
WARN-INVALIDHEADER-NEXT: {{.*}}warning: {{.*}}: invalid runtime pseudo-relocation records
163165
WARN-LOWEREND-NEXT: {{.*}}warning: {{.*}}: the end marker symbol for runtime pseudo-relocation must point to a higher address than where the begin marker points to: expected >=0x[[#%x,BEGIN]], but got 0x[[#%x,END]]
164-
WARN-OUTOFRANGE-NEXT: {{.*}}warning: {{.*}}: the marker symbol of runtime pseudo-relocation points past the end of the section: 0x[[#%x,8888]]
166+
WARN-OUTOFRANGE-NEXT: {{.*}}warning: {{.*}}: the marker symbol of runtime pseudo-relocation points past the end of the section 0x[[#%x,RDATASIZE]]: got 0x[[#%x,8888]]
165167
WARN-SECTIONDIFFERS-NEXT: {{.*}}warning: {{.*}}: the end marker symbol for runtime pseudo-relocation must point to the same section where the begin marker points to: expected 1, but got {{[2-9]}}
166168
EMPTY-NEXT: ]
167169

llvm/tools/llvm-readobj/COFFDumper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,8 +2115,8 @@ void COFFDumper::printCOFFPseudoReloc() {
21152115
Begin >= Data.size() || End > Data.size()) {
21162116
reportUniqueWarning(
21172117
createStringError("the marker symbol of runtime pseudo-relocation "
2118-
"points past the end of the section: 0x%x",
2119-
Begin >= Data.size() ? Begin : End));
2118+
"points past the end of the section 0x%x: got 0x%x",
2119+
Data.size(), Begin >= Data.size() ? Begin : End));
21202120
return;
21212121
}
21222122

0 commit comments

Comments
 (0)