LLVM: llvm::ifs Namespace Reference (original) (raw)
| Classes | |
|---|---|
| struct | DynamicEntries |
| struct | IFSStub |
| struct | IFSStubTriple |
| struct | IFSSymbol |
| struct | IFSTarget |
| 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 | |
|---|---|
| LLVM_ABI Expected< std::unique_ptr< IFSStub > > | readELFFile (MemoryBufferRef Buf) |
| Attempt to read a binary ELF file from a MemoryBuffer. | |
| LLVM_ABI Error | writeBinaryStub (StringRef FilePath, const IFSStub &Stub, bool WriteIfChanged=false) |
| Attempt to write a binary ELF stub. | |
| const VersionTuple | IFSVersionCurrent (3, 0) |
| LLVM_ABI Expected< std::unique_ptr< IFSStub > > | readIFSFromBuffer (StringRef Buf) |
| Attempts to read an IFS interface file from a StringRef buffer. | |
| LLVM_ABI Error | writeIFSToOutputStream (raw_ostream &OS, const IFSStub &Stub) |
| Attempts to write an IFS interface file to a raw_ostream. | |
| LLVM_ABI 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. | |
| LLVM_ABI Error | validateIFSTarget (IFSStub &Stub, bool ParseTriple) |
| Validate the target platform inforation in the text stub. | |
| LLVM_ABI void | stripIFSTarget (IFSStub &Stub, bool StripTriple, bool StripArch, bool StripEndianness, bool StripBitWidth) |
| Strips target platform information from the text stub. | |
| LLVM_ABI Error | filterIFSSyms (IFSStub &Stub, bool StripUndefined, const std::vector< std::string > &Exclude={}) |
| LLVM_ABI 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) |
| LLVM_ABI uint8_t | convertIFSBitWidthToELF (IFSBitWidthType BitWidth) |
| This function convert bit width type from IFS enum to ELF format Currently, ELFCLASS32 and ELFCLASS64 are supported. | |
| LLVM_ABI uint8_t | convertIFSEndiannessToELF (IFSEndiannessType Endianness) |
| This function convert endianness type from IFS enum to ELF format Currently, ELFDATA2LSB and ELFDATA2MSB are supported. | |
| LLVM_ABI 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. | |
| LLVM_ABI 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. | |
| LLVM_ABI 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. | |
| LLVM_ABI 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 | |
| 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 | |
| static Error | populateDynamic (DynamicEntries &Dyn, typename ELFT::DynRange DynTable) |
| This function populates a DynamicEntries struct using an ELFT::DynRange. | |
| template | |
| 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 | |
| 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 | |
| static Expected< std::unique_ptr< IFSStub > > | buildStub (const ELFObjectFile< ELFT > &ElfObj) |
| Returns a new IFSStub with all members populated from an ELFObjectFile. | |
| template | |
| 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. |
◆ IFSArch
◆ IFSBitWidthType
| Enumerator |
|---|
| IFS32 |
| IFS64 |
| Unknown |
Definition at line 45 of file IFSStub.h.
◆ IFSEndiannessType
| Enumerator |
|---|
| Little |
| Big |
| Unknown |
Definition at line 37 of file IFSStub.h.
◆ IFSSymbolType
| Enumerator |
|---|
| NoType |
| Object |
| Func |
| TLS |
| Unknown |
Definition at line 27 of file IFSStub.h.
◆ buildStub()
Returns a new IFSStub with all members populated from an ELFObjectFile.
Parameters
Definition at line 576 of file ELFObjHandler.cpp.
References llvm::ArrayRef(), convertELFBitWidthToIFS(), convertELFEndiannessToIFS(), llvm::object::ELFFile< ELFT >::dynamicEntries(), llvm::ELF::EI_CLASS, llvm::ELF::EI_DATA, llvm::object::ELFFile< ELFT >::getDynSymtabSize(), llvm::object::ELFObjectFile< ELFT >::getELFFile(), llvm::object::ELFFile< ELFT >::getHeader(), llvm::ifs::DynamicEntries::NeededLibNames, populateDynamic(), populateSymbols(), llvm::ifs::DynamicEntries::SONameOffset, llvm::Expected< T >::takeError(), and terminatedSubstr().
Referenced by readELFFile().
◆ convertELFBitWidthToIFS()
| IFSBitWidthType llvm::ifs::convertELFBitWidthToIFS | ( | uint8_t | BitWidth | ) |
|---|
◆ convertELFEndiannessToIFS()
| IFSEndiannessType llvm::ifs::convertELFEndiannessToIFS | ( | uint8_t | Endianness | ) |
|---|
◆ convertELFSymbolTypeToIFS()
| 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.
Parameters
| 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().
◆ convertIFSBitWidthToELF()
| uint8_t llvm::ifs::convertIFSBitWidthToELF | ( | IFSBitWidthType | BitWidth | ) |
|---|
◆ convertIFSEndiannessToELF()
| uint8_t llvm::ifs::convertIFSEndiannessToELF | ( | IFSEndiannessType | Endianness | ) |
|---|
◆ convertIFSSymbolTypeToELF()
| 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.
Parameters
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.
◆ createELFSym()
◆ filterIFSSyms()
| Error llvm::ifs::filterIFSSyms | ( | IFSStub & | Stub, |
|---|---|---|---|
| bool | StripUndefined, | ||
| const std::vector< std::string > & | Exclude = {} ) |
◆ IFSVersionCurrent()
◆ initELFHeader()
template
| void llvm::ifs::initELFHeader ( typename ELFT::Ehdr & ElfHeader, uint16_t Machine ) | 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.
Parameters
| 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.
◆ operator!=()
◆ operator==()
◆ overrideIFSTarget()
| Error llvm::ifs::overrideIFSTarget | ( | IFSStub & | Stub, |
|---|---|---|---|
| std::optional< IFSArch > | OverrideArch, | ||
| std::optional< IFSEndiannessType > | OverrideEndianness, | ||
| std::optional< IFSBitWidthType > | OverrideBitWidth, | ||
| std::optional< std::string > | OverrideTriple ) |
◆ parseTriple()
Parse llvm triple string into a IFSTarget struct.
Definition at line 304 of file IFSHandler.cpp.
References llvm::ifs::IFSTarget::Arch, Big, llvm::ifs::IFSTarget::BitWidth, llvm::ELF::convertTripleArchTypeToEMachine(), llvm::ELF::EM_NONE, llvm::ifs::IFSTarget::Endianness, llvm::Triple::getArch(), IFS32, IFS64, llvm::Triple::isArch64Bit(), llvm::Triple::isLittleEndian(), and Little.
Referenced by validateIFSTarget().
◆ populateDynamic()
This function populates a DynamicEntries struct using an ELFT::DynRange.
After populating the struct, the members are validated with some basic correctness checks.
Parameters
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::object::parse_failed, llvm::ifs::DynamicEntries::SONameOffset, llvm::ifs::DynamicEntries::StrSize, llvm::ifs::DynamicEntries::StrTabAddr, and llvm::Error::success().
Referenced by buildStub().
◆ populateSymbols()
◆ readELFFile()
◆ readIFSFromBuffer()
◆ stripIFSTarget()
| void llvm::ifs::stripIFSTarget | ( | IFSStub & | Stub, |
|---|---|---|---|
| bool | StripTriple, | ||
| bool | StripArch, | ||
| bool | StripEndianness, | ||
| bool | StripBitWidth ) |