LLVM 20.0.0git
|
Classes | |
struct | DynamicEntries |
struct | IFSStub |
struct | IFSStubTriple |
struct | IFSSymbol |
struct | IFSTarget |
Typedefs | |
typedef uint16_t | IFSArch |
Enumerations | |
enum class | IFSSymbolType { NoType , Object , Func , TLS , Unknown = 16 } |
enum class | IFSEndiannessType { Little , Big , Unknown = 256 } |
enum class | IFSBitWidthType { IFS32 , IFS64 , Unknown = 256 } |
Functions | |
Expected< std::unique_ptr< IFSStub > > | readELFFile (MemoryBufferRef Buf) |
Attempt to read a binary ELF file from a MemoryBuffer. | |
Error | writeBinaryStub (StringRef FilePath, const IFSStub &Stub, bool WriteIfChanged=false) |
Attempt to write a binary ELF stub. | |
const VersionTuple | IFSVersionCurrent (3, 0) |
Expected< std::unique_ptr< IFSStub > > | readIFSFromBuffer (StringRef Buf) |
Attempts to read an IFS interface file from a StringRef buffer. | |
Error | writeIFSToOutputStream (raw_ostream &OS, const IFSStub &Stub) |
Attempts to write an IFS interface file to a raw_ostream. | |
Error | overrideIFSTarget (IFSStub &Stub, std::optional< IFSArch > OverrideArch, std::optional< IFSEndiannessType > OverrideEndianness, std::optional< IFSBitWidthType > OverrideBitWidth, std::optional< std::string > OverrideTriple) |
Override the target platform inforation in the text stub. | |
Error | validateIFSTarget (IFSStub &Stub, bool ParseTriple) |
Validate the target platform inforation in the text stub. | |
void | stripIFSTarget (IFSStub &Stub, bool StripTriple, bool StripArch, bool StripEndianness, bool StripBitWidth) |
Strips target platform information from the text stub. | |
Error | filterIFSSyms (IFSStub &Stub, bool StripUndefined, const std::vector< std::string > &Exclude={}) |
IFSTarget | parseTriple (StringRef TripleStr) |
Parse llvm triple string into a IFSTarget struct. | |
bool | operator== (const IFSTarget &Lhs, const IFSTarget &Rhs) |
bool | operator!= (const IFSTarget &Lhs, const IFSTarget &Rhs) |
uint8_t | convertIFSBitWidthToELF (IFSBitWidthType BitWidth) |
This function convert bit width type from IFS enum to ELF format Currently, ELFCLASS32 and ELFCLASS64 are supported. | |
uint8_t | convertIFSEndiannessToELF (IFSEndiannessType Endianness) |
This function convert endianness type from IFS enum to ELF format Currently, ELFDATA2LSB and ELFDATA2MSB are supported. | |
uint8_t | convertIFSSymbolTypeToELF (IFSSymbolType SymbolType) |
This function convert symbol type from IFS enum to ELF format Currently, STT_NOTYPE, STT_OBJECT, STT_FUNC, and STT_TLS are supported. | |
IFSBitWidthType | convertELFBitWidthToIFS (uint8_t BitWidth) |
This function extracts ELF bit width from e_ident[EI_CLASS] of an ELF file Currently, ELFCLASS32 and ELFCLASS64 are supported. | |
IFSEndiannessType | convertELFEndiannessToIFS (uint8_t Endianness) |
This function extracts ELF endianness from e_ident[EI_DATA] of an ELF file Currently, ELFDATA2LSB and ELFDATA2MSB are supported. | |
IFSSymbolType | convertELFSymbolTypeToIFS (uint8_t SymbolType) |
This function extracts symbol type from a symbol's st_info member and maps it to an IFSSymbolType enum. | |
template<class ELFT > | |
static void | initELFHeader (typename ELFT::Ehdr &ElfHeader, uint16_t Machine) |
This initializes an ELF file header with information specific to a binary dynamic shared object. | |
static Expected< StringRef > | terminatedSubstr (StringRef Str, size_t Offset) |
This function behaves similarly to StringRef::substr(), but attempts to terminate the returned StringRef at the first null terminator. | |
template<class ELFT > | |
static Error | populateDynamic (DynamicEntries &Dyn, typename ELFT::DynRange DynTable) |
This function populates a DynamicEntries struct using an ELFT::DynRange. | |
template<class ELFT > | |
static IFSSymbol | createELFSym (StringRef SymName, const typename ELFT::Sym &RawSym) |
This function creates an IFSSymbol and populates all members using information from a binary ELFT::Sym. | |
template<class ELFT > | |
static Error | populateSymbols (IFSStub &TargetStub, const typename ELFT::SymRange DynSym, StringRef DynStr) |
This function populates an IFSStub with symbols using information read from an ELF binary. | |
template<class ELFT > | |
static Expected< std::unique_ptr< IFSStub > > | buildStub (const ELFObjectFile< ELFT > &ElfObj) |
Returns a new IFSStub with all members populated from an ELFObjectFile. | |
template<class ELFT > | |
static Error | writeELFBinaryToFile (StringRef FilePath, const IFSStub &Stub, bool WriteIfChanged) |
This function opens a file for writing and then writes a binary ELF stub to the file. | |
typedef uint16_t llvm::ifs::IFSArch |
|
strong |
|
strong |
|
strong |
|
static |
Returns a new IFSStub with all members populated from an ELFObjectFile.
ElfObj | Source ELFObjectFile. |
Definition at line 576 of file ELFObjHandler.cpp.
References convertELFBitWidthToIFS(), convertELFEndiannessToIFS(), llvm::ELF::EI_CLASS, llvm::ELF::EI_DATA, llvm::object::ELFObjectFile< ELFT >::getELFFile(), llvm::ifs::DynamicEntries::NeededLibNames, llvm::ifs::DynamicEntries::SONameOffset, llvm::Expected< T >::takeError(), and terminatedSubstr().
Referenced by readELFFile().
IFSBitWidthType llvm::ifs::convertELFBitWidthToIFS | ( | uint8_t | BitWidth | ) |
This function extracts ELF bit width from e_ident[EI_CLASS] of an ELF file Currently, ELFCLASS32 and ELFCLASS64 are supported.
Other endianness types are mapped to IFSBitWidthType::Unknown.
BitWidth | e_ident[EI_CLASS] value to extract bit width from. |
Definition at line 98 of file IFSStub.cpp.
References llvm::BitWidth, llvm::ELF::ELFCLASS32, llvm::ELF::ELFCLASS64, IFS32, IFS64, and Unknown.
Referenced by buildStub().
IFSEndiannessType llvm::ifs::convertELFEndiannessToIFS | ( | uint8_t | Endianness | ) |
This function extracts ELF endianness from e_ident[EI_DATA] of an ELF file Currently, ELFDATA2LSB and ELFDATA2MSB are supported.
Other endianness types are mapped to IFSEndiannessType::Unknown.
Endianness | e_ident[EI_DATA] value to extract endianness type from. |
Definition at line 109 of file IFSStub.cpp.
References Big, llvm::ELF::ELFDATA2LSB, llvm::ELF::ELFDATA2MSB, Little, and Unknown.
Referenced by buildStub().
IFSSymbolType llvm::ifs::convertELFSymbolTypeToIFS | ( | uint8_t | SymbolType | ) |
This function extracts symbol type from a symbol's st_info member and maps it to an IFSSymbolType enum.
Currently, STT_NOTYPE, STT_OBJECT, STT_FUNC, and STT_TLS are supported. Other symbol types are mapped to IFSSymbolType::Unknown.
SymbolType | Binary symbol st_info to extract symbol type from. |
Definition at line 120 of file IFSStub.cpp.
References Func, NoType, Object, llvm::ELF::STT_FUNC, llvm::ELF::STT_NOTYPE, llvm::ELF::STT_OBJECT, llvm::ELF::STT_TLS, TLS, and Unknown.
Referenced by createELFSym().
uint8_t llvm::ifs::convertIFSBitWidthToELF | ( | IFSBitWidthType | BitWidth | ) |
This function convert bit width type from IFS enum to ELF format Currently, ELFCLASS32 and ELFCLASS64 are supported.
BitWidth | IFS bit width type. |
Definition at line 61 of file IFSStub.cpp.
References llvm::BitWidth, llvm::ELF::ELFCLASS32, llvm::ELF::ELFCLASS64, IFS32, IFS64, and llvm_unreachable.
uint8_t llvm::ifs::convertIFSEndiannessToELF | ( | IFSEndiannessType | Endianness | ) |
This function convert endianness type from IFS enum to ELF format Currently, ELFDATA2LSB and ELFDATA2MSB are supported.
Endianness | IFS endianness type. |
Definition at line 72 of file IFSStub.cpp.
References Big, llvm::ELF::ELFDATA2LSB, llvm::ELF::ELFDATA2MSB, Little, and llvm_unreachable.
uint8_t llvm::ifs::convertIFSSymbolTypeToELF | ( | IFSSymbolType | SymbolType | ) |
This function convert symbol type from IFS enum to ELF format Currently, STT_NOTYPE, STT_OBJECT, STT_FUNC, and STT_TLS are supported.
SymbolType | IFS symbol type. |
Definition at line 83 of file IFSStub.cpp.
References Func, llvm_unreachable, NoType, Object, llvm::ELF::STT_FUNC, llvm::ELF::STT_NOTYPE, llvm::ELF::STT_OBJECT, llvm::ELF::STT_TLS, and TLS.
|
static |
This function creates an IFSSymbol and populates all members using information from a binary ELFT::Sym.
SymName | The desired name of the IFSSymbol. |
RawSym | ELFT::Sym to extract symbol information from. |
Definition at line 520 of file ELFObjHandler.cpp.
References convertELFSymbolTypeToIFS(), Func, llvm::ELF::STB_WEAK, and llvm::ifs::IFSSymbol::Weak.
Error llvm::ifs::filterIFSSyms | ( | IFSStub & | Stub, |
bool | StripUndefined, | ||
const std::vector< std::string > & | Exclude = {} |
||
) |
Definition at line 348 of file IFSHandler.cpp.
References llvm::GlobPattern::create(), llvm::erase_if(), llvm::Filter, llvm::Pattern::match(), llvm::Error::success(), Sym, llvm::ifs::IFSStub::Symbols, and llvm::Expected< T >::takeError().
const VersionTuple llvm::ifs::IFSVersionCurrent | ( | 3 | , |
0 | |||
) |
Referenced by readIFSFromBuffer().
|
static |
This initializes an ELF file header with information specific to a binary dynamic shared object.
Offsets, indexes, links, etc. for section and program headers are just zero-initialized as they will be updated elsewhere.
ElfHeader | Target ELFT::Ehdr to populate. |
Machine | Target architecture (e_machine from ELF specifications). |
Definition at line 52 of file ELFObjHandler.cpp.
References llvm::ELF::EI_CLASS, llvm::ELF::EI_DATA, llvm::ELF::EI_MAG0, llvm::ELF::EI_MAG1, llvm::ELF::EI_MAG2, llvm::ELF::EI_MAG3, llvm::ELF::EI_OSABI, llvm::ELF::EI_VERSION, llvm::ELF::ELFCLASS32, llvm::ELF::ELFCLASS64, llvm::ELF::ELFDATA2LSB, llvm::ELF::ELFDATA2MSB, llvm::ELF::ElfMagic, llvm::ELF::ELFOSABI_NONE, llvm::ELF::ET_DYN, llvm::ELF::EV_CURRENT, llvm::little, and Machine.
Definition at line 75 of file IFSStub.h.
References llvm::ifs::IFSTarget::Arch, llvm::ifs::IFSTarget::BitWidth, llvm::ifs::IFSTarget::Endianness, llvm::ifs::IFSTarget::ObjectFormat, llvm::operator==(), and llvm::ifs::IFSTarget::Triple.
Error llvm::ifs::overrideIFSTarget | ( | IFSStub & | Stub, |
std::optional< IFSArch > | OverrideArch, | ||
std::optional< IFSEndiannessType > | OverrideEndianness, | ||
std::optional< IFSBitWidthType > | OverrideBitWidth, | ||
std::optional< std::string > | OverrideTriple | ||
) |
Override the target platform inforation in the text stub.
Definition at line 231 of file IFSHandler.cpp.
References llvm::ifs::IFSTarget::Arch, llvm::ifs::IFSTarget::BitWidth, llvm::ifs::IFSTarget::Endianness, llvm::Error::success(), llvm::ifs::IFSStub::Target, and llvm::ifs::IFSTarget::Triple.
Parse llvm triple string into a IFSTarget struct.
Definition at line 304 of file IFSHandler.cpp.
References llvm::ifs::IFSTarget::Arch, llvm::ifs::IFSTarget::BitWidth, llvm::ELF::EM_AARCH64, llvm::ELF::EM_NONE, llvm::ELF::EM_RISCV, llvm::ELF::EM_X86_64, llvm::ifs::IFSTarget::Endianness, llvm::Triple::getArch(), llvm::Triple::isArch64Bit(), and llvm::Triple::isLittleEndian().
Referenced by validateIFSTarget().
|
static |
This function populates a DynamicEntries struct using an ELFT::DynRange.
After populating the struct, the members are validated with some basic correctness checks.
Dyn | Target DynamicEntries struct to populate. |
DynTable | Source dynamic table. |
Definition at line 447 of file ELFObjHandler.cpp.
References llvm::createError(), llvm::createStringError(), llvm::ifs::DynamicEntries::DynSymAddr, llvm::ifs::DynamicEntries::ElfHash, llvm::ifs::DynamicEntries::GnuHash, llvm::ifs::DynamicEntries::NeededLibNames, llvm::Offset, llvm::ifs::DynamicEntries::SONameOffset, llvm::ifs::DynamicEntries::StrSize, llvm::ifs::DynamicEntries::StrTabAddr, and llvm::Error::success().
|
static |
This function populates an IFSStub with symbols using information read from an ELF binary.
TargetStub | IFSStub to add symbols to. |
DynSym | Range of dynamic symbols to add to TargetStub. |
DynStr | StringRef to the dynamic string table. |
Definition at line 547 of file ELFObjHandler.cpp.
References llvm::ELF::STB_GLOBAL, llvm::ELF::STB_WEAK, llvm::ELF::STV_DEFAULT, llvm::ELF::STV_PROTECTED, llvm::Error::success(), Sym, llvm::ifs::IFSStub::Symbols, llvm::Expected< T >::takeError(), and terminatedSubstr().
Expected< std::unique_ptr< IFSStub > > llvm::ifs::readELFFile | ( | MemoryBufferRef | Buf | ) |
Attempt to read a binary ELF file from a MemoryBuffer.
Definition at line 691 of file ELFObjHandler.cpp.
References llvm::Bin, buildStub(), llvm::object::createBinary(), llvm::createStringError(), llvm::dyn_cast(), llvm::Expected< T >::get(), llvm::not_supported, and llvm::Expected< T >::takeError().
Attempts to read an IFS interface file from a StringRef buffer.
Definition at line 179 of file IFSHandler.cpp.
References llvm::ELF::convertArchNameToEMachine(), llvm::createStringError(), llvm::ELF::EM_NONE, IFSVersionCurrent(), and usesTriple().
void llvm::ifs::stripIFSTarget | ( | IFSStub & | Stub, |
bool | StripTriple, | ||
bool | StripArch, | ||
bool | StripEndianness, | ||
bool | StripBitWidth | ||
) |
Strips target platform information from the text stub.
Definition at line 328 of file IFSHandler.cpp.
References llvm::ifs::IFSTarget::Arch, llvm::ifs::IFSTarget::ArchString, llvm::ifs::IFSTarget::BitWidth, llvm::ifs::IFSTarget::Endianness, llvm::ifs::IFSTarget::ObjectFormat, llvm::ifs::IFSStub::Target, and llvm::ifs::IFSTarget::Triple.
This function behaves similarly to StringRef::substr(), but attempts to terminate the returned StringRef at the first null terminator.
If no null terminator is found, an error is returned.
Str | Source string to create a substring from. |
Offset | The start index of the desired substring. |
Definition at line 429 of file ELFObjHandler.cpp.
References llvm::createError(), llvm::StringRef::npos, and llvm::Offset.
Referenced by buildStub(), and populateSymbols().
Validate the target platform inforation in the text stub.
Definition at line 269 of file IFSHandler.cpp.
References llvm::ifs::IFSTarget::Arch, llvm::ifs::IFSTarget::BitWidth, llvm::ifs::IFSTarget::Endianness, llvm::ifs::IFSTarget::ObjectFormat, parseTriple(), llvm::Error::success(), llvm::ifs::IFSStub::Target, and llvm::ifs::IFSTarget::Triple.
Error llvm::ifs::writeBinaryStub | ( | StringRef | FilePath, |
const IFSStub & | Stub, | ||
bool | WriteIfChanged = false |
||
) |
Attempt to write a binary ELF stub.
This function determines appropriate ELFType using the passed ELFTarget and then writes a binary ELF stub to a specified file path.
FilePath | File path for writing the ELF binary. |
Stub | Source ELFStub to generate a binary ELF stub from. |
WriteIfChanged | Whether or not to preserve timestamp if the output stays the same. |
Definition at line 712 of file ELFObjHandler.cpp.
References llvm::ifs::IFSTarget::Arch, assert(), llvm::ifs::IFSTarget::BitWidth, llvm::ifs::IFSTarget::Endianness, IFS32, Little, llvm_unreachable, llvm::ifs::IFSStub::Target, and WriteIfChanged.
|
static |
This function opens a file for writing and then writes a binary ELF stub to the file.
FilePath | File path for writing the ELF binary. |
Stub | Source InterFace Stub to generate a binary ELF stub from. |
Definition at line 657 of file ELFObjHandler.cpp.
References llvm::FileOutputBuffer::create(), llvm::createStringError(), llvm::MemoryBuffer::getFile(), llvm::invalid_argument, memcmp, llvm::Error::success(), llvm::Expected< T >::takeError(), llvm::dwarf::toString(), and WriteIfChanged.
Error llvm::ifs::writeIFSToOutputStream | ( | raw_ostream & | OS, |
const IFSStub & | Stub | ||
) |
Attempts to write an IFS interface file to a raw_ostream.
Definition at line 213 of file IFSHandler.cpp.
References llvm::ifs::IFSTarget::Arch, llvm::ELF::convertEMachineToArchName(), OS, llvm::Error::success(), and llvm::ifs::IFSStub::Target.