Skip to content

Commit 3df1e7e

Browse files
committed
[llvm-readobj][XCOFF] Warn about invalid offset
Followup for D105522 Differential Revision: https://reviews.llvm.org/D107398
1 parent b16c37f commit 3df1e7e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

llvm/test/tools/llvm-readobj/XCOFF/string-table.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ Symbols:
3232

3333
## There is no string table.
3434
# RUN: yaml2obj --docnum=3 %s -o %t3
35-
# RUN: llvm-readobj --string-table %t3 | FileCheck %s --check-prefix=NO-STRTBL
35+
# RUN: llvm-readobj --string-table %t3 2>&1 | FileCheck %s --check-prefix=NO-STRTBL
3636

3737
# NO-STRTBL: StringTable {
38+
# NO-STRTBL-NEXT: error: offset is out of string contents
3839
# NO-STRTBL-NEXT: }
3940

4041
--- !XCOFF

llvm/tools/llvm-readobj/ObjDumper.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ static void printAsPrintable(raw_ostream &W, const uint8_t *Start, size_t Len) {
5454

5555
void ObjDumper::printAsStringList(StringRef StringContent,
5656
size_t StringDataOffset) {
57-
if (StringContent.size() < StringDataOffset)
57+
if (StringContent.size() < StringDataOffset) {
58+
reportUniqueWarning("error: offset is out of string contents");
5859
return;
60+
}
5961
const uint8_t *StrContent = StringContent.bytes_begin();
6062
// Some formats contain additional metadata at the start which should not be
6163
// interpreted as strings. Skip these bytes, but account for them in the

0 commit comments

Comments
 (0)