[PATCH] D105522: [llvm-readobj][XCOFF] Fix the error dumping for the first item of StringTable.
Esme Yi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 7 21:40:17 PDT 2021
Esme updated this revision to Diff 357130.
Esme added a comment.
Address comments.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105522/new/
https://reviews.llvm.org/D105522
Files:
llvm/test/tools/yaml2obj/XCOFF/long-symbol-name.yaml
llvm/tools/llvm-readobj/ObjDumper.cpp
llvm/tools/llvm-readobj/ObjDumper.h
llvm/tools/llvm-readobj/XCOFFDumper.cpp
Index: llvm/tools/llvm-readobj/XCOFFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/XCOFFDumper.cpp
+++ llvm/tools/llvm-readobj/XCOFFDumper.cpp
@@ -460,7 +460,10 @@
void XCOFFDumper::printStringTable() {
DictScope DS(W, "StringTable");
StringRef StrTable = Obj.getStringTable();
- printAsStringList(StrTable);
+ W.printNumber("Length (in bytes)", StrTable.size());
+ // Print strings from byte4, since the 0-3 bytes contain the length (in bytes)
+ // of the string table.
+ printAsStringList(StrTable, 4);
}
void XCOFFDumper::printDynamicSymbols() {
Index: llvm/tools/llvm-readobj/ObjDumper.h
===================================================================
--- llvm/tools/llvm-readobj/ObjDumper.h
+++ llvm/tools/llvm-readobj/ObjDumper.h
@@ -110,7 +110,7 @@
virtual void printStackMap() const = 0;
- void printAsStringList(StringRef StringContent);
+ void printAsStringList(StringRef StringContent, uint8_t BeginByte = 0);
void printSectionsAsString(const object::ObjectFile &Obj,
ArrayRef<std::string> Sections);
Index: llvm/tools/llvm-readobj/ObjDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/ObjDumper.cpp
+++ llvm/tools/llvm-readobj/ObjDumper.cpp
@@ -53,9 +53,11 @@
W << (isPrint(Start[i]) ? static_cast<char>(Start[i]) : '.');
}
-void ObjDumper::printAsStringList(StringRef StringContent) {
+void ObjDumper::printAsStringList(StringRef StringContent, uint8_t BeginByte) {
const uint8_t *StrContent = StringContent.bytes_begin();
- const uint8_t *CurrentWord = StrContent;
+ // Set the start at StrContent + BeginByte for the cases where the first few
+ // bytes do not contain a string entry.
+ const uint8_t *CurrentWord = StrContent + BeginByte;
const uint8_t *StrEnd = StringContent.bytes_end();
while (CurrentWord <= StrEnd) {
Index: llvm/test/tools/yaml2obj/XCOFF/long-symbol-name.yaml
===================================================================
--- llvm/test/tools/yaml2obj/XCOFF/long-symbol-name.yaml
+++ llvm/test/tools/yaml2obj/XCOFF/long-symbol-name.yaml
@@ -2,8 +2,6 @@
# RUN: yaml2obj %s -o %t
# RUN: llvm-readobj --symbols --string-table %t | FileCheck %s
-## FIXME: The first item of StringTable should be `[ 4] .longname`.
-
# CHECK: AddressSize: 32bit
# CHECK-NEXT: Symbols [
# CHECK-NEXT: Symbol {
@@ -26,7 +24,8 @@
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK-NEXT: StringTable {
-# CHECK-NEXT: [ 3] ..longname
+# CHECK-NEXT: Length (in bytes): 14
+# CHECK-NEXT: [ 4] .longname
# CHECK-NEXT: }
--- !XCOFF
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105522.357130.patch
Type: text/x-patch
Size: 2683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210708/47bf4742/attachment.bin>
More information about the llvm-commits
mailing list