summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/COFFObjectFile.cpp
diff options
context:
space:
mode:
authorNico Rieck <nico.rieck@gmail.com>2014-02-26 19:51:44 +0000
committerNico Rieck <nico.rieck@gmail.com>2014-02-26 19:51:44 +0000
commit773a57958ca2aecc631f9e0ffebe4e6ec194bb5b (patch)
tree673d4602fe29b720437529978775c4375504a31f /llvm/lib/Object/COFFObjectFile.cpp
parent5645b363062392d0a84f508026d27c8bea76d994 (diff)
downloadbcm5719-llvm-773a57958ca2aecc631f9e0ffebe4e6ec194bb5b.tar.gz
bcm5719-llvm-773a57958ca2aecc631f9e0ffebe4e6ec194bb5b.zip
Relax COFF string table check
COFF object files with 0 as string table size are currently rejected. This prevents us from reading object files written by tools like cvtres that violate the PECOFF spec and write 0 instead of 4 for the size of an empty string table. llvm-svn: 202292
Diffstat (limited to 'llvm/lib/Object/COFFObjectFile.cpp')
-rw-r--r--llvm/lib/Object/COFFObjectFile.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp
index 41d21eed139..0c79506f419 100644
--- a/llvm/lib/Object/COFFObjectFile.cpp
+++ b/llvm/lib/Object/COFFObjectFile.cpp
@@ -409,9 +409,13 @@ error_code COFFObjectFile::initSymbolTablePtr() {
getObject(StringTable, Data, StringTableAddr, StringTableSize))
return EC;
+ // Treat table sizes < 4 as empty because contrary to the PECOFF spec, some
+ // tools like cvtres write a size of 0 for an empty table instead of 4.
+ if (StringTableSize < 4)
+ StringTableSize = 4;
+
// Check that the string table is null terminated if has any in it.
- if (StringTableSize < 4 ||
- (StringTableSize > 4 && StringTable[StringTableSize - 1] != 0))
+ if (StringTableSize > 4 && StringTable[StringTableSize - 1] != 0)
return object_error::parse_failed;
return object_error::success;
}
OpenPOWER on IntegriCloud