1//===--- XCOFFObjectFile.cpp - XCOFF object file implementation -----------===// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7//===----------------------------------------------------------------------===// 9// This file defines the XCOFFObjectFile class. 11//===----------------------------------------------------------------------===// 31// Checks that [Ptr, Ptr + Size) bytes fall inside the memory buffer 32// 'M'. Returns a pointer to the underlying object on success. 36 uintptr_t
Addr =
reinterpret_cast<uintptr_t
>(
Ptr);
39returnreinterpret_cast<constT *
>(
Addr);
43returnreinterpret_cast<uintptr_t
>(
reinterpret_cast<constchar *
>(
Base) +
47template <
typename T>
staticconstT *
viewAs(uintptr_t in) {
48returnreinterpret_cast<constT *
>(in);
59constT &DerivedXCOFFSectionHeader =
static_cast<constT &
>(*this);
64constT &DerivedXCOFFSectionHeader =
static_cast<constT &
>(*this);
65return DerivedXCOFFSectionHeader.Flags & SectionFlagsTypeMask;
70constT &DerivedXCOFFSectionHeader =
static_cast<constT &
>(*this);
71return DerivedXCOFFSectionHeader.Flags & ~SectionFlagsTypeMask;
76return getSectionType() & SectionFlagsReservedMask;
79template <
typename AddressType>
84template <
typename AddressType>
89template <
typename AddressType>
91// The relocation encodes the bit length being relocated minus 1. Add back 92// the 1 to get the actual length being relocated. 102if (LoaderSecHeader->LengthOfStrTbl >
Offset)
103return (
reinterpret_cast<constchar *
>(LoaderSecHeader) +
104 LoaderSecHeader->OffsetToStrTbl +
Offset);
107" in the loader section's string table with size 0x" +
135assert(
is64Bit() &&
"64-bit interface called on a 32-bit object file.");
136return viewAs<XCOFF::SymbolAuxType>(
140void XCOFFObjectFile::checkSectionAddress(uintptr_t
Addr,
141 uintptr_t TableAddress)
const{
142if (
Addr < TableAddress)
149if (
Offset % getSectionHeaderSize() != 0)
151"Section header pointer does not point to a valid section header.");
154const XCOFFSectionHeader32 *
155XCOFFObjectFile::toSection32(DataRefImpl
Ref)
const{
156assert(!
is64Bit() &&
"32-bit interface called on 64-bit object file.");
158 checkSectionAddress(
Ref.p, getSectionHeaderTableAddress());
160return viewAs<XCOFFSectionHeader32>(
Ref.p);
163const XCOFFSectionHeader64 *
164XCOFFObjectFile::toSection64(DataRefImpl
Ref)
const{
165assert(
is64Bit() &&
"64-bit interface called on a 32-bit object file.");
167 checkSectionAddress(
Ref.p, getSectionHeaderTableAddress());
169return viewAs<XCOFFSectionHeader64>(
Ref.p);
173assert(
Ref.p != 0 &&
"Symbol table pointer can not be nullptr!");
181assert(!
is64Bit() &&
"32-bit interface called on 64-bit object file.");
186assert(
is64Bit() &&
"64-bit interface called on a 32-bit object file.");
191assert(!
is64Bit() &&
"32-bit interface called on 64-bit object file.");
196assert(
is64Bit() &&
"64-bit interface called on a 32-bit object file.");
200template <
typename T>
constT *XCOFFObjectFile::sectionHeaderTable()
const{
201returnstatic_cast<constT *
>(SectionHeaderTable);
204const XCOFFSectionHeader32 *
205XCOFFObjectFile::sectionHeaderTable32()
const{
206assert(!
is64Bit() &&
"32-bit interface called on 64-bit object file.");
207returnstatic_cast<constXCOFFSectionHeader32 *
>(SectionHeaderTable);
210const XCOFFSectionHeader64 *
211XCOFFObjectFile::sectionHeaderTable64()
const{
212assert(
is64Bit() &&
"64-bit interface called on a 32-bit object file.");
213returnstatic_cast<constXCOFFSectionHeader64 *
>(SectionHeaderTable);
220// This function is used by basic_symbol_iterator, which allows to 221// point to the end-of-symbol-table address. 222if (NextSymbolAddr != getEndOfSymbolTableAddress())
225 Symb.
p = NextSymbolAddr;
230// The byte offset is relative to the start of the string table. 231// A byte offset value of 0 is a null or zero-length symbol 232// name. A byte offset in the range 1 to 3 (inclusive) points into the length 233// field; as a soft-error recovery mechanism, we treat such cases as having an 242" in a string table with size 0x" +
247// If the size is less than or equal to 4, then the string table contains no 278if (!CsectAuxRefOrError)
279// TODO: report the error up the stack. 282 Result = 1ULL << CsectAuxRefOrError.
get().getAlignmentLog2();
293if (!CsectAuxRefOrError)
294// TODO: report the error up the stack. 311return IsFunction.takeError();
333// The "TOC" symbol is treated as SymbolRef::ST_Other. 334if (SymNameOrError.
get() ==
"TOC")
337// The symbol for a section name is treated as SymbolRef::ST_Other. 340 SecName = XCOFFObjectFile::toSection64(SecDRIOrErr.
get())->getName();
342 SecName = XCOFFObjectFile::toSection32(SecDRIOrErr.
get())->getName();
344if (SecName == SymNameOrError.
get())
362if (isReservedSectionNumber(SectNum))
373constchar *
Ptr =
reinterpret_cast<constchar *
>(Sec.
p);
374 Sec.
p =
reinterpret_cast<uintptr_t
>(
Ptr + getSectionHeaderSize());
382// Avoid ternary due to failure to convert the ubig32_t value to a unit64_t 391// Section numbers in XCOFF are numbered beginning at 1. A section number of 392// zero is used to indicate that a symbol is being imported or is undefined. 394return toSection64(Sec) - sectionHeaderTable64() + 1;
396return toSection32(Sec) - sectionHeaderTable32() + 1;
400// Avoid ternary due to failure to convert the ubig32_t value to a unit64_t 422Data,
reinterpret_cast<uintptr_t
>(ContentStart), SectionSize))
424toString(std::move(
E)) +
": section data with offset 0x" +
428returnArrayRef(ContentStart, SectionSize);
448if (DRI.
p == 0)
// No section is not an error. 451uint64_t SectionOffset = getSectionFileOffsetToRawData(DRI);
454 uintptr_t SectionStart =
reinterpret_cast<uintptr_t
>(
base() + SectionOffset);
462#define ECASE(Value, String) \ 464 SectionName = String; \ 483" section with offset 0x" +
486" goes past the end of the file");
523auto RelocationsOrErr =
524 relocations<XCOFFSectionHeader64, XCOFFRelocation64>(*SectionEntPtr);
525if (
ErrorE = RelocationsOrErr.takeError()) {
526// TODO: report the error up the stack. 530 Ret.p =
reinterpret_cast<uintptr_t
>(&*RelocationsOrErr.get().begin());
533auto RelocationsOrErr =
534 relocations<XCOFFSectionHeader32, XCOFFRelocation32>(*SectionEntPtr);
535if (
ErrorE = RelocationsOrErr.takeError()) {
536// TODO: report the error up the stack. 540 Ret.p =
reinterpret_cast<uintptr_t
>(&*RelocationsOrErr.get().begin());
549auto RelocationsOrErr =
550 relocations<XCOFFSectionHeader64, XCOFFRelocation64>(*SectionEntPtr);
551if (
ErrorE = RelocationsOrErr.takeError()) {
552// TODO: report the error up the stack. 556 Ret.p =
reinterpret_cast<uintptr_t
>(&*RelocationsOrErr.get().end());
559auto RelocationsOrErr =
560 relocations<XCOFFSectionHeader32, XCOFFRelocation32>(*SectionEntPtr);
561if (
ErrorE = RelocationsOrErr.takeError()) {
562// TODO: report the error up the stack. 566 Ret.p =
reinterpret_cast<uintptr_t
>(&*RelocationsOrErr.get().end());
573 Rel.
p =
reinterpret_cast<uintptr_t
>(viewAs<XCOFFRelocation64>(Rel.
p) + 1);
575 Rel.
p =
reinterpret_cast<uintptr_t
>(viewAs<XCOFFRelocation32>(Rel.
p) + 1);
585// Find which section this relocation belongs to, and get the 586// relocation offset relative to the start of the section. 588 RelocAddress < Sec64->VirtualAddress + Sec64->
SectionSize) {
599// Find which section this relocation belongs to, and get the 600// relocation offset relative to the start of the section. 602 RelocAddress < Sec32->VirtualAddress + Sec32->
SectionSize) {
633return viewAs<XCOFFRelocation64>(Rel.
p)->Type;
634return viewAs<XCOFFRelocation32>(Rel.
p)->Type;
647 Result.append(Res.
begin(), Res.
end());
667if (CsectAuxEntOrErr) {
677// There is no visibility in old 32 bit XCOFF object file interpret. 692 SymDRI.
p =
reinterpret_cast<uintptr_t
>(SymbolTblPtr);
709 DRI.
p = getSectionHeaderTableAddress();
723returnis64Bit() ?
"aix5coff64-rs6000" :
"aixcoff-rs6000";
741if (AuxiliaryHeader ==
nullptr)
750 .
Case(
"dwinfo",
"debug_info")
751 .
Case(
"dwline",
"debug_line")
752 .
Case(
"dwpbnms",
"debug_pubnames")
753 .
Case(
"dwpbtyp",
"debug_pubtypes")
754 .
Case(
"dwarnge",
"debug_aranges")
755 .
Case(
"dwabrev",
"debug_abbrev")
756 .
Case(
"dwstr",
"debug_str")
757 .
Case(
"dwrnges",
"debug_ranges")
758 .
Case(
"dwloc",
"debug_loc")
759 .
Case(
"dwframe",
"debug_frame")
760 .
Case(
"dwmac",
"debug_macinfo")
764size_t XCOFFObjectFile::getFileHeaderSize()
const{
768size_t XCOFFObjectFile::getSectionHeaderSize()
const{
769returnis64Bit() ?
sizeof(XCOFFSectionHeader64) :
770sizeof(XCOFFSectionHeader32);
780 uintptr_t StartPtr =
reinterpret_cast<uintptr_t
>(Start);
781// TODO: this path is untested. 786" goes past the end of the file");
797"the section index (" +
Twine(Num) +
802 getSectionHeaderSize() * (Num - 1));
809auto GetSectionAddr = [&](
constauto &Sections) -> uintptr_t {
810for (
constauto &Sec : Sections)
811if (Sec.getSectionType() == SectType)
812returnreinterpret_cast<uintptr_t
>(&Sec);
837 getSectionNameInternal(SecRef.
get()));
847bool XCOFFObjectFile::isReservedSectionNumber(int16_t SectionNumber) {
848return (SectionNumber <= 0 && SectionNumber >= -2);
870// As far as symbol table size is concerned, if this field is negative it is 871// to be treated as a 0. However since this field is also used for printing we 872// don't want to truncate any negative values. 895uintptr_t XCOFFObjectFile::getEndOfSymbolTableAddress()
const{
897returngetWithOffset(
reinterpret_cast<uintptr_t
>(SymbolTblPtr),
902if (SymbolEntPtr <
reinterpret_cast<uintptr_t
>(SymbolTblPtr))
905if (SymbolEntPtr >= getEndOfSymbolTableAddress())
909reinterpret_cast<constchar *
>(SymbolTblPtr);
913"Symbol table entry position is not valid inside of symbol table.");
917return (
reinterpret_cast<constchar *
>(SymbolEntPtr) -
918reinterpret_cast<constchar *
>(SymbolTblPtr)) /
928if (!CsectAuxRefOrError)
929// TODO: report the error up the stack. 950if (
Index >= NumberOfSymTableEntries)
952" exceeds symbol count " +
953Twine(NumberOfSymTableEntries));
964constchar *XCOFFObjectFile::getSectionNameInternal(
DataRefImpl Sec)
const{
968uintptr_t XCOFFObjectFile::getSectionHeaderTableAddress()
const{
969returnreinterpret_cast<uintptr_t
>(SectionHeaderTable);
982assert(
is64Bit() &&
"64-bit interface called for non 64-bit file.");
989assert(!
is64Bit() &&
"32-bit interface called for non 32-bit file.");
995// In an XCOFF32 file, when the field value is 65535, then an STYP_OVRFLO 996// section header contains the actual count of relocation entries in the s_paddr 997// field. STYP_OVRFLO headers contain the section index of their corresponding 998// sections as their raw "NumberOfRelocations" field value. 1002constT &Section =
static_cast<constT &
>(Sec);
1004return Section.NumberOfRelocations;
1006uint16_t SectionIndex = &Section - sectionHeaderTable<T>() + 1;
1008return Section.NumberOfRelocations;
1011 Sec.NumberOfRelocations == SectionIndex)
1012return Sec.PhysicalAddress;
1017template <
typename Shdr,
typename Reloc>
1019 uintptr_t RelocAddr =
getWithOffset(
reinterpret_cast<uintptr_t
>(FileHeader),
1020 Sec.FileOffsetToRelocationInfo);
1022if (
ErrorE = NumRelocEntriesOrErr.takeError())
1025uint32_t NumRelocEntries = NumRelocEntriesOrErr.get();
1028"Relocation structure is incorrect");
1029auto RelocationOrErr =
1030 getObject<Reloc>(
Data,
reinterpret_cast<void *
>(RelocAddr),
1031 NumRelocEntries *
sizeof(Reloc));
1032if (!RelocationOrErr)
1034toString(RelocationOrErr.takeError()) +
": relocations with offset 0x" +
1037" go past the end of the file");
1039const Reloc *StartReloc = RelocationOrErr.get();
1044template <
typename ExceptEnt>
1051if (!ExceptionSectOrErr)
1058 ExceptEnt *ExceptEntStart =
1059reinterpret_cast<ExceptEnt *
>(*ExceptionSectOrErr);
1061 ExceptEntStart, ExceptEntStart +
getSectionSize(DRI) /
sizeof(ExceptEnt));
1071// If there is a string table, then the buffer must contain at least 4 bytes 1072// for the string table's size. Not having a string table is not an error. 1074 Obj->
Data,
reinterpret_cast<uintptr_t
>(Obj->
base() +
Offset), 4)) {
1079// Read the size out of the buffer. 1082// If the size is less then 4, then the string table is just a size and no 1085return XCOFFStringTable{4,
nullptr};
1087auto StringTableOrErr =
1089if (!StringTableOrErr)
1091": string table with offset 0x" +
1094" goes past the end of the file");
1096constchar *StringTablePtr = StringTableOrErr.get();
1097if (StringTablePtr[
Size - 1] !=
'\0')
1100return XCOFFStringTable{
Size, StringTablePtr};
1103// This function returns the import file table. Each entry in the import file 1104// table consists of: "path_name\0base_name\0archive_member_name\0". 1108if (!LoaderSectionAddrOrError)
1109return LoaderSectionAddrOrError.
takeError();
1111 uintptr_t LoaderSectionAddr = LoaderSectionAddrOrError.
get();
1112if (!LoaderSectionAddr)
1115uint64_t OffsetToImportFileTable = 0;
1116uint64_t LengthOfImportFileTable = 0;
1119 viewAs<LoaderSectionHeader64>(LoaderSectionAddr);
1124 viewAs<LoaderSectionHeader32>(LoaderSectionAddr);
1129auto ImportTableOrErr = getObject<char>(
1131reinterpret_cast<void *
>(LoaderSectionAddr + OffsetToImportFileTable),
1132 LengthOfImportFileTable);
1133if (!ImportTableOrErr)
1135toString(ImportTableOrErr.takeError()) +
1136": import file table with offset 0x" +
1139" goes past the end of the file");
1141constchar *ImportTablePtr = ImportTableOrErr.get();
1142if (ImportTablePtr[LengthOfImportFileTable - 1] !=
'\0')
1144": import file name table with offset 0x" +
1147" must end with a null terminator");
1149returnStringRef(ImportTablePtr, LengthOfImportFileTable);
1154// Can't use std::make_unique because of the private constructor. 1155 std::unique_ptr<XCOFFObjectFile> Obj;
1159constauto *
Base = Obj->base();
1162// Parse file header. 1163auto FileHeaderOrErr =
1164 getObject<void>(
Data,
Base + CurOffset, Obj->getFileHeaderSize());
1165if (
ErrorE = FileHeaderOrErr.takeError())
1167 Obj->FileHeader = FileHeaderOrErr.get();
1169 CurOffset += Obj->getFileHeaderSize();
1171if (Obj->getOptionalHeaderSize()) {
1172auto AuxiliaryHeaderOrErr =
1173 getObject<void>(
Data,
Base + CurOffset, Obj->getOptionalHeaderSize());
1174if (
ErrorE = AuxiliaryHeaderOrErr.takeError())
1176 Obj->AuxiliaryHeader = AuxiliaryHeaderOrErr.get();
1179 CurOffset += Obj->getOptionalHeaderSize();
1181// Parse the section header table if it is present. 1182if (Obj->getNumberOfSections()) {
1184 Obj->getNumberOfSections() * Obj->getSectionHeaderSize();
1185auto SecHeadersOrErr =
1186 getObject<void>(
Data,
Base + CurOffset, SectionHeadersSize);
1187if (!SecHeadersOrErr)
1189": section headers with offset 0x" +
1192" go past the end of the file");
1194 Obj->SectionHeaderTable = SecHeadersOrErr.get();
1197constuint32_t NumberOfSymbolTableEntries =
1198 Obj->getNumberOfSymbolTableEntries();
1200// If there is no symbol table we are done parsing the memory buffer. 1201if (NumberOfSymbolTableEntries == 0)
1202return std::move(Obj);
1204// Parse symbol table. 1205 CurOffset = Obj->is64Bit() ? Obj->getSymbolTableOffset64()
1206 : Obj->getSymbolTableOffset32();
1209 NumberOfSymbolTableEntries;
1211 getObject<void *>(
Data,
Base + CurOffset, SymbolTableSize);
1214toString(SymTableOrErr.takeError()) +
": symbol table with offset 0x" +
1218 Obj->SymbolTblPtr = SymTableOrErr.get();
1219 CurOffset += SymbolTableSize;
1221// Parse String table. 1222 Expected<XCOFFStringTable> StringTableOrErr =
1223 parseStringTable(Obj.get(), CurOffset);
1224if (Error
E = StringTableOrErr.takeError())
1226 Obj->StringTable = StringTableOrErr.get();
1228return std::move(Obj);
1231Expected<std::unique_ptr<ObjectFile>>
1234return XCOFFObjectFile::create(FileType, MemBufRef);
1258// A function definition should not be a common type symbol or an external 1264// If the next symbol is an XTY_LD type symbol with the same address, this 1265// XTY_SD symbol is not a function. Otherwise this is a function symbol for 1266// -ffunction-sections. 1268// If this is a csect with size 0, it won't be a function definition. 1269// This is used to work around the fact that LLVM always generates below 1270// symbol for -ffunction-sections: 1271// m 0x00000000 .text 1 unamex **No Symbol** 1272// a4 0x00000000 0 0 SD PR 0 0 1273// FIXME: remove or replace this meaningless symbol. 1278// If this is the last main symbol table entry, there won't be an XTY_LD 1279// type symbol below. 1280if (++NextIt == getObject()->symbol_end())
1286// Check next symbol is XTY_LD. If so, this symbol is not a function. 1288if (!NextCsectAuxEnt)
1301"symbol csect aux entry with index " +
1303" has invalid symbol type " +
1315"Calling csect symbol interface with a non-csect symbol.");
1321return std::move(Err);
1324if (!NumberOfAuxEntries) {
1325returncreateError(
"csect symbol \"" + *NameOrErr +
"\" with index " +
1326Twine(SymbolIdx) +
" contains no auxiliary entry");
1330// In XCOFF32, the csect auxilliary entry is always the last auxiliary 1331// entry for the symbol. 1337// XCOFF64 uses SymbolAuxType to identify the auxiliary entry type. 1338// We need to iterate through all the auxiliary entries to find it. 1342if (*getObject()->getSymbolAuxType(AuxAddr) ==
1352"a csect auxiliary entry has not been found for symbol \"" + *NameOrErr +
1353"\" with index " +
Twine(SymbolIdx));
1357// A storage class value with the high-order bit on indicates that the name is 1358// a symbolic debugger stabstring. 1360returnStringRef(
"Unimplemented Debug Name");
1373// Explicitly instantiate template classes. 1380template LLVM_EXPORT_TEMPLATE
1385template LLVM_EXPORT_TEMPLATE
1392if (Bytes.
size() < 4)
1398#define GETVALUEWITHMASK(X) (Data & (TracebackTable::X)) 1399#define GETVALUEWITHMASKSHIFT(X, S) \ 1400 ((Data & (TracebackTable::X)) >> (TracebackTable::S)) 1406return std::move(Err);
1420if (!VecParmsTypeOrError)
1423 VecParmsInfo = VecParmsTypeOrError.
get();
1440 NumberOfVectorParmsShift);
1446#undef GETVALUEWITHMASK 1447#undef GETVALUEWITHMASKSHIFT 1454return std::move(Err);
1459Error &Err,
bool Is64Bit)
1460 : TBPtr(
Ptr), Is64BitObj(Is64Bit) {
1466// Skip 8 bytes of mandatory fields. 1473// Begin to parse optional fields. 1474if (Cur && (FixedParmsNum + FloatingParmsNum) > 0)
1475 ParamsTypeValue = DE.getU32(Cur);
1478 TraceBackTableOffset = DE.getU32(Cur);
1481 HandlerMask = DE.getU32(Cur);
1484 NumOfCtlAnchors = DE.getU32(Cur);
1485if (Cur && NumOfCtlAnchors) {
1487 Disp.
reserve(*NumOfCtlAnchors);
1488for (
uint32_tI = 0;
I < NumOfCtlAnchors && Cur; ++
I)
1491 ControlledStorageInfoDisp = std::move(Disp);
1496uint16_t FunctionNameLen = DE.getU16(Cur);
1498 FunctionName = DE.getBytes(Cur, FunctionNameLen);
1502 AllocaRegister = DE.getU8(Cur);
1504unsigned VectorParmsNum = 0;
1506 StringRef VectorExtRef = DE.getBytes(Cur, 6);
1509if (!TBVecExtOrErr) {
1510 Err = TBVecExtOrErr.takeError();
1513 VecExt = TBVecExtOrErr.get();
1514 VectorParmsNum = VecExt->getNumberOfVectorParms();
1515// Skip two bytes of padding after vector info. 1520// As long as there is no fixed-point or floating-point parameter, this 1521// field remains not present even when hasVectorInfo gives true and 1522// indicates the presence of vector parameters. 1523if (Cur && (FixedParmsNum + FloatingParmsNum) > 0) {
1524 Expected<SmallString<32>> ParmsTypeOrError =
1527 FloatingParmsNum, VectorParmsNum)
1528 :
parseParmsType(ParamsTypeValue, FixedParmsNum, FloatingParmsNum);
1530if (!ParmsTypeOrError) {
1531 Err = ParmsTypeOrError.takeError();
1534 ParmsType = ParmsTypeOrError.get();
1538 ExtensionTable = DE.getU8(Cur);
1540if (*ExtensionTable & ExtendedTBTableFlag::TB_EH_INFO) {
1541// eh_info displacement must be 4-byte aligned. 1542 Cur.seek(
alignTo(Cur.tell(), 4));
1543 EhInfoDisp = Is64BitObj ? DE.getU64(Cur) : DE.getU32(Cur);
1547 Err = Cur.takeError();
1552#define GETBITWITHMASK(P, X) \ 1553 (support::endian::read32be(TBPtr + (P)) & (TracebackTable::X)) 1554#define GETBITWITHMASKSHIFT(P, X, S) \ 1555 ((support::endian::read32be(TBPtr + (P)) & (TracebackTable::X)) >> \ 1556 (TracebackTable::S)) 1595returnGETBITWITHMASK(0, IsFloatingPointOperationLogOrAbortEnabledMask);
1612 OnConditionDirectiveShift);
1649 NumberOfFixedParmsShift);
1654 NumberOfFloatingPointParmsShift);
1661#undef GETBITWITHMASK 1662#undef GETBITWITHMASKSHIFT static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Analysis containing CSE Info
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
static bool is64Bit(const char *name)
#define GETVALUEWITHMASKSHIFT(X, S)
#define GETVALUEWITHMASK(X)
#define GETBITWITHMASKSHIFT(P, X, S)
#define GETBITWITHMASK(P, X)
#define ECASE(Value, String)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
A class representing a position in a DataExtractor, as well as any error encountered during extractio...
Helper for Errors used as out-parameters.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
A table of densely packed, null-terminated strings indexed by offset.
Manages the enabling and disabling of subtarget specific features.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static Twine utohexstr(const uint64_t &Val)
void toVector(SmallVectorImpl< char > &Out) const
Append the concatenated string into the given SmallString or SmallVector.
The instances of the Type class are immutable: once they are created, they are never changed.
A range adaptor for a pair of iterators.
unsigned int getType() const
static Error checkOffset(MemoryBufferRef M, uintptr_t Addr, const uint64_t Size)
This class is the base class for all object file types.
friend class RelocationRef
const uint8_t * base() const
static Expected< std::unique_ptr< ObjectFile > > createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType)
This is a value type class that represents a single symbol in the list of symbols in the object file.
Expected< uint64_t > getAddress() const
Returns the symbol virtual address (i.e.
uint8_t getNumberOfVectorParms() const
static Expected< TBVectorExt > create(StringRef TBvectorStrRef)
bool isVRSavedOnStack() const
uint8_t getNumberOfVRSaved() const
bool hasVMXInstruction() const
XCOFF::StorageMappingClass getStorageMappingClass() const
uint8_t getSymbolType() const
uintptr_t getEntryAddress() const
uint64_t getSectionOrLength() const
Expected< DataRefImpl > getSectionByNum(int16_t Num) const
uint8_t getBytesInAddress() const override
The number of bytes used to represent an address in this object file format.
const void * getPointerToSymbolTable() const
section_iterator section_begin() const override
uint32_t getSymbolIndex(uintptr_t SymEntPtr) const
relocation_iterator section_rel_end(DataRefImpl Sec) const override
Expected< StringRef > getCFileName(const XCOFFFileAuxEnt *CFileEntPtr) const
uintptr_t getSymbolEntryAddressByIndex(uint32_t SymbolTableIndex) const
bool isDebugSection(DataRefImpl Sec) const override
const XCOFFAuxiliaryHeader32 * auxiliaryHeader32() const
ArrayRef< XCOFFSectionHeader32 > sections32() const
void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const override
const XCOFFFileHeader64 * fileHeader64() const
ArrayRef< XCOFFSectionHeader64 > sections64() const
Expected< uint64_t > getStartAddress() const override
Expected< ArrayRef< ExceptEnt > > getExceptionEntries() const
Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const override
uint32_t getSymbolTableOffset32() const
bool isSectionVirtual(DataRefImpl Sec) const override
bool isSectionBSS(DataRefImpl Sec) const override
Expected< StringRef > getSectionName(DataRefImpl Sec) const override
uint32_t getNumberOfSymbolTableEntries() const
bool isSectionData(DataRefImpl Sec) const override
uint64_t getRelocationOffset(DataRefImpl Rel) const override
uint64_t getSectionSize(DataRefImpl Sec) const override
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override
int32_t getSectionFlags(DataRefImpl Sec) const
Expected< StringRef > getSymbolName(DataRefImpl Symb) const override
const XCOFFFileHeader32 * fileHeader32() const
int32_t getRawNumberOfSymbolTableEntries32() const
Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const override
uint32_t getNumberOfSymbolTableEntries64() const
iterator_range< xcoff_symbol_iterator > xcoff_symbol_iterator_range
const XCOFFAuxiliaryHeader64 * auxiliaryHeader64() const
uint16_t getOptionalHeaderSize() const
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override
XCOFFSymbolRef toSymbolRef(DataRefImpl Ref) const
basic_symbol_iterator symbol_begin() const override
Expected< StringRef > getSymbolNameByIndex(uint32_t SymbolTableIndex) const
unsigned getSymbolSectionID(SymbolRef Sym) const
uint64_t getSymbolTableOffset64() const
uint64_t getSymbolValueImpl(DataRefImpl Symb) const override
uint16_t getNumberOfSections() const
void moveRelocationNext(DataRefImpl &Rel) const override
Expected< StringRef > getImportFileTable() const
StringRef getFileFormatName() const override
Expected< uint32_t > getNumberOfRelocationEntries(const XCOFFSectionHeader< T > &Sec) const
bool isSectionCompressed(DataRefImpl Sec) const override
Expected< StringRef > getSymbolSectionName(XCOFFSymbolRef Ref) const
Expected< StringRef > getStringTableEntry(uint32_t Offset) const
static constexpr uint64_t InvalidRelocOffset
uint64_t getSectionAddress(DataRefImpl Sec) const override
Expected< ArrayRef< uint8_t > > getSectionContents(DataRefImpl Sec) const override
Expected< SubtargetFeatures > getFeatures() const override
relocation_iterator section_rel_begin(DataRefImpl Sec) const override
uint16_t getMagic() const
uint64_t getSectionAlignment(DataRefImpl Sec) const override
void checkSymbolEntryPointer(uintptr_t SymbolEntPtr) const
StringRef mapDebugSectionName(StringRef Name) const override
Maps a debug section name to a standard DWARF section name.
basic_symbol_iterator symbol_end() const override
static uintptr_t getAdvancedSymbolEntryAddress(uintptr_t CurrentAddress, uint32_t Distance)
bool is64Bit() const override
const XCOFF::SymbolAuxType * getSymbolAuxType(uintptr_t AuxEntryAddress) const
Triple::ArchType getArch() const override
uint64_t getRelocationType(DataRefImpl Rel) const override
std::optional< StringRef > tryGetCPUName() const override
bool isSectionText(DataRefImpl Sec) const override
Expected< StringRef > getRawData(const char *Start, uint64_t Size, StringRef Name) const
uint16_t getFlags() const
uint64_t getSymbolSize(DataRefImpl Symb) const
int32_t getTimeStamp() const
void moveSymbolNext(DataRefImpl &Symb) const override
Expected< ArrayRef< Reloc > > relocations(const Shdr &Sec) const
uint64_t getSectionIndex(DataRefImpl Sec) const override
bool isRelocatableObject() const override
True if this is a relocatable object (.o/.obj).
void moveSectionNext(DataRefImpl &Sec) const override
Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const override
section_iterator section_end() const override
uint32_t getLogicalNumberOfSymbolTableEntries32() const
xcoff_symbol_iterator_range symbols() const
uint32_t getSymbolAlignment(DataRefImpl Symb) const override
Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const override
StringRef getStringTable() const
Expected< XCOFFCsectAuxRef > getXCOFFCsectAuxRef() const
Expected< bool > isFunction() const
int16_t getSectionNumber() const
bool isCsectSymbol() const
const XCOFFSymbolEntry64 * getSymbol64() const
const XCOFFSymbolEntry32 * getSymbol32() const
uint16_t getSymbolType() const
uint64_t getValue() const
Expected< StringRef > getName() const
uint8_t getNumberOfAuxEntries() const
uintptr_t getEntryAddress() const
XCOFF::StorageClass getStorageClass() const
This class provides methods to extract traceback table data from a buffer.
bool isOutOfLineEpilogOrPrologue() const
uint8_t getNumOfGPRsSaved() const
bool hasTraceBackTableOffset() const
bool hasParmsOnStack() const
bool hasExtensionTable() const
uint8_t getOnConditionDirective() const
uint8_t getLanguageID() const
uint8_t getNumOfFPRsSaved() const
bool isFloatingPointOperationLogOrAbortEnabled() const
uint8_t getNumberOfFPParms() const
bool isFuncNamePresent() const
bool isAllocaUsed() const
bool isGlobalLinkage() const
bool isInternalProcedure() const
bool hasControlledStorage() const
bool isInterruptHandler() const
bool isFloatingPointPresent() const
uint8_t getVersion() const
static Expected< XCOFFTracebackTable > create(const uint8_t *Ptr, uint64_t &Size, bool Is64Bits=false)
Parse an XCOFF Traceback Table from Ptr with Size bytes.
bool isBackChainStored() const
uint8_t getNumberOfFixedParms() const
bool hasVectorInfo() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static constexpr uint8_t XR_BIASED_LENGTH_MASK
constexpr size_t RelocationSerializationSize32
static constexpr uint8_t XR_FIXUP_INDICATOR_MASK
constexpr uint16_t VISIBILITY_MASK
Expected< SmallString< 32 > > parseParmsTypeWithVecInfo(uint32_t Value, unsigned FixedParmsNum, unsigned FloatingParmsNum, unsigned VectorParmsNum)
static constexpr uint8_t XR_SIGN_INDICATOR_MASK
StringRef getRelocationTypeString(XCOFF::RelocationType Type)
Expected< SmallString< 32 > > parseParmsType(uint32_t Value, unsigned FixedParmsNum, unsigned FloatingParmsNum)
constexpr size_t RelocationSerializationSize64
Expected< SmallString< 32 > > parseVectorParmsType(uint32_t Value, unsigned ParmsNum)
@ AUX_CSECT
Identifies a csect auxiliary entry.
constexpr size_t NameSize
constexpr uint16_t RelocOverflow
@ XMC_GL
Global Linkage (Interfile Interface Code)
constexpr size_t SymbolTableEntrySize
@ XTY_CM
Common csect definition. For uninitialized storage.
@ XTY_SD
Csect definition for initialized storage.
@ XTY_LD
Label definition.
@ XTY_ER
External reference.
static Expected< const T * > getObject(MemoryBufferRef M, const void *Ptr, const uint64_t Size=sizeof(T))
bool doesXCOFFTracebackTableBegin(ArrayRef< uint8_t > Bytes)
Error createError(const Twine &Err)
Expected< StringRef > getLoaderSecSymNameInStrTbl(const T *LoaderSecHeader, uint64_t Offset)
static const size_t SymbolAuxTypeOffset
static const uint16_t NoRelMask
@ string_table_non_null_end
content_iterator< SectionRef > section_iterator
static const uint8_t FunctionSym
content_iterator< RelocationRef > relocation_iterator
content_iterator< BasicSymbolRef > basic_symbol_iterator
static uintptr_t getWithOffset(uintptr_t Base, ptrdiff_t Offset)
static StringRef generateXCOFFFixedNameStringRef(const char *Name)
static const T * viewAs(uintptr_t in)
uint32_t read32be(const void *P)
uint16_t read16be(const void *P)
This is an optimization pass for GlobalISel generic memory operations.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
@ Ref
The access may reference the value stored in memory.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
const char * toString(DWARFSectionKind Kind)
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
void consumeError(Error Err)
Consume a Error without doing anything.
support::ubig32_t LengthOfImpidStrTbl
support::big32_t OffsetToImpid
support::ubig32_t LengthOfImpidStrTbl
support::big64_t OffsetToImpid
support::big32_t IsNameInStrTbl
Expected< StringRef > getSymbolName(const LoaderSectionHeader32 *LoaderSecHeader) const
char SymbolName[XCOFF::NameSize]
Expected< StringRef > getSymbolName(const LoaderSectionHeader64 *LoaderSecHeader) const
uint64_t getEntryPointAddr() const
NameInStrTblType NameInStrTbl
char Name[XCOFF::NameSize+XCOFF::FileNamePadSize]
support::big32_t NumberOfSymTableEntries
support::big32_t TimeStamp
support::ubig16_t AuxHeaderSize
support::ubig16_t NumberOfSections
support::ubig32_t SymbolTableOffset
support::big32_t TimeStamp
support::ubig16_t AuxHeaderSize
support::ubig64_t SymbolTableOffset
support::ubig32_t NumberOfSymTableEntries
support::ubig16_t NumberOfSections
XCOFF::RelocationType Type
AddressType VirtualAddress
bool isFixupIndicated() const
support::ubig32_t SymbolIndex
uint8_t getRelocatedLength() const
bool isRelocationSigned() const
support::ubig32_t FileOffsetToRawData
support::ubig32_t SectionSize
char Name[XCOFF::NameSize]
support::ubig32_t VirtualAddress
support::ubig64_t VirtualAddress
support::ubig64_t SectionSize
support::big64_t FileOffsetToRawData
char Name[XCOFF::NameSize]
bool isReservedSectionType() const
StringRef getName() const
uint32_t getSectionSubtype() const
uint16_t getSectionType() const