mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202292 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5732fbd6e4
commit
0a91f48308
@ -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;
|
||||
}
|
||||
|
BIN
test/tools/llvm-readobj/Inputs/zero-string-table.obj.coff-i386
Normal file
BIN
test/tools/llvm-readobj/Inputs/zero-string-table.obj.coff-i386
Normal file
Binary file not shown.
8
test/tools/llvm-readobj/coff-zero-string-table.test
Normal file
8
test/tools/llvm-readobj/coff-zero-string-table.test
Normal file
@ -0,0 +1,8 @@
|
||||
Ensure that we can read COFF objects with a string table size of 0 (instead
|
||||
of 4) for empty string tables.
|
||||
|
||||
RUN: llvm-readobj -t %p/Inputs/zero-string-table.obj.coff-i386 | FileCheck %s
|
||||
|
||||
CHECK: Symbols [
|
||||
CHECK: Symbol {
|
||||
CHECK: Name: $R000000
|
Loading…
x
Reference in New Issue
Block a user