[PATCH] D105522: [llvm-readobj][XCOFF] Fix the error dumping for the first item of StringTable.
EsmeYi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 6 19:38:34 PDT 2021
Esme created this revision.
Esme added reviewers: jhenderson, shchenz, PowerPC.
Herald added a subscriber: rupprecht.
Esme requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.
In D104613 <https://reviews.llvm.org/D104613>, we left a FIXME about the error dumping for the first item of StringTable.
This is not caused by parsing, but by the fact that I didn't realize that byte3 stores the size of the StringTable.
The patch fixes the bug.
Repository:
rG LLVM Github Monorepo
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,9 @@
void XCOFFDumper::printStringTable() {
DictScope DS(W, "StringTable");
StringRef StrTable = Obj.getStringTable();
- printAsStringList(StrTable);
+ // No need to dump bytes 0-3, since bytes 0-2 are '\0' and byte 3 stores the
+ // size of StringTable.
+ 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,9 @@
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;
+ 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,7 @@
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK-NEXT: StringTable {
-# CHECK-NEXT: [ 3] ..longname
+# CHECK-NEXT: [ 4] .longname
# CHECK-NEXT: }
--- !XCOFF
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105522.356850.patch
Type: text/x-patch
Size: 2461 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210707/461c5b0f/attachment.bin>
More information about the llvm-commits
mailing list