[all-commits] [llvm/llvm-project] 9dce25: [llvm-objcopy] --add-symbol: fix crash if SHT_SYMT...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Oct 17 04:21:36 PDT 2019

  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 9dce25a9fa953cec1b89009226cdc463166a7ad4
  Author: Fangrui Song <maskray at google.com>
  Date:   2019-10-17 (Thu, 17 Oct 2019)

  Changed paths:
    A llvm/test/tools/llvm-objcopy/ELF/add-symbol-no-symtab.test
    M llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
    M llvm/tools/llvm-objcopy/ELF/Object.cpp
    M llvm/tools/llvm-objcopy/ELF/Object.h

  Log Message:
  [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) {

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

llvm-svn: 375105

More information about the All-commits mailing list