LLVM 17.0.0git
|
#include "llvm/ObjCopy/ELF/ELFObjcopy.h"
#include "ELFObject.h"
#include "llvm/ADT/BitmaskEnum.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/ObjCopy/CommonConfig.h"
#include "llvm/ObjCopy/ELF/ELFConfig.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/ELFTypes.h"
#include "llvm/Object/Error.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Memory.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstdlib>
#include <functional>
#include <iterator>
#include <memory>
#include <string>
#include <system_error>
#include <utility>
Go to the source code of this file.
Typedefs | |
using | SectionPred = std::function< bool(const SectionBase &Sec)> |
using SectionPred = std::function<bool(const SectionBase &Sec)> |
Definition at line 52 of file ELFObjcopy.cpp.
|
static |
Definition at line 530 of file ELFObjcopy.cpp.
References llvm::objcopy::elf::SectionBase::Addr, llvm::objcopy::elf::SymbolTableSection::addSymbol(), llvm::objcopy::elf::Object::findSection(), llvm::ELF::SHN_ABS, llvm::ELF::STB_GLOBAL, llvm::ELF::STB_LOCAL, llvm::ELF::STB_WEAK, llvm::ELF::STT_FILE, llvm::ELF::STT_FUNC, llvm::ELF::STT_GNU_IFUNC, llvm::ELF::STT_NOTYPE, llvm::ELF::STT_OBJECT, llvm::ELF::STT_SECTION, llvm::ELF::STV_DEFAULT, llvm::ELF::STV_HIDDEN, llvm::ELF::STV_PROTECTED, llvm::objcopy::elf::SYMBOL_SIMPLE_INDEX, and llvm::objcopy::elf::Object::SymbolTable.
Referenced by llvm::jitlink::SymbolAddressMap::addSymbols(), and handleArgs().
|
static |
Definition at line 133 of file ELFObjcopy.cpp.
References Config, llvm::objcopy::elf::ELFT_ELF32BE, llvm::objcopy::elf::ELFT_ELF32LE, llvm::objcopy::elf::ELFT_ELF64BE, llvm::objcopy::elf::ELFT_ELF64LE, and llvm_unreachable.
Referenced by createWriter().
|
static |
Definition at line 154 of file ELFObjcopy.cpp.
References Config, and createELFWriter().
Referenced by writeOutput().
Definition at line 174 of file ELFObjcopy.cpp.
References llvm::FileOutputBuffer::create(), llvm::createStringError(), E, llvm::objcopy::elf::Object::sections(), llvm::ELF::SHT_NOBITS, llvm::StringRef::str(), llvm::Error::success(), and llvm::Expected< T >::takeError().
Referenced by handleArgs().
|
static |
Definition at line 71 of file ELFObjcopy.cpp.
References llvm::ELF::SHF_ALLOC, llvm::ELF::SHF_EXCLUDE, llvm::ELF::SHF_EXECINSTR, llvm::ELF::SHF_MERGE, llvm::ELF::SHF_STRINGS, and llvm::ELF::SHF_WRITE.
Referenced by setSectionFlagsAndType().
Definition at line 112 of file ELFObjcopy.cpp.
References llvm::Bin, llvm::objcopy::elf::ELFT_ELF32BE, llvm::objcopy::elf::ELFT_ELF32LE, llvm::objcopy::elf::ELFT_ELF64BE, llvm::objcopy::elf::ELFT_ELF64LE, llvm::isa(), and llvm_unreachable.
Referenced by llvm::objcopy::elf::executeObjcopyOnBinary(), llvm::objcopy::elf::executeObjcopyOnIHex(), and llvm::objcopy::elf::executeObjcopyOnRawBinary().
|
static |
Definition at line 125 of file ELFObjcopy.cpp.
References llvm::objcopy::elf::ELFT_ELF32BE, llvm::objcopy::elf::ELFT_ELF32LE, llvm::objcopy::elf::ELFT_ELF64BE, llvm::objcopy::elf::ELFT_ELF64LE, and MI.
Definition at line 88 of file ELFObjcopy.cpp.
References llvm::ELF::SHF_COMPRESSED, llvm::ELF::SHF_EXCLUDE, llvm::ELF::SHF_GROUP, llvm::ELF::SHF_INFO_LINK, llvm::ELF::SHF_LINK_ORDER, llvm::ELF::SHF_MASKOS, llvm::ELF::SHF_MASKPROC, and llvm::ELF::SHF_TLS.
Referenced by setSectionFlagsAndType().
|
static |
Definition at line 599 of file ELFObjcopy.cpp.
References llvm::objcopy::elf::Object::addNewSymbolTable(), llvm::objcopy::elf::Object::addSection(), addSymbol(), llvm::objcopy::ELFConfig::AllowBrokenLinks, Config, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::Data, dumpSectionToFile(), E, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::end(), llvm::objcopy::elf::Object::Entry, llvm::objcopy::ELFConfig::EntryExpr, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::find(), llvm::objcopy::elf::SectionBase::Flags, handleUserSection(), I, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::objcopy::elf::Object::Machine, Name, llvm::objcopy::elf::SectionBase::Name, llvm::objcopy::SectionRename::NewFlags, llvm::objcopy::SectionFlagsUpdate::NewFlags, llvm::objcopy::SectionRename::NewName, llvm::objcopy::ELFConfig::NewSymbolVisibility, llvm::objcopy::elf::Object::OSABI, llvm::objcopy::elf::Object::removeSections(), replaceAndRemoveSections(), llvm::objcopy::elf::Object::sections(), setSectionFlagsAndType(), llvm::ELF::SHF_ALLOC, llvm::ELF::SHT_NOBITS, llvm::ELF::SHT_NOTE, SI, llvm::Error::success(), llvm::objcopy::elf::Object::SymbolTable, llvm::objcopy::elf::SectionBase::Type, updateAndRemoveSymbols(), and llvm::objcopy::elf::Object::updateSection().
Referenced by llvm::objcopy::elf::executeObjcopyOnBinary(), llvm::objcopy::elf::executeObjcopyOnIHex(), and llvm::objcopy::elf::executeObjcopyOnRawBinary().
|
static |
Definition at line 584 of file ELFObjcopy.cpp.
References llvm::Data, F, llvm::objcopy::NewSectionInfo::SectionData, and llvm::objcopy::NewSectionInfo::SectionName.
Referenced by handleArgs().
Definition at line 227 of file ELFObjcopy.cpp.
References Name, llvm::ELF::SHN_UNDEF, llvm::ELF::STB_LOCAL, llvm::ELF::STT_NOTYPE, and Sym.
Referenced by isRequiredByABISymbol().
Definition at line 237 of file ELFObjcopy.cpp.
References Name, llvm::ELF::SHN_UNDEF, llvm::ELF::STB_LOCAL, llvm::ELF::STT_NOTYPE, and Sym.
Referenced by isRequiredByABISymbol().
|
static |
Definition at line 198 of file ELFObjcopy.cpp.
References llvm::objcopy::elf::SectionBase::Flags, llvm::objcopy::elf::SectionBase::Name, llvm::ELF::SHF_COMPRESSED, and llvm::StringRef::startswith().
Referenced by replaceAndRemoveSections().
|
static |
Definition at line 54 of file ELFObjcopy.cpp.
References llvm::objcopy::elf::SectionBase::Name, and llvm::StringRef::startswith().
Referenced by replaceAndRemoveSections().
|
static |
Definition at line 58 of file ELFObjcopy.cpp.
References llvm::StringRef::endswith(), and llvm::objcopy::elf::SectionBase::Name.
Referenced by onlyKeepDWOPred(), and replaceAndRemoveSections().
Definition at line 249 of file ELFObjcopy.cpp.
References llvm::ELF::EM_AARCH64, llvm::ELF::EM_ARM, isAArch64MappingSymbol(), isArmMappingSymbol(), llvm::objcopy::elf::Object::isRelocatable(), llvm::objcopy::elf::Object::Machine, and Sym.
Referenced by updateAndRemoveSymbols().
Definition at line 262 of file ELFObjcopy.cpp.
References llvm::ELF::SHN_UNDEF, llvm::ELF::STB_LOCAL, llvm::ELF::STT_SECTION, and Sym.
Referenced by updateAndRemoveSymbols().
|
static |
Definition at line 168 of file ELFObjcopy.cpp.
References llvm::createStringError().
|
static |
Definition at line 62 of file ELFObjcopy.cpp.
References isDWOSection(), and llvm::objcopy::elf::Object::SectionNames.
Referenced by replaceAndRemoveSections().
|
static |
Definition at line 368 of file ELFObjcopy.cpp.
References llvm::objcopy::elf::Object::addSection(), llvm::objcopy::ELFConfig::AllowBrokenLinks, Config, E, llvm::objcopy::elf::SymbolTableSection::empty(), llvm::objcopy::elf::SymbolTableSection::getStrTab(), llvm::objcopy::elf::Object::Is64Bits, isCompressable(), isDebugSection(), isDWOSection(), llvm::objcopy::ELFConfig::KeepFileSymbols, onlyKeepDWOPred(), llvm::objcopy::elf::Object::removeSections(), replaceDebugSections(), llvm::objcopy::elf::Object::SectionNames, llvm::ELF::SHF_ALLOC, llvm::ELF::SHT_ARM_ATTRIBUTES, llvm::ELF::SHT_LLVM_PART_EHDR, llvm::ELF::SHT_LLVM_PART_PHDR, llvm::ELF::SHT_REL, llvm::ELF::SHT_RELA, llvm::ELF::SHT_STRTAB, llvm::ELF::SHT_SYMTAB, llvm::StringRef::startswith(), llvm::Error::success(), and llvm::objcopy::elf::Object::SymbolTable.
Referenced by handleArgs().
|
static |
Definition at line 203 of file ELFObjcopy.cpp.
References llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::objcopy::elf::Object::replaceSections(), llvm::objcopy::elf::Object::sections(), and llvm::Expected< T >::takeError().
Referenced by replaceAndRemoveSections().
|
static |
Definition at line 100 of file ELFObjcopy.cpp.
References llvm::objcopy::elf::SectionBase::Flags, Flags, getNewShfFlags(), getSectionFlagsPreserveMask(), llvm::ELF::SHF_ALLOC, llvm::ELF::SHT_NOBITS, llvm::ELF::SHT_PROGBITS, and llvm::objcopy::elf::SectionBase::Type.
Referenced by handleArgs().
|
static |
Definition at line 268 of file ELFObjcopy.cpp.
References Config, I, if(), llvm::objcopy::elf::Object::isRelocatable(), isRequiredByABISymbol(), isUnneededSymbol(), llvm::objcopy::ELFConfig::KeepFileSymbols, llvm::objcopy::ELFConfig::LocalizeHidden, llvm::objcopy::elf::Object::removeSymbols(), llvm::objcopy::elf::Object::sections(), llvm::ELF::SHN_UNDEF, llvm::StringRef::startswith(), llvm::ELF::STB_GLOBAL, llvm::ELF::STB_LOCAL, llvm::ELF::STB_WEAK, llvm::ELF::STT_FILE, llvm::ELF::STT_SECTION, llvm::ELF::STV_HIDDEN, llvm::ELF::STV_INTERNAL, llvm::Error::success(), Sym, llvm::objcopy::elf::Object::SymbolTable, and llvm::objcopy::elf::SymbolTableSection::updateSymbols().
Referenced by handleArgs().
|
static |
Definition at line 760 of file ELFObjcopy.cpp.
References Config, createWriter(), E, llvm::objcopy::elf::Writer::finalize(), and llvm::objcopy::elf::Writer::write().
Referenced by llvm::objcopy::elf::executeObjcopyOnBinary(), llvm::objcopy::elf::executeObjcopyOnIHex(), and llvm::objcopy::elf::executeObjcopyOnRawBinary().