diff options
| author | Martin Storsjo <martin@martin.st> | 2019-01-11 13:47:37 +0000 |
|---|---|---|
| committer | Martin Storsjo <martin@martin.st> | 2019-01-11 13:47:37 +0000 |
| commit | d1cc64fe12dc37147723e0615fd4b140197210b0 (patch) | |
| tree | 248233f1b913127af3fa24cac4dc07e858da7e9d /llvm/tools/llvm-objcopy | |
| parent | 37c1e2e7a9d00b90eb48c754b2b138b1670313bc (diff) | |
| download | bcm5719-llvm-d1cc64fe12dc37147723e0615fd4b140197210b0.tar.gz bcm5719-llvm-d1cc64fe12dc37147723e0615fd4b140197210b0.zip | |
[llvm-objcopy] [COFF] Fix writing object files without symbols/string table
Previously, this was broken - by setting PointerToSymbolTable to zero
but still actually writing the string table length, the object file
header was corrupted.
Differential Revision: https://reviews.llvm.org/D56584
llvm-svn: 350926
Diffstat (limited to 'llvm/tools/llvm-objcopy')
| -rw-r--r-- | llvm/tools/llvm-objcopy/COFF/Writer.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/tools/llvm-objcopy/COFF/Writer.cpp b/llvm/tools/llvm-objcopy/COFF/Writer.cpp index d7a5224b5ef..213cb11b788 100644 --- a/llvm/tools/llvm-objcopy/COFF/Writer.cpp +++ b/llvm/tools/llvm-objcopy/COFF/Writer.cpp @@ -154,12 +154,11 @@ Error COFFWriter::finalize(bool IsBigObj) { size_t PointerToSymbolTable = FileSize; // StrTabSize <= 4 is the size of an empty string table, only consisting // of the length field. - if (SymTabSize == 0 && StrTabSize <= 4) { - // Don't point to the symbol table if empty. + if (SymTabSize == 0 && StrTabSize <= 4 && Obj.IsPE) { + // For executables, don't point to the symbol table and skip writing + // the length field, if both the symbol and string tables are empty. PointerToSymbolTable = 0; - // For executables, skip the length field of an empty string table. - if (Obj.IsPE) - StrTabSize = 0; + StrTabSize = 0; } size_t NumRawSymbols = SymTabSize / SymbolSize; |

