diff options
author | Esme-Yi <esme.yi@ibm.com> | 2021-08-03 09:08:58 +0000 |
---|---|---|
committer | Esme-Yi <esme.yi@ibm.com> | 2021-08-03 09:08:58 +0000 |
commit | 69396896fb615067b04a3e0c220f93bc91a10eec (patch) | |
tree | 41557240ddf7cfaf3ef5e5bea8a3233130fbad26 /llvm/lib/Object/XCOFFObjectFile.cpp | |
parent | 18c6ed2f0f293582570ad3f6419e10ff808ba98e (diff) | |
download | llvm-69396896fb615067b04a3e0c220f93bc91a10eec.zip llvm-69396896fb615067b04a3e0c220f93bc91a10eec.tar.gz llvm-69396896fb615067b04a3e0c220f93bc91a10eec.tar.bz2 |
[llvm-readobj][XCOFF] Fix the error dumping for the first
item of StringTable.
Summary: For the string table in XCOFF, the first 4 bytes
contains the length of the string table, so we should
print the string entries from fifth bytes. This patch
also adds tests for llvm-readobj dumping the string
table.
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D105522
Diffstat (limited to 'llvm/lib/Object/XCOFFObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/XCOFFObjectFile.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Object/XCOFFObjectFile.cpp b/llvm/lib/Object/XCOFFObjectFile.cpp index 53447d0..28355b6 100644 --- a/llvm/lib/Object/XCOFFObjectFile.cpp +++ b/llvm/lib/Object/XCOFFObjectFile.cpp @@ -188,7 +188,10 @@ XCOFFObjectFile::getStringTableEntry(uint32_t Offset) const { } StringRef XCOFFObjectFile::getStringTable() const { - return StringRef(StringTable.Data, StringTable.Size); + // If the size is less than or equal to 4, then the string table contains no + // string data. + return StringRef(StringTable.Data, + StringTable.Size <= 4 ? 0 : StringTable.Size); } Expected<StringRef> |