llvm/tools/llvm-objcopy/ELF
Fangrui Song 327f5f9ccd [llvm-objcopy] --add-symbol: fix crash if SHT_SYMTAB does not exist
Exposed by D69041. If SHT_SYMTAB does not exist, ELFObjcopy.cpp:handleArgs will crash due
to a null pointer dereference.

  for (const NewSymbolInfo &SI : Config.ELF->SymbolsToAdd) {
    ...
    Obj.SymbolTable->addSymbol(

Fix this by creating .symtab and .strtab on demand in ELFBuilder<ELFT>::readSections,
if --add-symbol is specified.

Reviewed By: grimar

Differential Revision: https://reviews.llvm.org/D69093

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375105 91177308-0d34-0410-b5e6-96231b3b80d8
2019-10-17 11:21:54 +00:00
..
ELFConfig.cpp [llvm-objcopy] Refactor ELF-specific config out to ELFCopyConfig. NFC. 2019-09-24 09:38:23 +00:00
ELFConfig.h [llvm-objcopy] Refactor ELF-specific config out to ELFCopyConfig. NFC. 2019-09-24 09:38:23 +00:00
ELFObjcopy.cpp [llvm-objcopy] --add-symbol: fix crash if SHT_SYMTAB does not exist 2019-10-17 11:21:54 +00:00
ELFObjcopy.h [llvm-objcopy] Implement IHEX reader 2019-06-13 09:56:14 +00:00
Object.cpp [llvm-objcopy] --add-symbol: fix crash if SHT_SYMTAB does not exist 2019-10-17 11:21:54 +00:00
Object.h [llvm-objcopy] --add-symbol: fix crash if SHT_SYMTAB does not exist 2019-10-17 11:21:54 +00:00