[llvm] f49c3a6 - [llvm-readobj][XCOFF] Print the length of the string table.
via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 8 23:51:26 PDT 2021
Author: Esme-Yi
Date: 2021-08-09T06:47:15Z
New Revision: f49c3a688244ea0aadfe5c0bf27daec6ad0a9cfb
URL: https://github.com/llvm/llvm-project/commit/f49c3a688244ea0aadfe5c0bf27daec6ad0a9cfb
DIFF: https://github.com/llvm/llvm-project/commit/f49c3a688244ea0aadfe5c0bf27daec6ad0a9cfb.diff
LOG: [llvm-readobj][XCOFF] Print the length of the string table.
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D107333
Added:
Modified:
llvm/test/tools/llvm-readobj/XCOFF/string-table.yaml
llvm/test/tools/yaml2obj/XCOFF/basic-doc64.yaml
llvm/test/tools/yaml2obj/XCOFF/long-symbol-name.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 c5d15f2521599..7616fc10d8906 100644
--- a/llvm/test/tools/llvm-readobj/XCOFF/string-table.yaml
+++ b/llvm/test/tools/llvm-readobj/XCOFF/string-table.yaml
@@ -5,6 +5,7 @@
# RUN: llvm-readobj --string-table %t1 | FileCheck %s --check-prefix=BASIC
# BASIC: StringTable {
+# BASIC-NEXT: Length: 16
# BASIC-NEXT: [ 4] name2
# BASIC-NEXT: [ a] name1
# BASIC-NEXT: }
@@ -21,6 +22,7 @@ Symbols:
# RUN: llvm-readobj --string-table %t2 | FileCheck %s --check-prefix=SINGLE-BYTE
# SINGLE-BYTE: StringTable {
+# SINGLE-BYTE-NEXT: Length: 6
# SINGLE-BYTE-NEXT: [ 4] n
# SINGLE-BYTE-NEXT: }
@@ -35,6 +37,7 @@ Symbols:
# RUN: llvm-readobj --string-table %t3 | FileCheck %s --check-prefix=NO-STRTBL
# NO-STRTBL: StringTable {
+# NO-STRTBL-NEXT: Length: 0
# NO-STRTBL-NEXT: }
--- !XCOFF
diff --git a/llvm/test/tools/yaml2obj/XCOFF/basic-doc64.yaml b/llvm/test/tools/yaml2obj/XCOFF/basic-doc64.yaml
index 65245110f0dc4..8c14ef9a17ba9 100644
--- a/llvm/test/tools/yaml2obj/XCOFF/basic-doc64.yaml
+++ b/llvm/test/tools/yaml2obj/XCOFF/basic-doc64.yaml
@@ -135,6 +135,7 @@ Symbols:
# CHECK64-NEXT: }
# CHECK64-NEXT: ]
# CHECK64-NEXT: StringTable {
+# CHECK64-NEXT: Length: 28
# CHECK64-NEXT: [ 4] .text
# CHECK64-NEXT: [ a] .abs
# CHECK64-NEXT: [ f] .undef
diff --git a/llvm/test/tools/yaml2obj/XCOFF/long-symbol-name.yaml b/llvm/test/tools/yaml2obj/XCOFF/long-symbol-name.yaml
index 5a90f2e7ca280..521d132980bb6 100644
--- a/llvm/test/tools/yaml2obj/XCOFF/long-symbol-name.yaml
+++ b/llvm/test/tools/yaml2obj/XCOFF/long-symbol-name.yaml
@@ -24,6 +24,7 @@
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK-NEXT: StringTable {
+# CHECK-NEXT: Length: 14
# CHECK-NEXT: [ 4] .longname
# CHECK-NEXT: }
diff --git a/llvm/tools/llvm-readobj/XCOFFDumper.cpp b/llvm/tools/llvm-readobj/XCOFFDumper.cpp
index a269442104af7..3e47ceb9ee738 100644
--- a/llvm/tools/llvm-readobj/XCOFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/XCOFFDumper.cpp
@@ -460,9 +460,11 @@ void XCOFFDumper::printSymbols() {
void XCOFFDumper::printStringTable() {
DictScope DS(W, "StringTable");
StringRef StrTable = Obj.getStringTable();
+ size_t StrTabSize = StrTable.size();
+ W.printNumber("Length", StrTabSize);
// Print strings from the fifth byte, since the first four bytes contain the
// length (in bytes) of the string table (including the length field).
- if (StrTable.size() > 4)
+ if (StrTabSize > 4)
printAsStringList(StrTable, 4);
}
More information about the llvm-commits
mailing list