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 16 #include "llvm/ADT/SmallString.h" 17 #include "llvm/ADT/SmallVector.h" 18 #include "llvm/BinaryFormat/XCOFF.h" 19 #include "llvm/Object/ObjectFile.h" 20 #include "llvm/Support/Endian.h" 21 #include <limits> 22 23 namespace llvm { 24 namespace object { 25 26 struct XCOFFFileHeader32 { 27 support::ubig16_t Magic; 28 support::ubig16_t NumberOfSections; 29 30 // Unix time value, value of 0 indicates no timestamp. 31 // Negative values are reserved. 32 support::big32_t TimeStamp; 33 34 support::ubig32_t SymbolTableOffset; // File offset to symbol table. 35 support::big32_t NumberOfSymTableEntries; 36 support::ubig16_t AuxHeaderSize; 37 support::ubig16_t Flags; 38 }; 39 40 struct XCOFFFileHeader64 { 41 support::ubig16_t Magic; 42 support::ubig16_t NumberOfSections; 43 44 // Unix time value, value of 0 indicates no timestamp. 45 // Negative values are reserved. 46 support::big32_t TimeStamp; 47 48 support::ubig64_t SymbolTableOffset; // File offset to symbol table. 49 support::ubig16_t AuxHeaderSize; 50 support::ubig16_t Flags; 51 support::ubig32_t NumberOfSymTableEntries; 52 }; 53 54 template <typename T> struct XCOFFSectionHeader { 55 // Least significant 3 bits are reserved. 56 static constexpr unsigned SectionFlagsReservedMask = 0x7; 57 58 // The low order 16 bits of section flags denotes the section type. 59 static constexpr unsigned SectionFlagsTypeMask = 0xffffu; 60 61 public: 62 StringRef getName() const; 63 uint16_t getSectionType() const; 64 bool isReservedSectionType() const; 65 }; 66 67 // Explicit extern template declarations. 68 struct XCOFFSectionHeader32; 69 struct XCOFFSectionHeader64; 70 extern template struct XCOFFSectionHeader<XCOFFSectionHeader32>; 71 extern template struct XCOFFSectionHeader<XCOFFSectionHeader64>; 72 73 struct XCOFFSectionHeader32 : XCOFFSectionHeader<XCOFFSectionHeader32> { 74 char Name[XCOFF::NameSize]; 75 support::ubig32_t PhysicalAddress; 76 support::ubig32_t VirtualAddress; 77 support::ubig32_t SectionSize; 78 support::ubig32_t FileOffsetToRawData; 79 support::ubig32_t FileOffsetToRelocationInfo; 80 support::ubig32_t FileOffsetToLineNumberInfo; 81 support::ubig16_t NumberOfRelocations; 82 support::ubig16_t NumberOfLineNumbers; 83 support::big32_t Flags; 84 }; 85 86 struct XCOFFSectionHeader64 : XCOFFSectionHeader<XCOFFSectionHeader64> { 87 char Name[XCOFF::NameSize]; 88 support::ubig64_t PhysicalAddress; 89 support::ubig64_t VirtualAddress; 90 support::ubig64_t SectionSize; 91 support::big64_t FileOffsetToRawData; 92 support::big64_t FileOffsetToRelocationInfo; 93 support::big64_t FileOffsetToLineNumberInfo; 94 support::ubig32_t NumberOfRelocations; 95 support::ubig32_t NumberOfLineNumbers; 96 support::big32_t Flags; 97 char Padding[4]; 98 }; 99 100 struct XCOFFStringTable { 101 uint32_t Size; 102 const char *Data; 103 }; 104 105 struct XCOFFCsectAuxEnt32 { 106 support::ubig32_t SectionOrLength; 107 support::ubig32_t ParameterHashIndex; 108 support::ubig16_t TypeChkSectNum; 109 uint8_t SymbolAlignmentAndType; 110 XCOFF::StorageMappingClass StorageMappingClass; 111 support::ubig32_t StabInfoIndex; 112 support::ubig16_t StabSectNum; 113 }; 114 115 struct XCOFFCsectAuxEnt64 { 116 support::ubig32_t SectionOrLengthLowByte; 117 support::ubig32_t ParameterHashIndex; 118 support::ubig16_t TypeChkSectNum; 119 uint8_t SymbolAlignmentAndType; 120 XCOFF::StorageMappingClass StorageMappingClass; 121 support::ubig32_t SectionOrLengthHighByte; 122 uint8_t Pad; 123 XCOFF::SymbolAuxType AuxType; 124 }; 125 126 class XCOFFCsectAuxRef { 127 public: 128 static constexpr uint8_t SymbolTypeMask = 0x07; 129 static constexpr uint8_t SymbolAlignmentMask = 0xF8; 130 static constexpr size_t SymbolAlignmentBitOffset = 3; 131 132 XCOFFCsectAuxRef(const XCOFFCsectAuxEnt32 *Entry32) : Entry32(Entry32) {} 133 XCOFFCsectAuxRef(const XCOFFCsectAuxEnt64 *Entry64) : Entry64(Entry64) {} 134 135 // For getSectionOrLength(), 136 // If the symbol type is XTY_SD or XTY_CM, the csect length. 137 // If the symbol type is XTY_LD, the symbol table 138 // index of the containing csect. 139 // If the symbol type is XTY_ER, 0. 140 uint64_t getSectionOrLength() const { 141 return Entry32 ? getSectionOrLength32() : getSectionOrLength64(); 142 } 143 144 uint32_t getSectionOrLength32() const { 145 assert(Entry32 && "32-bit interface called on 64-bit object file."); 146 return Entry32->SectionOrLength; 147 } 148 149 uint64_t getSectionOrLength64() const { 150 assert(Entry64 && "64-bit interface called on 32-bit object file."); 151 return (static_cast<uint64_t>(Entry64->SectionOrLengthHighByte) << 32) | 152 Entry64->SectionOrLengthLowByte; 153 } 154 155 #define GETVALUE(X) Entry32 ? Entry32->X : Entry64->X 156 157 uint32_t getParameterHashIndex() const { 158 return GETVALUE(ParameterHashIndex); 159 } 160 161 uint16_t getTypeChkSectNum() const { return GETVALUE(TypeChkSectNum); } 162 163 XCOFF::StorageMappingClass getStorageMappingClass() const { 164 return GETVALUE(StorageMappingClass); 165 } 166 167 uintptr_t getEntryAddress() const { 168 return Entry32 ? reinterpret_cast<uintptr_t>(Entry32) 169 : reinterpret_cast<uintptr_t>(Entry64); 170 } 171 172 uint16_t getAlignmentLog2() const { 173 return (getSymbolAlignmentAndType() & SymbolAlignmentMask) >> 174 SymbolAlignmentBitOffset; 175 } 176 177 uint8_t getSymbolType() const { 178 return getSymbolAlignmentAndType() & SymbolTypeMask; 179 } 180 181 bool isLabel() const { return getSymbolType() == XCOFF::XTY_LD; } 182 183 uint32_t getStabInfoIndex32() const { 184 assert(Entry32 && "32-bit interface called on 64-bit object file."); 185 return Entry32->StabInfoIndex; 186 } 187 188 uint16_t getStabSectNum32() const { 189 assert(Entry32 && "32-bit interface called on 64-bit object file."); 190 return Entry32->StabSectNum; 191 } 192 193 XCOFF::SymbolAuxType getAuxType64() const { 194 assert(Entry64 && "64-bit interface called on 32-bit object file."); 195 return Entry64->AuxType; 196 } 197 198 private: 199 uint8_t getSymbolAlignmentAndType() const { 200 return GETVALUE(SymbolAlignmentAndType); 201 } 202 203 #undef GETVALUE 204 205 const XCOFFCsectAuxEnt32 *Entry32 = nullptr; 206 const XCOFFCsectAuxEnt64 *Entry64 = nullptr; 207 }; 208 209 struct XCOFFFileAuxEnt { 210 typedef struct { 211 support::big32_t Magic; // Zero indicates name in string table. 212 support::ubig32_t Offset; 213 char NamePad[XCOFF::FileNamePadSize]; 214 } NameInStrTblType; 215 union { 216 char Name[XCOFF::NameSize + XCOFF::FileNamePadSize]; 217 NameInStrTblType NameInStrTbl; 218 }; 219 XCOFF::CFileStringType Type; 220 uint8_t ReservedZeros[2]; 221 XCOFF::SymbolAuxType AuxType; // 64-bit XCOFF file only. 222 }; 223 224 struct XCOFFSectAuxEntForStat { 225 support::ubig32_t SectionLength; 226 support::ubig16_t NumberOfRelocEnt; 227 support::ubig16_t NumberOfLineNum; 228 uint8_t Pad[10]; 229 }; // 32-bit XCOFF file only. 230 231 struct XCOFFRelocation32 { 232 // Masks for packing/unpacking the r_rsize field of relocations. 233 234 // The msb is used to indicate if the bits being relocated are signed or 235 // unsigned. 236 static constexpr uint8_t XR_SIGN_INDICATOR_MASK = 0x80; 237 238 // The 2nd msb is used to indicate that the binder has replaced/modified the 239 // original instruction. 240 static constexpr uint8_t XR_FIXUP_INDICATOR_MASK = 0x40; 241 242 // The remaining bits specify the bit length of the relocatable reference 243 // minus one. 244 static constexpr uint8_t XR_BIASED_LENGTH_MASK = 0x3f; 245 246 public: 247 support::ubig32_t VirtualAddress; 248 support::ubig32_t SymbolIndex; 249 250 // Packed field, see XR_* masks for details of packing. 251 uint8_t Info; 252 253 XCOFF::RelocationType Type; 254 255 public: 256 bool isRelocationSigned() const; 257 bool isFixupIndicated() const; 258 259 // Returns the number of bits being relocated. 260 uint8_t getRelocatedLength() const; 261 }; 262 263 class XCOFFSymbolRef; 264 265 class XCOFFObjectFile : public ObjectFile { 266 private: 267 const void *FileHeader = nullptr; 268 const void *SectionHeaderTable = nullptr; 269 270 const void *SymbolTblPtr = nullptr; 271 XCOFFStringTable StringTable = {0, nullptr}; 272 273 const XCOFFFileHeader32 *fileHeader32() const; 274 const XCOFFFileHeader64 *fileHeader64() const; 275 276 const XCOFFSectionHeader32 *sectionHeaderTable32() const; 277 const XCOFFSectionHeader64 *sectionHeaderTable64() const; 278 279 size_t getFileHeaderSize() const; 280 size_t getSectionHeaderSize() const; 281 282 const XCOFFSectionHeader32 *toSection32(DataRefImpl Ref) const; 283 const XCOFFSectionHeader64 *toSection64(DataRefImpl Ref) const; 284 uintptr_t getSectionHeaderTableAddress() const; 285 uintptr_t getEndOfSymbolTableAddress() const; 286 287 // This returns a pointer to the start of the storage for the name field of 288 // the 32-bit or 64-bit SectionHeader struct. This string is *not* necessarily 289 // null-terminated. 290 const char *getSectionNameInternal(DataRefImpl Sec) const; 291 292 static bool isReservedSectionNumber(int16_t SectionNumber); 293 294 // Constructor and "create" factory function. The constructor is only a thin 295 // wrapper around the base constructor. The "create" function fills out the 296 // XCOFF-specific information and performs the error checking along the way. 297 XCOFFObjectFile(unsigned Type, MemoryBufferRef Object); 298 static Expected<std::unique_ptr<XCOFFObjectFile>> create(unsigned Type, 299 MemoryBufferRef MBR); 300 301 // Helper for parsing the StringTable. Returns an 'Error' if parsing failed 302 // and an XCOFFStringTable if parsing succeeded. 303 static Expected<XCOFFStringTable> parseStringTable(const XCOFFObjectFile *Obj, 304 uint64_t Offset); 305 306 // Make a friend so it can call the private 'create' function. 307 friend Expected<std::unique_ptr<ObjectFile>> 308 ObjectFile::createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType); 309 310 void checkSectionAddress(uintptr_t Addr, uintptr_t TableAddr) const; 311 312 public: 313 static constexpr uint64_t InvalidRelocOffset = 314 std::numeric_limits<uint64_t>::max(); 315 316 // Interface inherited from base classes. 317 void moveSymbolNext(DataRefImpl &Symb) const override; 318 Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override; 319 basic_symbol_iterator symbol_begin() const override; 320 basic_symbol_iterator symbol_end() const override; 321 322 Expected<StringRef> getSymbolName(DataRefImpl Symb) const override; 323 Expected<uint64_t> getSymbolAddress(DataRefImpl Symb) const override; 324 uint64_t getSymbolValueImpl(DataRefImpl Symb) const override; 325 uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override; 326 Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const override; 327 Expected<section_iterator> getSymbolSection(DataRefImpl Symb) const override; 328 329 void moveSectionNext(DataRefImpl &Sec) const override; 330 Expected<StringRef> getSectionName(DataRefImpl Sec) const override; 331 uint64_t getSectionAddress(DataRefImpl Sec) const override; 332 uint64_t getSectionIndex(DataRefImpl Sec) const override; 333 uint64_t getSectionSize(DataRefImpl Sec) const override; 334 Expected<ArrayRef<uint8_t>> 335 getSectionContents(DataRefImpl Sec) const override; 336 uint64_t getSectionAlignment(DataRefImpl Sec) const override; 337 bool isSectionCompressed(DataRefImpl Sec) const override; 338 bool isSectionText(DataRefImpl Sec) const override; 339 bool isSectionData(DataRefImpl Sec) const override; 340 bool isSectionBSS(DataRefImpl Sec) const override; 341 bool isDebugSection(DataRefImpl Sec) const override; 342 343 bool isSectionVirtual(DataRefImpl Sec) const override; 344 relocation_iterator section_rel_begin(DataRefImpl Sec) const override; 345 relocation_iterator section_rel_end(DataRefImpl Sec) const override; 346 347 void moveRelocationNext(DataRefImpl &Rel) const override; 348 349 /// \returns the relocation offset with the base address of the containing 350 /// section as zero, or InvalidRelocOffset on errors (such as a relocation 351 /// that does not refer to an address in any section). 352 uint64_t getRelocationOffset(DataRefImpl Rel) const override; 353 symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override; 354 uint64_t getRelocationType(DataRefImpl Rel) const override; 355 void getRelocationTypeName(DataRefImpl Rel, 356 SmallVectorImpl<char> &Result) const override; 357 358 section_iterator section_begin() const override; 359 section_iterator section_end() const override; 360 uint8_t getBytesInAddress() const override; 361 StringRef getFileFormatName() const override; 362 Triple::ArchType getArch() const override; 363 SubtargetFeatures getFeatures() const override; 364 Expected<uint64_t> getStartAddress() const override; 365 StringRef mapDebugSectionName(StringRef Name) const override; 366 bool isRelocatableObject() const override; 367 368 // Below here is the non-inherited interface. 369 bool is64Bit() const; 370 371 const void *getPointerToSymbolTable() const { return SymbolTblPtr; } 372 373 Expected<StringRef> getSymbolSectionName(XCOFFSymbolRef Ref) const; 374 unsigned getSymbolSectionID(SymbolRef Sym) const; 375 XCOFFSymbolRef toSymbolRef(DataRefImpl Ref) const; 376 377 // File header related interfaces. 378 uint16_t getMagic() const; 379 uint16_t getNumberOfSections() const; 380 int32_t getTimeStamp() const; 381 382 // Symbol table offset and entry count are handled differently between 383 // XCOFF32 and XCOFF64. 384 uint32_t getSymbolTableOffset32() const; 385 uint64_t getSymbolTableOffset64() const; 386 387 // Note that this value is signed and might return a negative value. Negative 388 // values are reserved for future use. 389 int32_t getRawNumberOfSymbolTableEntries32() const; 390 391 // The sanitized value appropriate to use as an index into the symbol table. 392 uint32_t getLogicalNumberOfSymbolTableEntries32() const; 393 394 uint32_t getNumberOfSymbolTableEntries64() const; 395 396 // Return getLogicalNumberOfSymbolTableEntries32 or 397 // getNumberOfSymbolTableEntries64 depending on the object mode. 398 uint32_t getNumberOfSymbolTableEntries() const; 399 400 uint32_t getSymbolIndex(uintptr_t SymEntPtr) const; 401 uintptr_t getSymbolEntryAddressByIndex(uint32_t SymbolTableIndex) const; 402 Expected<StringRef> getSymbolNameByIndex(uint32_t SymbolTableIndex) const; 403 404 Expected<StringRef> getCFileName(const XCOFFFileAuxEnt *CFileEntPtr) const; 405 uint16_t getOptionalHeaderSize() const; 406 uint16_t getFlags() const; 407 408 // Section header table related interfaces. 409 ArrayRef<XCOFFSectionHeader32> sections32() const; 410 ArrayRef<XCOFFSectionHeader64> sections64() const; 411 412 int32_t getSectionFlags(DataRefImpl Sec) const; 413 Expected<DataRefImpl> getSectionByNum(int16_t Num) const; 414 415 void checkSymbolEntryPointer(uintptr_t SymbolEntPtr) const; 416 417 // Relocation-related interfaces. 418 Expected<uint32_t> 419 getLogicalNumberOfRelocationEntries(const XCOFFSectionHeader32 &Sec) const; 420 421 Expected<ArrayRef<XCOFFRelocation32>> 422 relocations(const XCOFFSectionHeader32 &) const; 423 424 // This function returns string table entry. 425 Expected<StringRef> getStringTableEntry(uint32_t Offset) const; 426 427 // This function returns the string table. 428 StringRef getStringTable() const; 429 430 const XCOFF::SymbolAuxType *getSymbolAuxType(uintptr_t AuxEntryAddress) const; 431 432 static uintptr_t getAdvancedSymbolEntryAddress(uintptr_t CurrentAddress, 433 uint32_t Distance); 434 435 static bool classof(const Binary *B) { return B->isXCOFF(); } 436 }; // XCOFFObjectFile 437 438 typedef struct { 439 uint8_t LanguageId; 440 uint8_t CpuTypeId; 441 } CFileLanguageIdAndTypeIdType; 442 443 struct XCOFFSymbolEntry32 { 444 typedef struct { 445 support::big32_t Magic; // Zero indicates name in string table. 446 support::ubig32_t Offset; 447 } NameInStrTblType; 448 449 union { 450 char SymbolName[XCOFF::NameSize]; 451 NameInStrTblType NameInStrTbl; 452 }; 453 454 support::ubig32_t Value; // Symbol value; storage class-dependent. 455 support::big16_t SectionNumber; 456 457 union { 458 support::ubig16_t SymbolType; 459 CFileLanguageIdAndTypeIdType CFileLanguageIdAndTypeId; 460 }; 461 462 XCOFF::StorageClass StorageClass; 463 uint8_t NumberOfAuxEntries; 464 }; 465 466 struct XCOFFSymbolEntry64 { 467 support::ubig64_t Value; // Symbol value; storage class-dependent. 468 support::ubig32_t Offset; 469 support::big16_t SectionNumber; 470 471 union { 472 support::ubig16_t SymbolType; 473 CFileLanguageIdAndTypeIdType CFileLanguageIdAndTypeId; 474 }; 475 476 XCOFF::StorageClass StorageClass; 477 uint8_t NumberOfAuxEntries; 478 }; 479 480 class XCOFFSymbolRef { 481 public: 482 enum { NAME_IN_STR_TBL_MAGIC = 0x0 }; 483 484 XCOFFSymbolRef(DataRefImpl SymEntDataRef, 485 const XCOFFObjectFile *OwningObjectPtr) 486 : OwningObjectPtr(OwningObjectPtr) { 487 assert(OwningObjectPtr && "OwningObjectPtr cannot be nullptr!"); 488 assert(SymEntDataRef.p != 0 && 489 "Symbol table entry pointer cannot be nullptr!"); 490 491 if (OwningObjectPtr->is64Bit()) 492 Entry64 = reinterpret_cast<const XCOFFSymbolEntry64 *>(SymEntDataRef.p); 493 else 494 Entry32 = reinterpret_cast<const XCOFFSymbolEntry32 *>(SymEntDataRef.p); 495 } 496 497 uint64_t getValue() const { return Entry32 ? getValue32() : getValue64(); } 498 499 uint32_t getValue32() const { return Entry32->Value; } 500 501 uint64_t getValue64() const { return Entry64->Value; } 502 503 #define GETVALUE(X) Entry32 ? Entry32->X : Entry64->X 504 505 int16_t getSectionNumber() const { return GETVALUE(SectionNumber); } 506 507 uint16_t getSymbolType() const { return GETVALUE(SymbolType); } 508 509 uint8_t getLanguageIdForCFile() const { 510 assert(getStorageClass() == XCOFF::C_FILE && 511 "This interface is for C_FILE only."); 512 return GETVALUE(CFileLanguageIdAndTypeId.LanguageId); 513 } 514 515 uint8_t getCPUTypeIddForCFile() const { 516 assert(getStorageClass() == XCOFF::C_FILE && 517 "This interface is for C_FILE only."); 518 return GETVALUE(CFileLanguageIdAndTypeId.CpuTypeId); 519 } 520 521 XCOFF::StorageClass getStorageClass() const { return GETVALUE(StorageClass); } 522 523 uint8_t getNumberOfAuxEntries() const { return GETVALUE(NumberOfAuxEntries); } 524 525 #undef GETVALUE 526 527 uintptr_t getEntryAddress() const { 528 return Entry32 ? reinterpret_cast<uintptr_t>(Entry32) 529 : reinterpret_cast<uintptr_t>(Entry64); 530 } 531 532 Expected<StringRef> getName() const; 533 bool isFunction() const; 534 bool isCsectSymbol() const; 535 Expected<XCOFFCsectAuxRef> getXCOFFCsectAuxRef() const; 536 537 private: 538 const XCOFFObjectFile *OwningObjectPtr; 539 const XCOFFSymbolEntry32 *Entry32 = nullptr; 540 const XCOFFSymbolEntry64 *Entry64 = nullptr; 541 }; 542 543 class TBVectorExt { 544 uint16_t Data; 545 SmallString<32> VecParmsInfo; 546 547 TBVectorExt(StringRef TBvectorStrRef, Error &Err); 548 549 public: 550 static Expected<TBVectorExt> create(StringRef TBvectorStrRef); 551 uint8_t getNumberOfVRSaved() const; 552 bool isVRSavedOnStack() const; 553 bool hasVarArgs() const; 554 uint8_t getNumberOfVectorParms() const; 555 bool hasVMXInstruction() const; 556 SmallString<32> getVectorParmsInfo() const { return VecParmsInfo; }; 557 }; 558 559 /// This class provides methods to extract traceback table data from a buffer. 560 /// The various accessors may reference the buffer provided via the constructor. 561 562 class XCOFFTracebackTable { 563 const uint8_t *const TBPtr; 564 Optional<SmallString<32>> ParmsType; 565 Optional<uint32_t> TraceBackTableOffset; 566 Optional<uint32_t> HandlerMask; 567 Optional<uint32_t> NumOfCtlAnchors; 568 Optional<SmallVector<uint32_t, 8>> ControlledStorageInfoDisp; 569 Optional<StringRef> FunctionName; 570 Optional<uint8_t> AllocaRegister; 571 Optional<TBVectorExt> VecExt; 572 Optional<uint8_t> ExtensionTable; 573 574 XCOFFTracebackTable(const uint8_t *Ptr, uint64_t &Size, Error &Err); 575 public: 576 /// Parse an XCOFF Traceback Table from \a Ptr with \a Size bytes. 577 /// Returns an XCOFFTracebackTable upon successful parsing, otherwise an 578 /// Error is returned. 579 /// 580 /// \param[in] Ptr 581 /// A pointer that points just past the initial 4 bytes of zeros at the 582 /// beginning of an XCOFF Traceback Table. 583 /// 584 /// \param[in, out] Size 585 /// A pointer that points to the length of the XCOFF Traceback Table. 586 /// If the XCOFF Traceback Table is not parsed successfully or there are 587 /// extra bytes that are not recognized, \a Size will be updated to be the 588 /// size up to the end of the last successfully parsed field of the table. 589 static Expected<XCOFFTracebackTable> create(const uint8_t *Ptr, 590 uint64_t &Size); 591 uint8_t getVersion() const; 592 uint8_t getLanguageID() const; 593 594 bool isGlobalLinkage() const; 595 bool isOutOfLineEpilogOrPrologue() const; 596 bool hasTraceBackTableOffset() const; 597 bool isInternalProcedure() const; 598 bool hasControlledStorage() const; 599 bool isTOCless() const; 600 bool isFloatingPointPresent() const; 601 bool isFloatingPointOperationLogOrAbortEnabled() const; 602 603 bool isInterruptHandler() const; 604 bool isFuncNamePresent() const; 605 bool isAllocaUsed() const; 606 uint8_t getOnConditionDirective() const; 607 bool isCRSaved() const; 608 bool isLRSaved() const; 609 610 bool isBackChainStored() const; 611 bool isFixup() const; 612 uint8_t getNumOfFPRsSaved() const; 613 614 bool hasVectorInfo() const; 615 bool hasExtensionTable() const; 616 uint8_t getNumOfGPRsSaved() const; 617 618 uint8_t getNumberOfFixedParms() const; 619 620 uint8_t getNumberOfFPParms() const; 621 bool hasParmsOnStack() const; 622 623 const Optional<SmallString<32>> &getParmsType() const { return ParmsType; } 624 const Optional<uint32_t> &getTraceBackTableOffset() const { 625 return TraceBackTableOffset; 626 } 627 const Optional<uint32_t> &getHandlerMask() const { return HandlerMask; } 628 const Optional<uint32_t> &getNumOfCtlAnchors() { return NumOfCtlAnchors; } 629 const Optional<SmallVector<uint32_t, 8>> &getControlledStorageInfoDisp() { 630 return ControlledStorageInfoDisp; 631 } 632 const Optional<StringRef> &getFunctionName() const { return FunctionName; } 633 const Optional<uint8_t> &getAllocaRegister() const { return AllocaRegister; } 634 const Optional<TBVectorExt> &getVectorExt() const { return VecExt; } 635 const Optional<uint8_t> &getExtensionTable() const { return ExtensionTable; } 636 }; 637 638 bool doesXCOFFTracebackTableBegin(ArrayRef<uint8_t> Bytes); 639 } // namespace object 640 } // namespace llvm 641 642 #endif // LLVM_OBJECT_XCOFFOBJECTFILE_H 643