LLVM 22.0.0git
ELFObject.cpp File Reference
#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)

Function Documentation

◆ addressOverflows32bit()

bool addressOverflows32bit ( uint64_t Addr)
static

◆ checkChars()

◆ checkedGetHex()

◆ checkRecord()

◆ compareSegmentsByOffset()

bool compareSegmentsByOffset ( const Segment * A,
const Segment * B )
static

Definition at line 1253 of file ELFObject.cpp.

References A(), and B().

Referenced by layoutSegments(), and orderSegments().

◆ encodeCrel()

template<bool Is64>
SmallVector< char, 0 > encodeCrel ( ArrayRef< Relocation > Relocations)
static

Definition at line 109 of file ELFObject.cpp.

References llvm::ELF::encodeCrel().

◆ getAddend() [1/2]

template<class ELFT>
void getAddend ( uint64_t & ,
const Elf_Rel_Impl< ELFT, false > &  )
static

Definition at line 1650 of file ELFObject.cpp.

Referenced by initRelocations(), and loadObj().

◆ getAddend() [2/2]

template<class ELFT>
void getAddend ( uint64_t & ToSet,
const Elf_Rel_Impl< ELFT, true > & Rela )
static

Definition at line 1653 of file ELFObject.cpp.

◆ initRelocations()

◆ isValidReservedSectionIndex()

◆ layoutSections()

◆ layoutSectionsForOnlyKeepDebug()

◆ layoutSegments()

◆ layoutSegmentsForOnlyKeepDebug()

◆ orderSegments()

void orderSegments ( std::vector< Segment * > & Segments)
static

Definition at line 2324 of file ELFObject.cpp.

References compareSegmentsByOffset(), and llvm::stable_sort().

◆ removeUnneededSections()

◆ sectionPhysicalAddr()

◆ sectionWithinSegment()

◆ segmentOverlapsSegment()

bool segmentOverlapsSegment ( const Segment & Child,
const Segment & Parent )
static

◆ setAddend() [1/2]

template<class ELFT>
void setAddend ( Elf_Rel_Impl< ELFT, false > & ,
uint64_t  )
static

Definition at line 965 of file ELFObject.cpp.

Referenced by writeRel().

◆ setAddend() [2/2]

template<class ELFT>
void setAddend ( Elf_Rel_Impl< ELFT, true > & Rela,
uint64_t Addend )
static

Definition at line 968 of file ELFObject.cpp.

◆ toHexStr()

template<class T, class Iterator>
Iterator toHexStr ( T X,
Iterator It,
size_t Len )
static

◆ writeRel()

template<class RelRange, class T>
void writeRel ( const RelRange & Relocations,
T * Buf,
bool IsMips64EL )
static

Definition at line 973 of file ELFObject.cpp.

References setAddend(), and T.

Referenced by llvm::objcopy::elf::ELFSectionWriter< ELFT >::visit().