diff --git a/llvm/test/tools/yaml2obj/XCOFF/long-symbol-name.yaml b/llvm/test/tools/yaml2obj/XCOFF/long-symbol-name.yaml --- a/llvm/test/tools/yaml2obj/XCOFF/long-symbol-name.yaml +++ b/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 diff --git a/llvm/tools/llvm-readobj/ObjDumper.h b/llvm/tools/llvm-readobj/ObjDumper.h --- a/llvm/tools/llvm-readobj/ObjDumper.h +++ b/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 Sections); diff --git a/llvm/tools/llvm-readobj/ObjDumper.cpp b/llvm/tools/llvm-readobj/ObjDumper.cpp --- a/llvm/tools/llvm-readobj/ObjDumper.cpp +++ b/llvm/tools/llvm-readobj/ObjDumper.cpp @@ -53,9 +53,9 @@ W << (isPrint(Start[i]) ? static_cast(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) { diff --git a/llvm/tools/llvm-readobj/XCOFFDumper.cpp b/llvm/tools/llvm-readobj/XCOFFDumper.cpp --- a/llvm/tools/llvm-readobj/XCOFFDumper.cpp +++ b/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() {