13#ifndef LLVM_OBJECT_XCOFFOBJECTFILE_H
14#define LLVM_OBJECT_XCOFFOBJECTFILE_H
28class xcoff_symbol_iterator;
64 return static_cast<const T *
>(
this)->FlagAndTDataAlignment &
69 return static_cast<const T *
>(
this)->FlagAndTDataAlignment &
75 return static_cast<const T *
>(
this)->EntryPointAddr;
272 return NumberOfRelTabEnt == 0
304 assert(Reason == 0 &&
"Get symbol table index of the function only when "
305 "the e_reason field is 0.");
310 assert(Reason != 0 &&
"Zero is not a valid trap exception reason code.");
352 static constexpr uint8_t SymbolTypeMask = 0x07;
353 static constexpr uint8_t SymbolAlignmentMask = 0xF8;
354 static constexpr size_t SymbolAlignmentBitOffset = 3;
365 return Entry32 ? getSectionOrLength32() : getSectionOrLength64();
369 assert(Entry32 &&
"32-bit interface called on 64-bit object file.");
370 return Entry32->SectionOrLength;
374 assert(Entry64 &&
"64-bit interface called on 32-bit object file.");
375 return (
static_cast<uint64_t>(Entry64->SectionOrLengthHighByte) << 32) |
376 Entry64->SectionOrLengthLowByte;
379#define GETVALUE(X) Entry32 ? Entry32->X : Entry64->X
382 return GETVALUE(ParameterHashIndex);
392 return Entry32 ?
reinterpret_cast<uintptr_t
>(Entry32)
393 :
reinterpret_cast<uintptr_t
>(Entry64);
397 return (getSymbolAlignmentAndType() & SymbolAlignmentMask) >>
398 SymbolAlignmentBitOffset;
402 return getSymbolAlignmentAndType() & SymbolTypeMask;
408 assert(Entry32 &&
"32-bit interface called on 64-bit object file.");
409 return Entry32->StabInfoIndex;
413 assert(Entry32 &&
"32-bit interface called on 64-bit object file.");
414 return Entry32->StabSectNum;
418 assert(Entry64 &&
"64-bit interface called on 32-bit object file.");
419 return Entry64->AuxType;
423 return GETVALUE(SymbolAlignmentAndType);
534 const void *FileHeader =
nullptr;
535 const void *AuxiliaryHeader =
nullptr;
536 const void *SectionHeaderTable =
nullptr;
538 const void *SymbolTblPtr =
nullptr;
543 template <
typename T>
const T *sectionHeaderTable()
const;
545 size_t getFileHeaderSize()
const;
546 size_t getSectionHeaderSize()
const;
550 uintptr_t getSectionHeaderTableAddress()
const;
551 uintptr_t getEndOfSymbolTableAddress()
const;
559 const char *getSectionNameInternal(
DataRefImpl Sec)
const;
561 static bool isReservedSectionNumber(int16_t SectionNumber);
579 void checkSectionAddress(uintptr_t
Addr, uintptr_t TableAddr)
const;
583 std::numeric_limits<uint64_t>::max();
586 void moveSymbolNext(
DataRefImpl &Symb)
const override;
603 void moveSectionNext(
DataRefImpl &Sec)
const override;
609 getSectionContents(
DataRefImpl Sec)
const override;
611 bool isSectionCompressed(
DataRefImpl Sec)
const override;
612 bool isSectionText(
DataRefImpl Sec)
const override;
613 bool isSectionData(
DataRefImpl Sec)
const override;
617 bool isSectionVirtual(
DataRefImpl Sec)
const override;
621 void moveRelocationNext(
DataRefImpl &Rel)
const override;
634 uint8_t getBytesInAddress()
const override;
635 StringRef getFileFormatName()
const override;
640 bool isRelocatableObject()
const override;
660 uint16_t getNumberOfSections()
const;
661 int32_t getTimeStamp()
const;
665 uint32_t getSymbolTableOffset32()
const;
666 uint64_t getSymbolTableOffset64()
const;
670 int32_t getRawNumberOfSymbolTableEntries32()
const;
673 uint32_t getLogicalNumberOfSymbolTableEntries32()
const;
675 uint32_t getNumberOfSymbolTableEntries64()
const;
679 uint32_t getNumberOfSymbolTableEntries()
const;
681 uint32_t getSymbolIndex(uintptr_t SymEntPtr)
const;
684 return reinterpret_cast<uintptr_t
>(SymbolTblPtr) +
687 uintptr_t getSymbolEntryAddressByIndex(
uint32_t SymbolTableIndex)
const;
691 uint16_t getOptionalHeaderSize()
const;
704 void checkSymbolEntryPointer(uintptr_t SymbolEntPtr)
const;
707 template <
typename T>
711 template <
typename Shdr,
typename Reloc>
718 template <
typename ExceptEnt>
729 static uintptr_t getAdvancedSymbolEntryAddress(uintptr_t CurrentAddress,
734 std::optional<StringRef> tryGetCPUName()
const override;
780XCOFFObjectFile::relocations<XCOFFSectionHeader32, XCOFFRelocation32>(
783XCOFFObjectFile::relocations<XCOFFSectionHeader64, XCOFFRelocation64>(
792 :
SymbolRef(SymEntDataRef, OwningObjectPtr) {
793 assert(OwningObjectPtr &&
"OwningObjectPtr cannot be nullptr!");
795 "Symbol table entry pointer cannot be nullptr!");
825 getObject()->is64Bit() \
826 ? reinterpret_cast<const XCOFFSymbolEntry64 *>(getRawDataRefImpl().p)->X \
827 : reinterpret_cast<const XCOFFSymbolEntry32 *>(getRawDataRefImpl().p)->X
835 "This interface is for C_FILE only.");
836 return GETVALUE(CFileLanguageIdAndTypeId.LanguageId);
841 "This interface is for C_FILE only.");
842 return GETVALUE(CFileLanguageIdAndTypeId.CpuTypeId);
905 std::optional<SmallString<32>> ParmsType;
906 std::optional<uint32_t> TraceBackTableOffset;
907 std::optional<uint32_t> HandlerMask;
908 std::optional<uint32_t> NumOfCtlAnchors;
909 std::optional<SmallVector<uint32_t, 8>> ControlledStorageInfoDisp;
910 std::optional<StringRef> FunctionName;
911 std::optional<uint8_t> AllocaRegister;
912 std::optional<TBVectorExt> VecExt;
913 std::optional<uint8_t> ExtensionTable;
914 std::optional<uint64_t> EhInfoDisp;
917 bool Is64Bit =
false);
971 return TraceBackTableOffset;
975 return NumOfCtlAnchors;
977 const std::optional<SmallVector<uint32_t, 8>> &
979 return ControlledStorageInfoDisp;
985 return AllocaRegister;
987 const std::optional<TBVectorExt> &
getVectorExt()
const {
return VecExt; }
989 return ExtensionTable;
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static StringRef getSymbolName(SymbolKind SymKind)
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static bool isDebugSection(const SectionBase &Sec)
static FeatureBitset getFeatures(MCSubtargetInfo &STI, StringRef CPU, StringRef TuneCPU, StringRef FS, ArrayRef< StringRef > ProcNames, ArrayRef< SubtargetSubTypeKV > ProcDesc, ArrayRef< SubtargetFeatureKV > ProcFeatures)
static uint32_t getSectionFlags(const MachOObjectFile &O, DataRefImpl Sec)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
This file defines the SmallVector class.
static unsigned getSymbolSectionID(const ObjectFile &O, SymbolRef Sym)
static uint32_t getFlags(const Symbol *Sym)
static std::unique_ptr< PDBSymbol > getSymbolType(const PDBSymbol &Symbol)
static bool is64Bit(const char *name)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
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...
StringRef - Represent a constant reference to a string, i.e.
A table of densely packed, null-terminated strings indexed by offset.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
A range adaptor for a pair of iterators.
const SymbolicFile * getObject() const
DataRefImpl getRawDataRefImpl() const
This class is the base class for all object file types.
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.
SmallString< 32 > getVectorParmsInfo() const
uint8_t getNumberOfVectorParms() const
static Expected< TBVectorExt > create(StringRef TBvectorStrRef)
bool isVRSavedOnStack() const
uint8_t getNumberOfVRSaved() const
bool hasVMXInstruction() const
XCOFF::StorageMappingClass getStorageMappingClass() const
XCOFFCsectAuxRef(const XCOFFCsectAuxEnt32 *Entry32)
uint32_t getSectionOrLength32() const
uint16_t getStabSectNum32() const
uint32_t getParameterHashIndex() const
uint8_t getSymbolType() const
uintptr_t getEntryAddress() const
uint64_t getSectionOrLength() const
uint16_t getAlignmentLog2() const
XCOFFCsectAuxRef(const XCOFFCsectAuxEnt64 *Entry64)
uint32_t getStabInfoIndex32() const
uint64_t getSectionOrLength64() const
XCOFF::SymbolAuxType getAuxType64() const
uint16_t getTypeChkSectNum() const
uint8_t getSymbolAlignmentAndType() const
const void * getPointerToSymbolTable() const
static bool classof(const Binary *B)
uintptr_t getSymbolByIndex(uint32_t Idx) const
bool is64Bit() const override
uint64_t getSymbolSize(DataRefImpl Symb) const
Expected< XCOFFCsectAuxRef > getXCOFFCsectAuxRef() const
Expected< bool > isFunction() const
int16_t getSectionNumber() const
bool isCsectSymbol() const
const XCOFFSymbolEntry64 * getSymbol64() const
XCOFFSymbolRef(DataRefImpl SymEntDataRef, const XCOFFObjectFile *OwningObjectPtr)
const XCOFFSymbolEntry32 * getSymbol32() const
uint16_t getSymbolType() const
uint32_t getValue32() const
uint64_t getValue() const
Expected< StringRef > getName() const
uint8_t getCPUTypeIddForCFile() const
uint64_t getValue64() const
uint8_t getNumberOfAuxEntries() const
uintptr_t getEntryAddress() const
XCOFF::StorageClass getStorageClass() const
uint8_t getLanguageIdForCFile() const
This class provides methods to extract traceback table data from a buffer.
bool isOutOfLineEpilogOrPrologue() const
const std::optional< StringRef > & getFunctionName() const
const std::optional< uint64_t > & getEhInfoDisp() const
const std::optional< uint32_t > & getTraceBackTableOffset() const
uint8_t getNumOfGPRsSaved() const
bool hasTraceBackTableOffset() const
bool hasParmsOnStack() const
bool hasExtensionTable() const
const std::optional< SmallVector< uint32_t, 8 > > & getControlledStorageInfoDisp()
const std::optional< uint8_t > & getExtensionTable() const
const std::optional< SmallString< 32 > > & getParmsType() const
uint8_t getOnConditionDirective() const
uint8_t getLanguageID() const
uint8_t getNumOfFPRsSaved() const
bool isFloatingPointOperationLogOrAbortEnabled() const
uint8_t getNumberOfFPParms() const
bool isFuncNamePresent() const
const std::optional< uint32_t > & getNumOfCtlAnchors()
bool isAllocaUsed() const
bool isGlobalLinkage() const
const std::optional< uint32_t > & getHandlerMask() const
bool isInternalProcedure() const
bool hasControlledStorage() const
bool isInterruptHandler() const
const std::optional< TBVectorExt > & getVectorExt() 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
const std::optional< uint8_t > & getAllocaRegister() const
uint8_t getNumberOfFixedParms() const
bool hasVectorInfo() const
const SymbolRef * operator->() const
const SymbolRef & operator*() const
const XCOFFSymbolRef * operator->() const
const XCOFFSymbolRef & operator*() const
xcoff_symbol_iterator(const XCOFFSymbolRef *Symbol)
xcoff_symbol_iterator(const basic_symbol_iterator &B)
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
constexpr size_t NameSize
StorageMappingClass
Storage Mapping Class definitions.
constexpr size_t SymbolTableEntrySize
constexpr size_t FileNamePadSize
@ XTY_LD
Label definition.
static constexpr const StringLiteral & getSectionName(DebugSectionKind SectionKind)
Return the name of the section.
bool doesXCOFFTracebackTableBegin(ArrayRef< uint8_t > Bytes)
ExceptionSectionEntry< support::ubig64_t > ExceptionSectionEntry64
ExceptionSectionEntry< support::ubig32_t > ExceptionSectionEntry32
This is an optimization pass for GlobalISel generic memory operations.
@ Ref
The access may reference the value stored in memory.
support::ubig32_t SymbolIdx
uint8_t getReason() const
uint64_t getTrapInstAddr() const
uint8_t getLangID() const
uint32_t getSymbolIndex() const
support::big32_t SymbolIndex
support::ubig32_t VirtualAddr
support::big16_t SectionNum
support::ubig64_t VirtualAddr
support::big16_t SectionNum
support::big32_t SymbolIndex
support::big32_t IsNameInStrTbl
XCOFF::StorageClass StorageClass
support::big16_t SectionNumber
support::ubig32_t ParameterTypeCheck
support::ubig32_t ImportFileID
support::ubig32_t ParameterTypeCheck
XCOFF::StorageClass StorageClass
support::big16_t SectionNumber
support::ubig32_t ImportFileID
uint8_t ReservedZeros1[2]
support::ubig16_t LineNumLo
support::ubig16_t LineNumHi
uint8_t ReservedZeros2[12]
XCOFF::SymbolAuxType AuxType
support::ubig32_t LineNum
support::ubig16_t TypeChkSectNum
support::ubig16_t StabSectNum
support::ubig32_t ParameterHashIndex
support::ubig32_t SectionOrLength
support::ubig32_t StabInfoIndex
XCOFF::StorageMappingClass StorageMappingClass
uint8_t SymbolAlignmentAndType
XCOFF::StorageMappingClass StorageMappingClass
support::ubig32_t SectionOrLengthLowByte
support::ubig16_t TypeChkSectNum
support::ubig32_t SectionOrLengthHighByte
support::ubig32_t ParameterHashIndex
uint8_t SymbolAlignmentAndType
XCOFF::SymbolAuxType AuxType
support::ubig32_t SizeOfFunction
support::big32_t SymIdxOfNextBeyond
support::ubig64_t OffsetToExceptionTbl
XCOFF::SymbolAuxType AuxType
NameInStrTblType NameInStrTbl
XCOFF::SymbolAuxType AuxType
XCOFF::CFileStringType Type
char Name[XCOFF::NameSize+XCOFF::FileNamePadSize]
support::ubig32_t SizeOfFunction
support::ubig32_t PtrToLineNum
support::ubig32_t OffsetToExceptionTbl
support::big32_t SymIdxOfNextBeyond
support::big32_t SymIdxOfNextBeyond
support::ubig64_t PtrToLineNum
XCOFF::SymbolAuxType AuxType
support::ubig32_t SizeOfFunction
XCOFF::RelocationType Type
AddressType VirtualAddress
bool isFixupIndicated() const
support::ubig32_t SymbolIndex
uint8_t getRelocatedLength() const
bool isRelocationSigned() const
support::ubig32_t LengthOfSectionPortion
support::ubig32_t NumberOfRelocEnt
XCOFF::SymbolAuxType AuxType
support::ubig64_t LengthOfSectionPortion
support::ubig64_t NumberOfRelocEnt
support::ubig32_t SectionLength
support::ubig16_t NumberOfLineNum
support::ubig16_t NumberOfRelocEnt
uint8_t NumberOfAuxEntries
support::ubig16_t SymbolType
CFileLanguageIdAndTypeIdType CFileLanguageIdAndTypeId
XCOFF::StorageClass StorageClass
NameInStrTblType NameInStrTbl
char SymbolName[XCOFF::NameSize]
support::big16_t SectionNumber
support::big16_t SectionNumber
uint8_t NumberOfAuxEntries
support::ubig16_t SymbolType
CFileLanguageIdAndTypeIdType CFileLanguageIdAndTypeId
XCOFF::StorageClass StorageClass