forked from OSchip/llvm-project
[llvm-readobj][XCOFF] Warn about invalid offset
Followup for D105522 Differential Revision: https://reviews.llvm.org/D107398
This commit is contained in:
parent
b16c37fa2c
commit
3df1e7e6f0
|
@ -32,9 +32,10 @@ Symbols:
|
|||
|
||||
## There is no string table.
|
||||
# RUN: yaml2obj --docnum=3 %s -o %t3
|
||||
# RUN: llvm-readobj --string-table %t3 | FileCheck %s --check-prefix=NO-STRTBL
|
||||
# RUN: llvm-readobj --string-table %t3 2>&1 | FileCheck %s --check-prefix=NO-STRTBL
|
||||
|
||||
# NO-STRTBL: StringTable {
|
||||
# NO-STRTBL-NEXT: error: offset is out of string contents
|
||||
# NO-STRTBL-NEXT: }
|
||||
|
||||
--- !XCOFF
|
||||
|
|
|
@ -54,8 +54,10 @@ static void printAsPrintable(raw_ostream &W, const uint8_t *Start, size_t Len) {
|
|||
|
||||
void ObjDumper::printAsStringList(StringRef StringContent,
|
||||
size_t StringDataOffset) {
|
||||
if (StringContent.size() < StringDataOffset)
|
||||
if (StringContent.size() < StringDataOffset) {
|
||||
reportUniqueWarning("error: offset is out of string contents");
|
||||
return;
|
||||
}
|
||||
const uint8_t *StrContent = StringContent.bytes_begin();
|
||||
// Some formats contain additional metadata at the start which should not be
|
||||
// interpreted as strings. Skip these bytes, but account for them in the
|
||||
|
|
Loading…
Reference in New Issue