[PATCH] D127902: [Object][COFF] Improve section name parsing
Pengxuan Zheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 16 17:01:26 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2e0c46044a5d: [Object][COFF] Improve section name parsing (authored by pzheng).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127902/new/
https://reviews.llvm.org/D127902
Files:
llvm/lib/Object/COFFObjectFile.cpp
Index: llvm/lib/Object/COFFObjectFile.cpp
===================================================================
--- llvm/lib/Object/COFFObjectFile.cpp
+++ llvm/lib/Object/COFFObjectFile.cpp
@@ -1146,13 +1146,7 @@
Expected<StringRef>
COFFObjectFile::getSectionName(const coff_section *Sec) const {
- StringRef Name;
- if (Sec->Name[COFF::NameSize - 1] == 0)
- // Null terminated, let ::strlen figure out the length.
- Name = Sec->Name;
- else
- // Not null terminated, use all 8 bytes.
- Name = StringRef(Sec->Name, COFF::NameSize);
+ StringRef Name = StringRef(Sec->Name, COFF::NameSize).split('\0').first;
// Check for string table entry. First byte is '/'.
if (Name.startswith("/")) {
@@ -1162,7 +1156,7 @@
return createStringError(object_error::parse_failed,
"invalid section name");
} else {
- if (Name.substr(1).consumeInteger(10, Offset))
+ if (Name.substr(1).getAsInteger(10, Offset))
return createStringError(object_error::parse_failed,
"invalid section name");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127902.437751.patch
Type: text/x-patch
Size: 1104 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220617/d885ccf5/attachment.bin>
More information about the llvm-commits
mailing list