[llvm-readobj][XCOFF] dump the string table only if the size is bigger than 4.

This commit is contained in:
Esme-Yi 2021-08-04 06:28:26 +00:00
parent 432341d8a8
commit 737e27f623
2 changed files with 3 additions and 3 deletions

View File

@ -32,10 +32,9 @@ Symbols:
## There is no string table.
# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: llvm-readobj --string-table %t3 2>&1 | FileCheck %s --check-prefix=NO-STRTBL
# RUN: llvm-readobj --string-table %t3 | FileCheck %s --check-prefix=NO-STRTBL
# NO-STRTBL: StringTable {
# NO-STRTBL-NEXT: error: offset is out of string contents
# NO-STRTBL-NEXT: }
--- !XCOFF

View File

@ -462,7 +462,8 @@ void XCOFFDumper::printStringTable() {
StringRef StrTable = Obj.getStringTable();
// Print strings from the fifth byte, since the first four bytes contain the
// length (in bytes) of the string table (including the length field).
printAsStringList(StrTable, 4);
if (StrTable.size() > 4)
printAsStringList(StrTable, 4);
}
void XCOFFDumper::printDynamicSymbols() {