| 
    LLVM 22.0.0git
    
   | 
 
#include "ELFObject.h"#include "llvm/ADT/ArrayRef.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/StringRef.h"#include "llvm/ADT/Twine.h"#include "llvm/ADT/iterator_range.h"#include "llvm/BinaryFormat/ELF.h"#include "llvm/MC/MCELFExtras.h"#include "llvm/MC/MCTargetOptions.h"#include "llvm/Support/Compression.h"#include "llvm/Support/Endian.h"#include "llvm/Support/ErrorHandling.h"#include "llvm/Support/Path.h"#include <algorithm>#include <cstddef>#include <cstdint>#include <iterator>#include <unordered_set>#include <utility>#include <vector>Go to the source code of this file.
Namespaces | |
| namespace | llvm | 
| This is an optimization pass for GlobalISel generic memory operations.  | |
| namespace | llvm::objcopy | 
| namespace | llvm::objcopy::elf | 
Functions | |
| template<bool Is64> | |
| static SmallVector< char, 0 > | encodeCrel (ArrayRef< Relocation > Relocations) | 
| static bool | addressOverflows32bit (uint64_t Addr) | 
| template<class T> | |
| static T | checkedGetHex (StringRef S) | 
| template<class T, class Iterator> | |
| static Iterator | toHexStr (T X, Iterator It, size_t Len) | 
| static Error | checkRecord (const IHexRecord &R) | 
| static Error | checkChars (StringRef Line) | 
| static uint64_t | sectionPhysicalAddr (const SectionBase *Sec) | 
| static bool | isValidReservedSectionIndex (uint16_t Index, uint16_t Machine) | 
| template<class ELFT> | |
| static void | setAddend (Elf_Rel_Impl< ELFT, false > &, uint64_t) | 
| template<class ELFT> | |
| static void | setAddend (Elf_Rel_Impl< ELFT, true > &Rela, uint64_t Addend) | 
| template<class RelRange, class T> | |
| static void | writeRel (const RelRange &Relocations, T *Buf, bool IsMips64EL) | 
| static bool | sectionWithinSegment (const SectionBase &Sec, const Segment &Seg) | 
| static bool | segmentOverlapsSegment (const Segment &Child, const Segment &Parent) | 
| static bool | compareSegmentsByOffset (const Segment *A, const Segment *B) | 
| template<class ELFT> | |
| static void | getAddend (uint64_t &, const Elf_Rel_Impl< ELFT, false > &) | 
| template<class ELFT> | |
| static void | getAddend (uint64_t &ToSet, const Elf_Rel_Impl< ELFT, true > &Rela) | 
| template<class T> | |
| static Error | initRelocations (RelocationSection *Relocs, T RelRange) | 
| static void | orderSegments (std::vector< Segment * > &Segments) | 
| static uint64_t | layoutSegments (std::vector< Segment * > &Segments, uint64_t Offset) | 
| template<class Range> | |
| static uint64_t | layoutSections (Range Sections, uint64_t Offset) | 
| static uint64_t | layoutSectionsForOnlyKeepDebug (Object &Obj, uint64_t Off) | 
| static uint64_t | layoutSegmentsForOnlyKeepDebug (std::vector< Segment * > &Segments, uint64_t HdrEnd) | 
| static Error | removeUnneededSections (Object &Obj) | 
Definition at line 193 of file ELFObject.cpp.
Referenced by llvm::objcopy::elf::ASCIIHexWriter::checkSection(), and llvm::objcopy::elf::ASCIIHexWriter::finalize().
Definition at line 301 of file ELFObject.cpp.
References assert(), llvm::createStringError(), llvm::hexDigitValue(), llvm::invalid_argument, and llvm::Error::success().
Referenced by llvm::objcopy::elf::IHexRecord::parse().
Definition at line 198 of file ELFObject.cpp.
References assert(), Fail, llvm::StringRef::getAsInteger(), and T.
Referenced by llvm::objcopy::elf::OwnedDataSection::appendHexData(), llvm::objcopy::elf::IHexRecord::getChecksum(), and llvm::objcopy::elf::IHexRecord::parse().
      
  | 
  static | 
Definition at line 251 of file ELFObject.cpp.
References llvm::createStringError(), llvm::objcopy::elf::IHexRecord::Data, llvm::objcopy::elf::IHexRecord::EndOfFile, llvm::objcopy::elf::IHexRecord::ExtendedAddr, llvm::invalid_argument, llvm::objcopy::elf::IHexRecord::SegmentAddr, llvm::objcopy::elf::IHexRecord::StartAddr, llvm::objcopy::elf::IHexRecord::StartAddr80x86, and llvm::Error::success().
Referenced by llvm::objcopy::elf::IHexRecord::parse().
Definition at line 1253 of file ELFObject.cpp.
Referenced by layoutSegments(), and orderSegments().
      
  | 
  static | 
Definition at line 109 of file ELFObject.cpp.
References llvm::ELF::encodeCrel().
      
  | 
  static | 
Definition at line 1650 of file ELFObject.cpp.
Referenced by initRelocations(), and loadObj().
      
  | 
  static | 
Definition at line 1653 of file ELFObject.cpp.
      
  | 
  static | 
Definition at line 1658 of file ELFObject.cpp.
References llvm::objcopy::elf::Relocation::Addend, llvm::objcopy::elf::RelocationSection::addRelocation(), llvm::createStringError(), getAddend(), llvm::objcopy::elf::RelocationSection::getObject(), llvm::objcopy::elf::SymbolTableSection::getSymbolByIndex(), llvm::invalid_argument, llvm::objcopy::elf::Object::IsMips64EL, llvm::objcopy::elf::SectionBase::Name, llvm::objcopy::elf::Relocation::Offset, llvm::objcopy::elf::Relocation::RelocSymbol, llvm::Error::success(), llvm::objcopy::elf::Object::SymbolTable, T, llvm::Expected< T >::takeError(), and llvm::objcopy::elf::Relocation::Type.
Definition at line 648 of file ELFObject.cpp.
References llvm::ELF::EM_AMDGPU, llvm::ELF::EM_HEXAGON, llvm::ELF::EM_MIPS, Machine, llvm::ELF::SHN_ABS, llvm::ELF::SHN_AMDGPU_LDS, llvm::ELF::SHN_COMMON, llvm::ELF::SHN_HEXAGON_SCOMMON, llvm::ELF::SHN_HEXAGON_SCOMMON_1, llvm::ELF::SHN_HEXAGON_SCOMMON_2, llvm::ELF::SHN_HEXAGON_SCOMMON_4, llvm::ELF::SHN_HEXAGON_SCOMMON_8, llvm::ELF::SHN_MIPS_ACOMMON, llvm::ELF::SHN_MIPS_SCOMMON, and llvm::ELF::SHN_MIPS_SUNDEFINED.
Definition at line 2364 of file ELFObject.cpp.
References llvm::alignTo(), llvm::objcopy::elf::Segment::Offset, llvm::Offset, llvm::objcopy::elf::SectionBase::OriginalOffset, llvm::objcopy::elf::Segment::OriginalOffset, llvm::objcopy::elf::Segment::ParentSegment, Range, llvm::ELF::SHT_NOBITS, and llvm::stable_sort().
Definition at line 2400 of file ELFObject.cpp.
References llvm::alignTo(), llvm::objcopy::elf::SectionBase::OriginalOffset, llvm::ELF::PT_LOAD, llvm::objcopy::elf::Object::sections(), llvm::ELF::SHT_NOBITS, llvm::objcopy::elf::SectionTableRef::size(), and llvm::stable_sort().
Definition at line 2331 of file ELFObject.cpp.
References llvm::objcopy::elf::Segment::Align, llvm::alignTo(), assert(), compareSegmentsByOffset(), llvm::objcopy::elf::Segment::FileSize, llvm::is_sorted(), llvm::objcopy::elf::Segment::Offset, llvm::Offset, llvm::objcopy::elf::Segment::OriginalOffset, llvm::objcopy::elf::Segment::ParentSegment, and llvm::objcopy::elf::Segment::VAddr.
      
  | 
  static | 
Definition at line 2450 of file ELFObject.cpp.
References llvm::objcopy::elf::Segment::FileSize, llvm::objcopy::elf::Segment::firstSection(), llvm::objcopy::elf::SectionBase::Offset, llvm::objcopy::elf::Segment::Offset, llvm::Offset, llvm::objcopy::elf::Segment::ParentSegment, llvm::ELF::PT_PHDR, llvm::objcopy::elf::Segment::Sections, llvm::ELF::SHT_NOBITS, Size, llvm::objcopy::elf::SectionBase::Size, llvm::objcopy::elf::SectionBase::Type, and llvm::objcopy::elf::Segment::Type.
      
  | 
  static | 
Definition at line 2324 of file ELFObject.cpp.
References compareSegmentsByOffset(), and llvm::stable_sort().
Definition at line 2560 of file ELFObject.cpp.
References llvm::objcopy::elf::SymbolTableSection::empty(), llvm::objcopy::elf::SymbolTableSection::getStrTab(), llvm::objcopy::elf::Object::isRelocatable(), llvm::objcopy::elf::Object::removeSections(), llvm::objcopy::elf::Object::SectionNames, llvm::Error::success(), and llvm::objcopy::elf::Object::SymbolTable.
Referenced by llvm::objcopy::elf::ELFWriter< ELFT >::finalize().
      
  | 
  static | 
Definition at line 343 of file ELFObject.cpp.
References llvm::objcopy::elf::SectionBase::Addr, llvm::objcopy::elf::SectionBase::OriginalOffset, llvm::objcopy::elf::Segment::OriginalOffset, llvm::objcopy::elf::Segment::PAddr, llvm::objcopy::elf::SectionBase::ParentSegment, llvm::ELF::PT_LOAD, and llvm::objcopy::elf::Segment::Type.
Referenced by llvm::objcopy::elf::ASCIIHexWriter::finalize(), llvm::objcopy::elf::IHexSectionWriterBase::writeSection(), and llvm::objcopy::elf::SRECSectionWriterBase::writeSection().
      
  | 
  static | 
Definition at line 1216 of file ELFObject.cpp.
References llvm::objcopy::elf::SectionBase::Addr, llvm::objcopy::elf::Segment::FileSize, llvm::objcopy::elf::SectionBase::Flags, llvm::objcopy::elf::Segment::MemSize, llvm::objcopy::elf::Segment::Offset, llvm::objcopy::elf::SectionBase::OriginalOffset, llvm::ELF::PT_TLS, llvm::ELF::SHF_ALLOC, llvm::ELF::SHF_TLS, llvm::ELF::SHT_NOBITS, llvm::objcopy::elf::SectionBase::Size, llvm::objcopy::elf::SectionBase::Type, llvm::objcopy::elf::Segment::Type, and llvm::objcopy::elf::Segment::VAddr.
Definition at line 1246 of file ELFObject.cpp.
References llvm::objcopy::elf::Segment::FileSize, and llvm::objcopy::elf::Segment::OriginalOffset.
      
  | 
  static | 
Definition at line 965 of file ELFObject.cpp.
Referenced by writeRel().
      
  | 
  static | 
Definition at line 968 of file ELFObject.cpp.
Definition at line 209 of file ELFObject.cpp.
References assert(), llvm::hexdigit(), I, Mod, T, and X.
Referenced by llvm::objcopy::elf::IHexRecord::getLine(), and llvm::objcopy::elf::SRecord::toString().
      
  | 
  static | 
Definition at line 973 of file ELFObject.cpp.
References setAddend(), and T.
Referenced by llvm::objcopy::elf::ELFSectionWriter< ELFT >::visit().