LLVM 19.0.0git
Namespaces | Functions
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/MCTargetOptions.h"
#include "llvm/Object/ELF.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileOutputBuffer.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

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()

static bool addressOverflows32bit ( uint64_t  Addr)
static

◆ checkChars()

static Error checkChars ( StringRef  Line)
static

◆ checkedGetHex()

template<class T >
static T checkedGetHex ( StringRef  S)
static

Definition at line 183 of file ELFObject.cpp.

◆ checkRecord()

static Error checkRecord ( const IHexRecord R)
static

◆ compareSegmentsByOffset()

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

Definition at line 1232 of file ELFObject.cpp.

References A, and B.

Referenced by layoutSegments(), and orderSegments().

◆ getAddend() [1/2]

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

Definition at line 1626 of file ELFObject.cpp.

Referenced by initRelocations(), and loadObj().

◆ getAddend() [2/2]

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

Definition at line 1629 of file ELFObject.cpp.

◆ initRelocations()

template<class T >
static Error initRelocations ( RelocationSection Relocs,
T  RelRange 
)
static

◆ isValidReservedSectionIndex()

static bool isValidReservedSectionIndex ( uint16_t  Index,
uint16_t  Machine 
)
static

◆ layoutSections()

template<class Range >
static uint64_t layoutSections ( Range  Sections,
uint64_t  Offset 
)
static

◆ layoutSectionsForOnlyKeepDebug()

static uint64_t layoutSectionsForOnlyKeepDebug ( Object Obj,
uint64_t  Off 
)
static

◆ layoutSegments()

static uint64_t layoutSegments ( std::vector< Segment * > &  Segments,
uint64_t  Offset 
)
static

◆ layoutSegmentsForOnlyKeepDebug()

static uint64_t layoutSegmentsForOnlyKeepDebug ( std::vector< Segment * > &  Segments,
uint64_t  HdrEnd 
)
static

◆ orderSegments()

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

Definition at line 2277 of file ELFObject.cpp.

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

◆ removeUnneededSections()

static Error removeUnneededSections ( Object Obj)
static

◆ sectionPhysicalAddr()

static uint64_t sectionPhysicalAddr ( const SectionBase Sec)
static

◆ sectionWithinSegment()

static bool sectionWithinSegment ( const SectionBase Sec,
const Segment Seg 
)
static

◆ segmentOverlapsSegment()

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

◆ setAddend() [1/2]

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

Definition at line 948 of file ELFObject.cpp.

Referenced by writeRel().

◆ setAddend() [2/2]

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

Definition at line 951 of file ELFObject.cpp.

◆ toHexStr()

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

◆ writeRel()

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

Definition at line 956 of file ELFObject.cpp.

References setAddend().

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