From 064db243113ccac50ab3f8695f8f83a9e71efd3f Mon Sep 17 00:00:00 2001 From: Pengxuan Zheng Date: Wed, 8 Jun 2022 18:02:49 -0700 Subject: [Object][COFF] Fix section name parsing error when the name field is not null-padded Some object files produced by Mirosoft tools contain sections whose name field is not fully null-padded at the end. Microsoft's dumpbin is able to print the section name correctly, but this causes parsing errors with LLVM tools. So far, this issue only seems to happen when the section name is longer than 8 bytes. In this case, the section name field contains a slash (/) followed by the offset into the string table, but the name field is not fully null-padded at the end. Reviewed By: mstorsjo Differential Revision: https://reviews.llvm.org/D127369 --- llvm/lib/Object/COFFObjectFile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/Object/COFFObjectFile.cpp') diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index fe8fab23..e5013d77 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -1168,7 +1168,7 @@ COFFObjectFile::getSectionName(const coff_section *Sec) const { return createStringError(object_error::parse_failed, "invalid section name"); } else { - if (Name.substr(1).getAsInteger(10, Offset)) + if (Name.substr(1).consumeInteger(10, Offset)) return createStringError(object_error::parse_failed, "invalid section name"); } -- cgit v1.1