Go to the documentation of this file.
46 {
"Unknown",
"<unknown>: 7", 7},
47 {
"Unknown",
"<unknown>: 8", 8},
48 {
"Unknown",
"<unknown>: 9", 9},
50 {
"OS Specific",
"<OS specific>: 11", 11},
51 {
"OS Specific",
"<OS specific>: 12", 12},
52 {
"Proc Specific",
"<processor specific>: 13", 13},
53 {
"Proc Specific",
"<processor specific>: 14", 14},
54 {
"Proc Specific",
"<processor specific>: 15", 15}
66 return std::make_unique<ELFObjectFile<ELFT>>(
std::move(*
Ret));
71 std::pair<unsigned char, unsigned char> Ident =
73 std::size_t MaxAlignment =
82 return createPtr<ELF32LE>(Obj, InitContent);
84 return createPtr<ELF32BE>(Obj, InitContent);
89 return createPtr<ELF64LE>(Obj, InitContent);
91 return createPtr<ELF64BE>(Obj, InitContent);
316 while (!Arch.
empty()) {
336 Arch = Arch.
drop_until([](
char c) {
return c ==
'_' ||
c ==
'\0'; });
337 Arch = Arch.
drop_while([](
char c) {
return c ==
'_'; });
347 return getMIPSFeatures();
349 return getARMFeatures();
351 return getRISCVFeatures();
360 return getAMDGPUCPUName();
366 StringRef ELFObjectFileBase::getAMDGPUCPUName()
const {
598 std::vector<std::pair<Optional<DataRefImpl>,
uint64_t>>
608 JumpSlotReloc = ELF::R_386_JUMP_SLOT;
611 JumpSlotReloc = ELF::R_X86_64_JUMP_SLOT;
615 JumpSlotReloc = ELF::R_AARCH64_JUMP_SLOT;
620 std::unique_ptr<const MCInstrInfo> MII(
T->createMCInstrInfo());
621 std::unique_ptr<const MCInstrAnalysis> MIA(
622 T->createMCInstrAnalysis(MII.get()));
636 else if (
Name ==
".rela.plt" ||
Name ==
".rel.plt")
638 else if (
Name ==
".got.plt")
641 if (!Plt || !RelaPlt || !GotPlt)
648 auto PltEntries = MIA->findPltEntries(Plt->getAddress(),
649 arrayRefFromStringRef(*PltContents),
650 GotPlt->getAddress(),
Triple);
653 for (
const auto &Entry : PltEntries)
654 GotToPlt.
insert(std::make_pair(Entry.second, Entry.first));
657 std::vector<std::pair<Optional<DataRefImpl>,
uint64_t>> Result;
658 for (
const auto &Relocation : RelaPlt->relocations()) {
659 if (Relocation.getType() != JumpSlotReloc)
661 auto PltEntryIter = GotToPlt.
find(Relocation.getOffset());
662 if (PltEntryIter != GotToPlt.
end()) {
665 Result.emplace_back(
None, PltEntryIter->second);
673 template <
class ELFT>
678 std::vector<BBAddrMap> BBAddrMaps;
679 const auto &Sections =
cantFail(EF.sections());
680 for (
const Elf_Shdr &Sec : Sections) {
683 if (TextSectionIndex) {
686 return createError(
"unable to get the linked-to section for " +
689 if (*TextSectionIndex != std::distance(Sections.begin(), *TextSecOrErr))
696 std::move(BBAddrMapOrErr->begin(), BBAddrMapOrErr->end(),
697 std::back_inserter(BBAddrMaps));
702 template <
class ELFT>
707 const Elf_Shdr *VerSec =
nullptr;
708 const Elf_Shdr *VerNeedSec =
nullptr;
709 const Elf_Shdr *VerDefSec =
nullptr;
711 for (
const Elf_Shdr &Sec :
cantFail(EF.sections())) {
720 return std::vector<VersionEntry>();
723 EF.loadVersionMap(VerNeedSec, VerDefSec);
727 std::vector<VersionEntry>
Ret;
729 for (
const ELFSymbolRef &Sym : Symbols) {
732 EF.template getEntry<typename ELFT::Versym>(*VerSec,
I);
735 " from " +
describe(EF, *VerSec) +
": " +
740 return createError(
"unable to read flags for symbol with index " +
745 (*VerEntryOrErr)->vs_index, IsDefault, *MapOrErr,
749 " of " +
describe(EF, *VerSec) +
": " +
752 Ret.push_back({(*VerOrErr).str(), IsDefault});
761 if (
const auto *Obj = dyn_cast<ELF32LEObjectFile>(
this))
763 if (
const auto *Obj = dyn_cast<ELF32BEObjectFile>(
this))
765 if (
const auto *Obj = dyn_cast<ELF64LEObjectFile>(
this))
773 if (
const auto *Obj = dyn_cast<ELF32LEObjectFile>(
this))
775 if (
const auto *Obj = dyn_cast<ELF64LEObjectFile>(
this))
777 if (
const auto *Obj = dyn_cast<ELF32BEObjectFile>(
this))
779 if (
const auto *Obj = cast<ELF64BEObjectFile>(
this))
@ EF_AMDGPU_MACH_AMDGCN_GFX1010
@ EF_AMDGPU_MACH_AMDGCN_GFX803
static std::string describe(const ELFFile< ELFT > &Obj, const typename ELFT::Shdr &Sec)
@ EF_AMDGPU_MACH_R600_CAYMAN
const char * getBufferStart() const
This is an optimization pass for GlobalISel generic memory operations.
@ EF_AMDGPU_MACH_AMDGCN_GFX1033
@ EF_AMDGPU_MACH_R600_CAICOS
@ EF_AMDGPU_MACH_R600_JUNIPER
@ EF_AMDGPU_MACH_AMDGCN_GFX1012
@ EF_AMDGPU_MACH_AMDGCN_GFX940
bool isLittleEndian() const
@ EF_AMDGPU_MACH_AMDGCN_GFX90C
@ EF_AMDGPU_MACH_AMDGCN_GFX1031
void AddFeature(StringRef String, bool Enable=true)
Adds Features.
@ EF_AMDGPU_MACH_R600_SUMO
std::vector< std::pair< Optional< DataRefImpl >, uint64_t > > getPltAddresses() const
@ EF_AMDGPU_MACH_R600_CEDAR
Expected< std::vector< VersionEntry > > readDynsymVersions() const
Returns a vector containing a symbol version for each dynamic symbol.
@ EF_AMDGPU_MACH_AMDGCN_GFX1034
virtual Error getBuildAttributes(ELFAttributeParser &Attributes) const =0
@ EF_AMDGPU_MACH_R600_RS880
virtual uint16_t getEMachine() const =0
@ EF_AMDGPU_MACH_AMDGCN_GFX810
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Triple - Helper class for working with autoconf configuration names.
The instances of the Type class are immutable: once they are created, they are never changed.
@ EF_AMDGPU_MACH_R600_REDWOOD
constexpr int NumElfSymbolTypes
static Expected< std::vector< VersionEntry > > readDynsymVersionsImpl(const ELFFile< ELFT > &EF, ELFObjectFileBase::elf_symbol_iterator_range Symbols)
@ EF_AMDGPU_MACH_AMDGCN_GFX1036
Tagged union holding either a T or a Error.
@ EF_AMDGPU_MACH_AMDGCN_GFX602
static Expected< std::unique_ptr< ELFObjectFile< ELFT > > > createPtr(MemoryBufferRef Object, bool InitContent)
static const Target * lookupTarget(const std::string &Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
Expected< std::vector< BBAddrMap > > readBBAddrMapImpl(const ELFFile< ELFT > &EF, Optional< unsigned > TextSectionIndex)
@ EF_AMDGPU_MACH_AMDGCN_GFX908
void consumeError(Error Err)
Consume a Error without doing anything.
@ EF_AMDGPU_MACH_R600_R600
constexpr bool hasValue() const
virtual basic_symbol_iterator symbol_end() const =0
virtual unsigned getPlatformFlags() const =0
Returns platform-specific object flags, if any.
@ EF_AMDGPU_MACH_AMDGCN_GFX906
LLVM_NODISCARD StringRef take_front(size_t N=1) const
Return a StringRef equal to 'this' but with only the first N elements remaining.
DataRefImpl getRawDataRefImpl() const
const std::string & str() const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Manages the enabling and disabling of subtarget specific features.
@ EF_AMDGPU_MACH_AMDGCN_GFX90A
@ EF_AMDGPU_MACH_AMDGCN_GFX900
@ EF_AMDGPU_MACH_AMDGCN_GFX1030
@ EF_AMDGPU_MACH_AMDGCN_GFX909
LLVM_NODISCARD StringRef drop_until(function_ref< bool(char)> F) const
Return a StringRef equal to 'this', but with all characters not satisfying the given predicate droppe...
@ EF_AMDGPU_MACH_AMDGCN_GFX1032
static Expected< std::unique_ptr< ObjectFile > > createELFObjectFile(MemoryBufferRef Object, bool InitContent=true)
static Expected< ELFObjectFile< ELFT > > create(MemoryBufferRef Object, bool InitContent=true)
ArchType getArch() const
Get the parsed architecture type of this triple.
the resulting code requires compare and branches when and if the revised code is with conditional branches instead of More there is a byte word extend before each where there should be only and the condition codes are not remembered when the same two values are compared twice More LSR enhancements i8 and i32 load store addressing modes are identical int int c
virtual elf_symbol_iterator_range getDynamicSymbolIterators() const =0
LLVM_NODISCARD StringRef drop_while(function_ref< bool(char)> F) const
Return a StringRef equal to 'this', but with all characters satisfying the given predicate dropped fr...
This is a value type class that represents a single section in the list of sections in the object fil...
@ EF_AMDGPU_MACH_AMDGCN_GFX1102
const llvm::EnumEntry< unsigned > ElfSymbolTypes[NumElfSymbolTypes]
@ EF_AMDGPU_MACH_AMDGCN_GFX1101
bool isThumb() const
Tests whether the target is Thumb (little and big endian).
bar al al movzbl eax ret Missed when stored in a memory object
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
SubtargetFeatures getFeatures() const override
@ EF_AMDGPU_MACH_AMDGCN_GFX802
@ EF_AMDGPU_MACH_AMDGCN_GFX805
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Expected< std::vector< BBAddrMap > > readBBAddrMap(Optional< unsigned > TextSectionIndex=None) const
Returns a vector of all BB address maps in the object file. When.
@ EF_AMDGPU_MACH_AMDGCN_GFX700
@ EF_AMDGPU_MACH_AMDGCN_GFX702
iterator find(const_arg_type_t< KeyT > Val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
constexpr const T & getValue() const &
@ AllowMVEIntegerAndFloat
iterator_range< elf_symbol_iterator > elf_symbol_iterator_range
StringRef getBuffer() const
@ EF_AMDGPU_MACH_AMDGCN_GFX704
@ EF_AMDGPU_MACH_R600_TURKS
Triple makeTriple() const
Create a triple from the data in this object file.
unsigned countTrailingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the least significant bit to the most stopping at the first 1.
@ EF_AMDGPU_MACH_R600_RV730
StringRef - Represent a constant reference to a string, i.e.
This class is the base class for all object file types.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ EF_AMDGPU_MACH_AMDGCN_GFX1103
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
@ EF_AMDGPU_MACH_AMDGCN_GFX600
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
@ EF_AMDGPU_MACH_R600_RV670
@ EF_AMDGPU_MACH_R600_RV710
@ EF_AMDGPU_MACH_AMDGCN_GFX701
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
SubArchType getSubArch() const
get the parsed subarchitecture type for this triple.
@ EF_AMDGPU_MACH_R600_RV770
const char * toString(DWARFSectionKind Kind)
void setARMSubArch(Triple &TheTriple) const override
Lightweight error class with error context and mandatory checking.
@ EF_AMDGPU_MACH_AMDGCN_GFX703
@ EF_AMDGPU_MACH_R600_CYPRESS
@ EF_AMDGPU_MACH_AMDGCN_GFX601
@ EF_AMDGPU_MACH_AMDGCN_GFX902
@ EF_AMDGPU_MACH_AMDGCN_GFX1011
@ EF_AMDGPU_MACH_AMDGCN_GFX1013
Error takeError()
Take ownership of the stored error.
void setArchName(StringRef Str)
Set the architecture (first) component of the triple by name.
@ EF_AMDGPU_MACH_AMDGCN_GFX904
A range adaptor for a pair of iterators.
section_iterator_range sections() const
Error createError(const Twine &Err)
std::pair< unsigned char, unsigned char > getElfArchType(StringRef Object)
@ EF_AMDGPU_MACH_AMDGCN_GFX705
Optional< StringRef > tryGetCPUName() const override
@ EF_AMDGPU_MACH_AMDGCN_GFX1035
@ EF_AMDGPU_MACH_R600_R630
@ EF_AMDGPU_MACH_AMDGCN_GFX801
@ EF_AMDGPU_MACH_R600_BARTS
@ EF_AMDGPU_MACH_AMDGCN_GFX1100
ELFObjectFileBase(unsigned int Type, MemoryBufferRef Source)