LLVM 20.0.0git
XCOFFObjectFile.h
Go to the documentation of this file.
1//===- XCOFFObjectFile.h - XCOFF object file implementation -----*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares the XCOFFObjectFile class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_OBJECT_XCOFFOBJECTFILE_H
14#define LLVM_OBJECT_XCOFFOBJECTFILE_H
15
22#include "llvm/Support/Endian.h"
23#include <limits>
24
25namespace llvm {
26namespace object {
27
28class xcoff_symbol_iterator;
29
33
34 // Unix time value, value of 0 indicates no timestamp.
35 // Negative values are reserved.
37
38 support::ubig32_t SymbolTableOffset; // File offset to symbol table.
42};
43
47
48 // Unix time value, value of 0 indicates no timestamp.
49 // Negative values are reserved.
51
52 support::ubig64_t SymbolTableOffset; // File offset to symbol table.
56};
57
58template <typename T> struct XCOFFAuxiliaryHeader {
59 static constexpr uint8_t AuxiHeaderFlagMask = 0xF0;
60 static constexpr uint8_t AuxiHeaderTDataAlignmentMask = 0x0F;
61
62public:
63 uint8_t getFlag() const {
64 return static_cast<const T *>(this)->FlagAndTDataAlignment &
66 }
67
69 return static_cast<const T *>(this)->FlagAndTDataAlignment &
71 }
72
73 uint16_t getVersion() const { return static_cast<const T *>(this)->Version; }
75 return static_cast<const T *>(this)->EntryPointAddr;
76 }
77};
78
79struct XCOFFAuxiliaryHeader32 : XCOFFAuxiliaryHeader<XCOFFAuxiliaryHeader32> {
81 AuxMagic; ///< If the value of the o_vstamp field is greater than 1, the
82 ///< o_mflags field is reserved for future use and it should
83 ///< contain 0. Otherwise, this field is not used.
85 Version; ///< The valid values are 1 and 2. When the o_vstamp field is 2
86 ///< in an XCOFF32 file, the new interpretation of the n_type
87 ///< field in the symbol table entry is used.
106 support::ubig32_t MaxStackSize; ///< If the value is 0, the system default
107 ///< maximum stack size is used.
108 support::ubig32_t MaxDataSize; ///< If the value is 0, the system default
109 ///< maximum data size is used.
111 ReservedForDebugger; ///< This field should contain 0. When a loaded
112 ///< program is being debugged, the memory image of
113 ///< this field may be modified by a debugger to
114 ///< insert a trap instruction.
115 uint8_t TextPageSize; ///< Specifies the size of pages for the exec text. The
116 ///< default value is 0 (system-selected page size).
117 uint8_t DataPageSize; ///< Specifies the size of pages for the exec data. The
118 ///< default value is 0 (system-selected page size).
119 uint8_t StackPageSize; ///< Specifies the size of pages for the stack. The
120 ///< default value is 0 (system-selected page size).
124};
125
126struct XCOFFAuxiliaryHeader64 : XCOFFAuxiliaryHeader<XCOFFAuxiliaryHeader64> {
157};
158
159template <typename T> struct XCOFFSectionHeader {
160 // The section flags definitions are the same in both 32- and 64-bit objects.
161 // Least significant 3 bits are reserved.
162 static constexpr unsigned SectionFlagsReservedMask = 0x7;
163
164 // The low order 16 bits of section flags denotes the section type.
165 // The high order 16 bits of section flags denotes the section subtype.
166 // For now, this is only used for DWARF sections.
167 static constexpr unsigned SectionFlagsTypeMask = 0xffffu;
168
169public:
170 StringRef getName() const;
171 uint16_t getSectionType() const;
173 bool isReservedSectionType() const;
174};
175
176// Explicit extern template declarations.
179extern template struct XCOFFSectionHeader<XCOFFSectionHeader32>;
180extern template struct XCOFFSectionHeader<XCOFFSectionHeader64>;
181
193};
194
206 char Padding[4];
207};
208
213 support::big32_t IsNameInStrTbl; // Zero indicates name in string table.
215 };
216
217 char SymbolName[XCOFF::NameSize];
218 support::ubig32_t Value; // The virtual address of the symbol.
224
226 getSymbolName(const LoaderSectionHeader32 *LoaderSecHeader) const;
227};
228
230 support::ubig64_t Value; // The virtual address of the symbol.
237
239 getSymbolName(const LoaderSectionHeader64 *LoaderSecHeader) const;
240};
241
247};
248
254};
255
265
267 return NumberOfSymTabEnt == 0 ? 0 : sizeof(LoaderSectionHeader32);
268 }
269
271 // Relocation table is after Symbol table.
272 return NumberOfRelTabEnt == 0
273 ? 0
274 : sizeof(LoaderSectionHeader32) +
275 sizeof(LoaderSectionSymbolEntry32) * NumberOfSymTabEnt;
276 }
277};
278
290
291 uint64_t getOffsetToSymTbl() const { return OffsetToSymTbl; }
292 uint64_t getOffsetToRelEnt() const { return OffsetToRelEnt; }
293};
294
295template <typename AddressType> struct ExceptionSectionEntry {
296 union {
298 AddressType TrapInstAddr;
299 };
302
304 assert(Reason == 0 && "Get symbol table index of the function only when "
305 "the e_reason field is 0.");
306 return SymbolIdx;
307 }
308
310 assert(Reason != 0 && "Zero is not a valid trap exception reason code.");
311 return TrapInstAddr;
312 }
313 uint8_t getLangID() const { return LangId; }
314 uint8_t getReason() const { return Reason; }
315};
316
319
320// Explicit extern template declarations.
321extern template struct ExceptionSectionEntry<support::ubig32_t>;
322extern template struct ExceptionSectionEntry<support::ubig64_t>;
323
326 const char *Data;
327};
328
337};
338
348};
349
351public:
352 static constexpr uint8_t SymbolTypeMask = 0x07;
353 static constexpr uint8_t SymbolAlignmentMask = 0xF8;
354 static constexpr size_t SymbolAlignmentBitOffset = 3;
355
356 XCOFFCsectAuxRef(const XCOFFCsectAuxEnt32 *Entry32) : Entry32(Entry32) {}
357 XCOFFCsectAuxRef(const XCOFFCsectAuxEnt64 *Entry64) : Entry64(Entry64) {}
358
359 // For getSectionOrLength(),
360 // If the symbol type is XTY_SD or XTY_CM, the csect length.
361 // If the symbol type is XTY_LD, the symbol table
362 // index of the containing csect.
363 // If the symbol type is XTY_ER, 0.
365 return Entry32 ? getSectionOrLength32() : getSectionOrLength64();
366 }
367
369 assert(Entry32 && "32-bit interface called on 64-bit object file.");
370 return Entry32->SectionOrLength;
371 }
372
374 assert(Entry64 && "64-bit interface called on 32-bit object file.");
375 return (static_cast<uint64_t>(Entry64->SectionOrLengthHighByte) << 32) |
376 Entry64->SectionOrLengthLowByte;
377 }
378
379#define GETVALUE(X) Entry32 ? Entry32->X : Entry64->X
380
382 return GETVALUE(ParameterHashIndex);
383 }
384
385 uint16_t getTypeChkSectNum() const { return GETVALUE(TypeChkSectNum); }
386
389 }
390
391 uintptr_t getEntryAddress() const {
392 return Entry32 ? reinterpret_cast<uintptr_t>(Entry32)
393 : reinterpret_cast<uintptr_t>(Entry64);
394 }
395
397 return (getSymbolAlignmentAndType() & SymbolAlignmentMask) >>
398 SymbolAlignmentBitOffset;
399 }
400
402 return getSymbolAlignmentAndType() & SymbolTypeMask;
403 }
404
405 bool isLabel() const { return getSymbolType() == XCOFF::XTY_LD; }
406
408 assert(Entry32 && "32-bit interface called on 64-bit object file.");
409 return Entry32->StabInfoIndex;
410 }
411
413 assert(Entry32 && "32-bit interface called on 64-bit object file.");
414 return Entry32->StabSectNum;
415 }
416
418 assert(Entry64 && "64-bit interface called on 32-bit object file.");
419 return Entry64->AuxType;
420 }
421
423 return GETVALUE(SymbolAlignmentAndType);
424 }
425
426#undef GETVALUE
427
428private:
429 const XCOFFCsectAuxEnt32 *Entry32 = nullptr;
430 const XCOFFCsectAuxEnt64 *Entry64 = nullptr;
431};
432
434 typedef struct {
435 support::big32_t Magic; // Zero indicates name in string table.
439 union {
442 };
445 XCOFF::SymbolAuxType AuxType; // 64-bit XCOFF file only.
446};
447
453}; // 32-bit XCOFF file only.
454
461};
462
468 XCOFF::SymbolAuxType AuxType; // Contains _AUX_FCN; Type of auxiliary entry
469};
470
476 XCOFF::SymbolAuxType AuxType; // Contains _AUX_EXCEPT; Type of auxiliary entry
477};
478
484};
485
489 XCOFF::SymbolAuxType AuxType; // Contains _AUX_SYM; Type of auxiliary entry
490};
491
497};
498
503 XCOFF::SymbolAuxType AuxType; // Contains _AUX_SECT; Type of Auxillary entry
504};
505
506template <typename AddressType> struct XCOFFRelocation {
507public:
508 AddressType VirtualAddress;
510
511 // Packed field, see XR_* masks for details of packing.
513
515
516public:
517 bool isRelocationSigned() const;
518 bool isFixupIndicated() const;
519
520 // Returns the number of bits being relocated.
522};
523
524extern template struct XCOFFRelocation<llvm::support::ubig32_t>;
525extern template struct XCOFFRelocation<llvm::support::ubig64_t>;
526
529
530class XCOFFSymbolRef;
531
533private:
534 const void *FileHeader = nullptr;
535 const void *AuxiliaryHeader = nullptr;
536 const void *SectionHeaderTable = nullptr;
537
538 const void *SymbolTblPtr = nullptr;
539 XCOFFStringTable StringTable = {0, nullptr};
540
541 const XCOFFSectionHeader32 *sectionHeaderTable32() const;
542 const XCOFFSectionHeader64 *sectionHeaderTable64() const;
543 template <typename T> const T *sectionHeaderTable() const;
544
545 size_t getFileHeaderSize() const;
546 size_t getSectionHeaderSize() const;
547
548 const XCOFFSectionHeader32 *toSection32(DataRefImpl Ref) const;
549 const XCOFFSectionHeader64 *toSection64(DataRefImpl Ref) const;
550 uintptr_t getSectionHeaderTableAddress() const;
551 uintptr_t getEndOfSymbolTableAddress() const;
552
553 DataRefImpl getSectionByType(XCOFF::SectionTypeFlags SectType) const;
554 uint64_t getSectionFileOffsetToRawData(DataRefImpl Sec) const;
555
556 // This returns a pointer to the start of the storage for the name field of
557 // the 32-bit or 64-bit SectionHeader struct. This string is *not* necessarily
558 // null-terminated.
559 const char *getSectionNameInternal(DataRefImpl Sec) const;
560
561 static bool isReservedSectionNumber(int16_t SectionNumber);
562
563 // Constructor and "create" factory function. The constructor is only a thin
564 // wrapper around the base constructor. The "create" function fills out the
565 // XCOFF-specific information and performs the error checking along the way.
566 XCOFFObjectFile(unsigned Type, MemoryBufferRef Object);
567 static Expected<std::unique_ptr<XCOFFObjectFile>> create(unsigned Type,
568 MemoryBufferRef MBR);
569
570 // Helper for parsing the StringTable. Returns an 'Error' if parsing failed
571 // and an XCOFFStringTable if parsing succeeded.
572 static Expected<XCOFFStringTable> parseStringTable(const XCOFFObjectFile *Obj,
574
575 // Make a friend so it can call the private 'create' function.
578
579 void checkSectionAddress(uintptr_t Addr, uintptr_t TableAddr) const;
580
581public:
582 static constexpr uint64_t InvalidRelocOffset =
583 std::numeric_limits<uint64_t>::max();
584
585 // Interface inherited from base classes.
586 void moveSymbolNext(DataRefImpl &Symb) const override;
587 Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override;
588 basic_symbol_iterator symbol_begin() const override;
589 basic_symbol_iterator symbol_end() const override;
590
592 xcoff_symbol_iterator_range symbols() const;
593
594 bool is64Bit() const override;
595 Expected<StringRef> getSymbolName(DataRefImpl Symb) const override;
596 Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const override;
597 uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
598 uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
599 uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
601 Expected<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
602
603 void moveSectionNext(DataRefImpl &Sec) const override;
605 uint64_t getSectionAddress(DataRefImpl Sec) const override;
606 uint64_t getSectionIndex(DataRefImpl Sec) const override;
607 uint64_t getSectionSize(DataRefImpl Sec) const override;
609 getSectionContents(DataRefImpl Sec) const override;
610 uint64_t getSectionAlignment(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;
614 bool isSectionBSS(DataRefImpl Sec) const override;
615 bool isDebugSection(DataRefImpl Sec) const override;
616
617 bool isSectionVirtual(DataRefImpl Sec) const override;
618 relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
619 relocation_iterator section_rel_end(DataRefImpl Sec) const override;
620
621 void moveRelocationNext(DataRefImpl &Rel) const override;
622
623 /// \returns the relocation offset with the base address of the containing
624 /// section as zero, or InvalidRelocOffset on errors (such as a relocation
625 /// that does not refer to an address in any section).
626 uint64_t getRelocationOffset(DataRefImpl Rel) const override;
627 symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
628 uint64_t getRelocationType(DataRefImpl Rel) const override;
629 void getRelocationTypeName(DataRefImpl Rel,
630 SmallVectorImpl<char> &Result) const override;
631
632 section_iterator section_begin() const override;
633 section_iterator section_end() const override;
634 uint8_t getBytesInAddress() const override;
635 StringRef getFileFormatName() const override;
636 Triple::ArchType getArch() const override;
638 Expected<uint64_t> getStartAddress() const override;
639 StringRef mapDebugSectionName(StringRef Name) const override;
640 bool isRelocatableObject() const override;
641
642 // Below here is the non-inherited interface.
643
644 Expected<StringRef> getRawData(const char *Start, uint64_t Size,
645 StringRef Name) const;
646
647 const XCOFFAuxiliaryHeader32 *auxiliaryHeader32() const;
648 const XCOFFAuxiliaryHeader64 *auxiliaryHeader64() const;
649
650 const void *getPointerToSymbolTable() const { return SymbolTblPtr; }
651
652 Expected<StringRef> getSymbolSectionName(XCOFFSymbolRef Ref) const;
653 unsigned getSymbolSectionID(SymbolRef Sym) const;
654 XCOFFSymbolRef toSymbolRef(DataRefImpl Ref) const;
655
656 // File header related interfaces.
657 const XCOFFFileHeader32 *fileHeader32() const;
658 const XCOFFFileHeader64 *fileHeader64() const;
659 uint16_t getMagic() const;
660 uint16_t getNumberOfSections() const;
661 int32_t getTimeStamp() const;
662
663 // Symbol table offset and entry count are handled differently between
664 // XCOFF32 and XCOFF64.
665 uint32_t getSymbolTableOffset32() const;
666 uint64_t getSymbolTableOffset64() const;
667
668 // Note that this value is signed and might return a negative value. Negative
669 // values are reserved for future use.
670 int32_t getRawNumberOfSymbolTableEntries32() const;
671
672 // The sanitized value appropriate to use as an index into the symbol table.
673 uint32_t getLogicalNumberOfSymbolTableEntries32() const;
674
675 uint32_t getNumberOfSymbolTableEntries64() const;
676
677 // Return getLogicalNumberOfSymbolTableEntries32 or
678 // getNumberOfSymbolTableEntries64 depending on the object mode.
679 uint32_t getNumberOfSymbolTableEntries() const;
680
681 uint32_t getSymbolIndex(uintptr_t SymEntPtr) const;
682 uint64_t getSymbolSize(DataRefImpl Symb) const;
683 uintptr_t getSymbolByIndex(uint32_t Idx) const {
684 return reinterpret_cast<uintptr_t>(SymbolTblPtr) +
686 }
687 uintptr_t getSymbolEntryAddressByIndex(uint32_t SymbolTableIndex) const;
688 Expected<StringRef> getSymbolNameByIndex(uint32_t SymbolTableIndex) const;
689
690 Expected<StringRef> getCFileName(const XCOFFFileAuxEnt *CFileEntPtr) const;
691 uint16_t getOptionalHeaderSize() const;
692 uint16_t getFlags() const;
693
694 // Section header table related interfaces.
695 ArrayRef<XCOFFSectionHeader32> sections32() const;
696 ArrayRef<XCOFFSectionHeader64> sections64() const;
697
698 int32_t getSectionFlags(DataRefImpl Sec) const;
699 Expected<DataRefImpl> getSectionByNum(int16_t Num) const;
700
702 getSectionFileOffsetToRawData(XCOFF::SectionTypeFlags SectType) const;
703
704 void checkSymbolEntryPointer(uintptr_t SymbolEntPtr) const;
705
706 // Relocation-related interfaces.
707 template <typename T>
709 getNumberOfRelocationEntries(const XCOFFSectionHeader<T> &Sec) const;
710
711 template <typename Shdr, typename Reloc>
712 Expected<ArrayRef<Reloc>> relocations(const Shdr &Sec) const;
713
714 // Loader section related interfaces.
715 Expected<StringRef> getImportFileTable() const;
716
717 // Exception-related interface.
718 template <typename ExceptEnt>
719 Expected<ArrayRef<ExceptEnt>> getExceptionEntries() const;
720
721 // This function returns string table entry.
722 Expected<StringRef> getStringTableEntry(uint32_t Offset) const;
723
724 // This function returns the string table.
725 StringRef getStringTable() const;
726
727 const XCOFF::SymbolAuxType *getSymbolAuxType(uintptr_t AuxEntryAddress) const;
728
729 static uintptr_t getAdvancedSymbolEntryAddress(uintptr_t CurrentAddress,
730 uint32_t Distance);
731
732 static bool classof(const Binary *B) { return B->isXCOFF(); }
733
734 std::optional<StringRef> tryGetCPUName() const override;
735}; // XCOFFObjectFile
736
737typedef struct {
741
743 typedef struct {
744 support::big32_t Magic; // Zero indicates name in string table.
747
748 union {
751 };
752
753 support::ubig32_t Value; // Symbol value; storage class-dependent.
755
756 union {
759 };
760
763};
764
766 support::ubig64_t Value; // Symbol value; storage class-dependent.
769
770 union {
773 };
774
777};
778
779extern template LLVM_TEMPLATE_ABI Expected<ArrayRef<XCOFFRelocation32>>
780XCOFFObjectFile::relocations<XCOFFSectionHeader32, XCOFFRelocation32>(
781 const XCOFFSectionHeader32 &Sec) const;
782extern template LLVM_TEMPLATE_ABI Expected<ArrayRef<XCOFFRelocation64>>
783XCOFFObjectFile::relocations<XCOFFSectionHeader64, XCOFFRelocation64>(
784 const XCOFFSectionHeader64 &Sec) const;
785
786class XCOFFSymbolRef : public SymbolRef {
787public:
788 enum { NAME_IN_STR_TBL_MAGIC = 0x0 };
789
791 const XCOFFObjectFile *OwningObjectPtr)
792 : SymbolRef(SymEntDataRef, OwningObjectPtr) {
793 assert(OwningObjectPtr && "OwningObjectPtr cannot be nullptr!");
794 assert(SymEntDataRef.p != 0 &&
795 "Symbol table entry pointer cannot be nullptr!");
796 }
797
799 return reinterpret_cast<const XCOFFSymbolEntry32 *>(getRawDataRefImpl().p);
800 }
801
803 return reinterpret_cast<const XCOFFSymbolEntry64 *>(getRawDataRefImpl().p);
804 }
805
807 return getObject()->is64Bit() ? getValue64() : getValue32();
808 }
809
811 return reinterpret_cast<const XCOFFSymbolEntry32 *>(getRawDataRefImpl().p)
812 ->Value;
813 }
814
816 return reinterpret_cast<const XCOFFSymbolEntry64 *>(getRawDataRefImpl().p)
817 ->Value;
818 }
819
821 return getObject()->getSymbolSize(getRawDataRefImpl());
822 }
823
824#define GETVALUE(X) \
825 getObject()->is64Bit() \
826 ? reinterpret_cast<const XCOFFSymbolEntry64 *>(getRawDataRefImpl().p)->X \
827 : reinterpret_cast<const XCOFFSymbolEntry32 *>(getRawDataRefImpl().p)->X
828
829 int16_t getSectionNumber() const { return GETVALUE(SectionNumber); }
830
832
835 "This interface is for C_FILE only.");
836 return GETVALUE(CFileLanguageIdAndTypeId.LanguageId);
837 }
838
841 "This interface is for C_FILE only.");
842 return GETVALUE(CFileLanguageIdAndTypeId.CpuTypeId);
843 }
844
846
847 uint8_t getNumberOfAuxEntries() const { return GETVALUE(NumberOfAuxEntries); }
848
849#undef GETVALUE
850
851 uintptr_t getEntryAddress() const {
852 return getRawDataRefImpl().p;
853 }
854
857 bool isCsectSymbol() const;
859
860private:
861 const XCOFFObjectFile *getObject() const {
862 return cast<XCOFFObjectFile>(BasicSymbolRef::getObject());
863 }
864};
865
867public:
869 : symbol_iterator(B) {}
870
872 : symbol_iterator(*Symbol) {}
873
874 const XCOFFSymbolRef *operator->() const {
875 return static_cast<const XCOFFSymbolRef *>(symbol_iterator::operator->());
876 }
877
878 const XCOFFSymbolRef &operator*() const {
879 return static_cast<const XCOFFSymbolRef &>(symbol_iterator::operator*());
880 }
881};
882
884 uint16_t Data;
885 SmallString<32> VecParmsInfo;
886
887 TBVectorExt(StringRef TBvectorStrRef, Error &Err);
888
889public:
890 static Expected<TBVectorExt> create(StringRef TBvectorStrRef);
892 bool isVRSavedOnStack() const;
893 bool hasVarArgs() const;
895 bool hasVMXInstruction() const;
896 SmallString<32> getVectorParmsInfo() const { return VecParmsInfo; };
897};
898
899/// This class provides methods to extract traceback table data from a buffer.
900/// The various accessors may reference the buffer provided via the constructor.
901
903 const uint8_t *const TBPtr;
904 bool Is64BitObj;
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;
915
917 bool Is64Bit = false);
918
919public:
920 /// Parse an XCOFF Traceback Table from \a Ptr with \a Size bytes.
921 /// Returns an XCOFFTracebackTable upon successful parsing, otherwise an
922 /// Error is returned.
923 ///
924 /// \param[in] Ptr
925 /// A pointer that points just past the initial 4 bytes of zeros at the
926 /// beginning of an XCOFF Traceback Table.
927 ///
928 /// \param[in, out] Size
929 /// A pointer that points to the length of the XCOFF Traceback Table.
930 /// If the XCOFF Traceback Table is not parsed successfully or there are
931 /// extra bytes that are not recognized, \a Size will be updated to be the
932 /// size up to the end of the last successfully parsed field of the table.
934 create(const uint8_t *Ptr, uint64_t &Size, bool Is64Bits = false);
935 uint8_t getVersion() const;
936 uint8_t getLanguageID() const;
937
938 bool isGlobalLinkage() const;
939 bool isOutOfLineEpilogOrPrologue() const;
940 bool hasTraceBackTableOffset() const;
941 bool isInternalProcedure() const;
942 bool hasControlledStorage() const;
943 bool isTOCless() const;
944 bool isFloatingPointPresent() const;
946
947 bool isInterruptHandler() const;
948 bool isFuncNamePresent() const;
949 bool isAllocaUsed() const;
951 bool isCRSaved() const;
952 bool isLRSaved() const;
953
954 bool isBackChainStored() const;
955 bool isFixup() const;
957
958 bool hasVectorInfo() const;
959 bool hasExtensionTable() const;
961
963
965 bool hasParmsOnStack() const;
966
967 const std::optional<SmallString<32>> &getParmsType() const {
968 return ParmsType;
969 }
970 const std::optional<uint32_t> &getTraceBackTableOffset() const {
971 return TraceBackTableOffset;
972 }
973 const std::optional<uint32_t> &getHandlerMask() const { return HandlerMask; }
974 const std::optional<uint32_t> &getNumOfCtlAnchors() {
975 return NumOfCtlAnchors;
976 }
977 const std::optional<SmallVector<uint32_t, 8>> &
979 return ControlledStorageInfoDisp;
980 }
981 const std::optional<StringRef> &getFunctionName() const {
982 return FunctionName;
983 }
984 const std::optional<uint8_t> &getAllocaRegister() const {
985 return AllocaRegister;
986 }
987 const std::optional<TBVectorExt> &getVectorExt() const { return VecExt; }
988 const std::optional<uint8_t> &getExtensionTable() const {
989 return ExtensionTable;
990 }
991 const std::optional<uint64_t> &getEhInfoDisp() const { return EhInfoDisp; }
992};
993
995} // namespace object
996} // namespace llvm
997
998#endif // LLVM_OBJECT_XCOFFOBJECTFILE_H
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
Elf_Shdr Shdr
uint64_t Addr
std::string Name
uint64_t Size
static bool isDebugSection(const SectionBase &Sec)
Definition: ELFObjcopy.cpp:49
Symbol * Sym
Definition: ELF_riscv.cpp:479
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)
Definition: SymbolSize.cpp:39
static uint32_t getFlags(const Symbol *Sym)
Definition: TapiFile.cpp:26
static std::unique_ptr< PDBSymbol > getSymbolType(const PDBSymbol &Symbol)
Definition: UDTLayout.cpp:36
static bool is64Bit(const char *name)
#define GETVALUE(X)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
Tagged union holding either a T or a Error.
Definition: Error.h:481
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:573
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
A table of densely packed, null-terminated strings indexed by offset.
Definition: StringTable.h:31
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM Value Representation.
Definition: Value.h:74
A range adaptor for a pair of iterators.
const SymbolicFile * getObject() const
Definition: SymbolicFile.h:214
DataRefImpl getRawDataRefImpl() const
Definition: SymbolicFile.h:210
This class is the base class for all object file types.
Definition: ObjectFile.h:229
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.
Definition: ObjectFile.h:168
SmallString< 32 > getVectorParmsInfo() const
uint8_t getNumberOfVectorParms() const
static Expected< TBVectorExt > create(StringRef TBvectorStrRef)
uint8_t getNumberOfVRSaved() const
XCOFF::StorageMappingClass getStorageMappingClass() const
XCOFFCsectAuxRef(const XCOFFCsectAuxEnt32 *Entry32)
uint32_t getSectionOrLength32() const
uint32_t getParameterHashIndex() const
XCOFFCsectAuxRef(const XCOFFCsectAuxEnt64 *Entry64)
uint64_t getSectionOrLength64() const
XCOFF::SymbolAuxType getAuxType64() 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
const XCOFFSymbolEntry64 * getSymbol64() const
XCOFFSymbolRef(DataRefImpl SymEntDataRef, const XCOFFObjectFile *OwningObjectPtr)
const XCOFFSymbolEntry32 * getSymbol32() const
Expected< StringRef > getName() const
uint8_t getCPUTypeIddForCFile() 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.
const std::optional< StringRef > & getFunctionName() const
const std::optional< uint64_t > & getEhInfoDisp() const
const std::optional< uint32_t > & getTraceBackTableOffset() const
const std::optional< SmallVector< uint32_t, 8 > > & getControlledStorageInfoDisp()
const std::optional< uint8_t > & getExtensionTable() const
const std::optional< SmallString< 32 > > & getParmsType() const
const std::optional< uint32_t > & getNumOfCtlAnchors()
const std::optional< uint32_t > & getHandlerMask() const
const std::optional< TBVectorExt > & getVectorExt() 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.
const std::optional< uint8_t > & getAllocaRegister() const
const SymbolRef * operator->() const
Definition: ObjectFile.h:215
const SymbolRef & operator*() const
Definition: ObjectFile.h:220
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.
SymbolAuxType
Definition: XCOFF.h:365
RelocationType
Definition: XCOFF.h:262
constexpr size_t NameSize
Definition: XCOFF.h:29
CFileStringType
Definition: XCOFF.h:323
StorageClass
Definition: XCOFF.h:170
@ C_FILE
Definition: XCOFF.h:172
StorageMappingClass
Storage Mapping Class definitions.
Definition: XCOFF.h:103
constexpr size_t SymbolTableEntrySize
Definition: XCOFF.h:38
constexpr size_t FileNamePadSize
Definition: XCOFF.h:28
@ XTY_LD
Label definition.
Definition: XCOFF.h:243
SectionTypeFlags
Definition: XCOFF.h:134
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.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:480
@ Ref
The access may reference the value stored in memory.
support::ubig32_t MaxStackSize
If the value is 0, the system default maximum stack size is used.
support::ubig16_t AuxMagic
If the value of the o_vstamp field is greater than 1, the o_mflags field is reserved for future use a...
uint8_t TextPageSize
Specifies the size of pages for the exec text.
uint8_t StackPageSize
Specifies the size of pages for the stack.
support::ubig32_t ReservedForDebugger
This field should contain 0.
support::ubig16_t Version
The valid values are 1 and 2.
uint8_t DataPageSize
Specifies the size of pages for the exec data.
support::ubig32_t MaxDataSize
If the value is 0, the system default maximum data size is used.
static constexpr uint8_t AuxiHeaderTDataAlignmentMask
static constexpr uint8_t AuxiHeaderFlagMask
XCOFF::StorageMappingClass StorageMappingClass
XCOFF::StorageMappingClass StorageMappingClass
support::ubig32_t SectionOrLengthLowByte
support::ubig32_t SectionOrLengthHighByte
XCOFF::SymbolAuxType AuxType
XCOFF::CFileStringType Type
char Name[XCOFF::NameSize+XCOFF::FileNamePadSize]
support::big32_t NumberOfSymTableEntries
support::ubig16_t NumberOfSections
support::ubig32_t SymbolTableOffset
support::ubig64_t SymbolTableOffset
support::ubig32_t NumberOfSymTableEntries
support::ubig16_t NumberOfSections
XCOFF::RelocationType Type
support::ubig32_t FileOffsetToLineNumberInfo
support::ubig32_t FileOffsetToRelocationInfo
static constexpr unsigned SectionFlagsReservedMask
static constexpr unsigned SectionFlagsTypeMask
CFileLanguageIdAndTypeIdType CFileLanguageIdAndTypeId
char SymbolName[XCOFF::NameSize]
CFileLanguageIdAndTypeIdType CFileLanguageIdAndTypeId