LLVM 20.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 564 of file ELFObjcopy.cpp.
References llvm::objcopy::elf::SectionBase::Addr, llvm::objcopy::elf::SymbolTableSection::addSymbol(), llvm::objcopy::Default, llvm::objcopy::File, llvm::objcopy::elf::Object::findSection(), llvm::objcopy::Function, llvm::objcopy::Global, llvm::objcopy::Hidden, llvm::objcopy::IndirectFunction, llvm::objcopy::Local, llvm::objcopy::Object, llvm::objcopy::Protected, llvm::objcopy::Section, 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, llvm::objcopy::elf::Object::SymbolTable, and llvm::objcopy::Weak.
Referenced by llvm::jitlink::SymbolAddressMap::addSymbols(), and handleArgs().
|
static |
Definition at line 157 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 178 of file ELFObjcopy.cpp.
References Config, and createELFWriter().
Referenced by writeOutput().
Definition at line 193 of file ELFObjcopy.cpp.
References llvm::FileOutputBuffer::create(), llvm::createStringError(), 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::createStringError(), llvm::ELF::EM_X86_64, llvm::ELF::SHF_ALLOC, llvm::ELF::SHF_EXCLUDE, llvm::ELF::SHF_EXECINSTR, llvm::ELF::SHF_MERGE, llvm::ELF::SHF_STRINGS, llvm::ELF::SHF_WRITE, and llvm::ELF::SHF_X86_64_LARGE.
Referenced by setSectionFlagsAndType().
Definition at line 136 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 149 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.
|
static |
Definition at line 96 of file ELFObjcopy.cpp.
References llvm::ELF::EM_X86_64, 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, llvm::ELF::SHF_TLS, and llvm::ELF::SHF_X86_64_LARGE.
Referenced by setSectionFlagsAndType().
|
static |
Definition at line 681 of file ELFObjcopy.cpp.
References llvm::objcopy::Add, llvm::objcopy::elf::Object::addNewSymbolTable(), llvm::objcopy::elf::Object::addSection(), addSymbol(), llvm::objcopy::ELFConfig::AllowBrokenLinks, llvm::big, Config, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::createStringError(), llvm::Data, dumpSectionToFile(), llvm::objcopy::elf::ELFT_ELF32LE, llvm::objcopy::elf::ELFT_ELF64LE, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::end(), llvm::objcopy::elf::Object::Entry, llvm::objcopy::ELFConfig::EntryExpr, llvm::ELF::ET_REL, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::find(), llvm::objcopy::elf::SectionBase::Flags, handleUserSection(), I, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::invalid_argument, llvm::little, llvm::objcopy::elf::Object::Machine, llvm::make_range(), 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(), llvm::objcopy::elf::Object::segments(), llvm::objcopy::Set, setSectionFlagsAndType(), setSectionType(), llvm::ELF::SHF_ALLOC, llvm::ELF::SHT_NOBITS, llvm::ELF::SHT_NOTE, llvm::objcopy::Subtract, llvm::Error::success(), llvm::objcopy::elf::Object::SymbolTable, llvm::StringMap< ValueTy, AllocatorTy >::try_emplace(), llvm::objcopy::elf::SectionBase::Type, llvm::objcopy::elf::Object::Type, updateAndRemoveSymbols(), llvm::objcopy::elf::Object::updateSection(), llvm::Twine::utohexstr(), verifyNoteSection(), and llvm::objcopy::ELFConfig::VerifyNoteSections.
Referenced by llvm::objcopy::elf::executeObjcopyOnBinary(), llvm::objcopy::elf::executeObjcopyOnIHex(), and llvm::objcopy::elf::executeObjcopyOnRawBinary().
|
static |
Definition at line 618 of file ELFObjcopy.cpp.
References llvm::Data, F, llvm::objcopy::NewSectionInfo::SectionData, and llvm::objcopy::NewSectionInfo::SectionName.
Referenced by handleArgs().
Definition at line 263 of file ELFObjcopy.cpp.
References llvm::objcopy::elf::Symbol::Binding, llvm::objcopy::elf::Symbol::getShndx(), Name, llvm::objcopy::elf::Symbol::Name, llvm::ELF::SHN_UNDEF, llvm::ELF::STB_LOCAL, llvm::ELF::STT_NOTYPE, Sym, and llvm::objcopy::elf::Symbol::Type.
Referenced by isRequiredByABISymbol().
Definition at line 273 of file ELFObjcopy.cpp.
References llvm::objcopy::elf::Symbol::Binding, llvm::objcopy::elf::Symbol::getShndx(), Name, llvm::objcopy::elf::Symbol::Name, llvm::ELF::SHN_UNDEF, llvm::ELF::STB_LOCAL, llvm::ELF::STT_NOTYPE, Sym, and llvm::objcopy::elf::Symbol::Type.
Referenced by isRequiredByABISymbol().
|
static |
Definition at line 54 of file ELFObjcopy.cpp.
References llvm::objcopy::elf::SectionBase::Name, and llvm::StringRef::starts_with().
Referenced by replaceAndRemoveSections().
|
static |
Definition at line 58 of file ELFObjcopy.cpp.
References llvm::StringRef::ends_with(), and llvm::objcopy::elf::SectionBase::Name.
Referenced by onlyKeepDWOPred(), and replaceAndRemoveSections().
Definition at line 285 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 298 of file ELFObjcopy.cpp.
References llvm::objcopy::elf::Symbol::Binding, llvm::objcopy::elf::Symbol::getShndx(), llvm::objcopy::elf::Symbol::Referenced, llvm::ELF::SHN_UNDEF, llvm::ELF::STB_LOCAL, llvm::ELF::STT_SECTION, Sym, and llvm::objcopy::elf::Symbol::Type.
Referenced by updateAndRemoveSymbols().
|
static |
Definition at line 62 of file ELFObjcopy.cpp.
References isDWOSection(), and llvm::objcopy::elf::Object::SectionNames.
Referenced by replaceAndRemoveSections().
|
static |
Definition at line 416 of file ELFObjcopy.cpp.
References llvm::objcopy::ELFConfig::AllowBrokenLinks, llvm::objcopy::elf::Object::compressOrDecompressSections(), Config, llvm::objcopy::elf::SymbolTableSection::empty(), llvm::objcopy::elf::SymbolTableSection::getStrTab(), isDebugSection(), isDWOSection(), llvm::objcopy::ELFConfig::KeepFileSymbols, onlyKeepDWOPred(), llvm::objcopy::elf::Object::removeSections(), 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::starts_with(), llvm::Error::success(), and llvm::objcopy::elf::Object::SymbolTable.
Referenced by handleArgs().
|
static |
Definition at line 118 of file ELFObjcopy.cpp.
References llvm::objcopy::elf::SectionBase::Flags, getNewShfFlags(), getSectionFlagsPreserveMask(), setSectionType(), llvm::ELF::SHF_ALLOC, llvm::ELF::SHT_NOBITS, llvm::ELF::SHT_PROGBITS, llvm::Error::success(), llvm::Expected< T >::takeError(), and llvm::objcopy::elf::SectionBase::Type.
Referenced by handleArgs().
|
static |
Definition at line 110 of file ELFObjcopy.cpp.
References llvm::objcopy::elf::SectionBase::Align, llvm::alignTo(), llvm::objcopy::elf::SectionBase::Offset, llvm::ELF::SHT_NOBITS, and llvm::objcopy::elf::SectionBase::Type.
Referenced by handleArgs(), and setSectionFlagsAndType().
|
static |
Definition at line 304 of file ELFObjcopy.cpp.
References llvm::objcopy::All, llvm::objcopy::elf::Symbol::Binding, Config, for(), llvm::objcopy::elf::Symbol::getShndx(), I, if(), llvm::objcopy::elf::Symbol::isCommon(), llvm::objcopy::elf::Object::isRelocatable(), isRequiredByABISymbol(), isUnneededSymbol(), llvm::objcopy::ELFConfig::KeepFileSymbols, llvm::objcopy::ELFConfig::LocalizeHidden, llvm::objcopy::Locals, llvm::objcopy::elf::Symbol::Name, llvm::objcopy::elf::Symbol::Referenced, llvm::objcopy::elf::Object::removeSymbols(), llvm::objcopy::elf::Object::sections(), llvm::ELF::SHN_UNDEF, llvm::StringRef::starts_with(), 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::ELFConfig::SymbolsToSetVisibility, llvm::objcopy::elf::Object::SymbolTable, llvm::objcopy::elf::Symbol::Type, llvm::objcopy::elf::SymbolTableSection::updateSymbols(), and llvm::objcopy::elf::Symbol::Visibility.
Referenced by handleArgs().
|
static |
Definition at line 626 of file ELFObjcopy.cpp.
References llvm::alignTo(), llvm::createStringError(), llvm::ArrayRef< T >::data(), llvm::Data, llvm::invalid_argument, Name, llvm::XCOFF::NameSize, llvm::support::endian::read32(), and llvm::Error::success().
Referenced by handleArgs().
|
static |
Definition at line 929 of file ELFObjcopy.cpp.
References Config, createWriter(), 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().