[llvm] 737e27f - [llvm-readobj][XCOFF] dump the string table only if the size is bigger than 4.
via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 3 23:29:28 PDT 2021
Author: Esme-Yi
Date: 2021-08-04T06:28:26Z
New Revision: 737e27f6236f18dcac53130242756ba0cc1dfe7d
URL: https://github.com/llvm/llvm-project/commit/737e27f6236f18dcac53130242756ba0cc1dfe7d
DIFF: https://github.com/llvm/llvm-project/commit/737e27f6236f18dcac53130242756ba0cc1dfe7d.diff
LOG: [llvm-readobj][XCOFF] dump the string table only if the size is bigger than 4.
Added:
Modified:
llvm/test/tools/llvm-readobj/XCOFF/string-table.yaml
llvm/tools/llvm-readobj/XCOFFDumper.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-readobj/XCOFF/string-table.yaml b/llvm/test/tools/llvm-readobj/XCOFF/string-table.yaml
index 7b537c1fe4c97..c5d15f2521599 100644
--- a/llvm/test/tools/llvm-readobj/XCOFF/string-table.yaml
+++ b/llvm/test/tools/llvm-readobj/XCOFF/string-table.yaml
@@ -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
diff --git a/llvm/tools/llvm-readobj/XCOFFDumper.cpp b/llvm/tools/llvm-readobj/XCOFFDumper.cpp
index b91ba5eb1e07e..a269442104af7 100644
--- a/llvm/tools/llvm-readobj/XCOFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/XCOFFDumper.cpp
@@ -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() {
More information about the llvm-commits
mailing list