1 //===--- XCOFFObjectFile.cpp - XCOFF object file implementation -----------===// 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 defines the XCOFFObjectFile class. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "llvm/Object/XCOFFObjectFile.h" 14 #include "llvm/ADT/ArrayRef.h" 15 #include "llvm/Support/BinaryStreamReader.h" 16 #include "llvm/Support/Endian.h" 17 #include "llvm/Support/ErrorHandling.h" 18 #include "llvm/Support/MathExtras.h" 19 #include <cstddef> 20 #include <cstring> 21 22 namespace llvm { 23 namespace object { 24 25 // Checks that [Ptr, Ptr + Size) bytes fall inside the memory buffer 26 // 'M'. Returns a pointer to the underlying object on success. 27 template <typename T> 28 static Expected<const T *> getObject(MemoryBufferRef M, const void *Ptr, 29 const uint64_t Size = sizeof(T)) { 30 uintptr_t Addr = uintptr_t(Ptr); 31 if (std::error_code EC = Binary::checkOffset(M, Addr, Size)) 32 return errorCodeToError(EC); 33 return reinterpret_cast<const T *>(Addr); 34 } 35 36 static uintptr_t getWithOffset(uintptr_t Base, ptrdiff_t Offset) { 37 return reinterpret_cast<uintptr_t>(reinterpret_cast<const char *>(Base) + 38 Offset); 39 } 40 41 template <typename T> static const T *viewAs(uintptr_t in) { 42 return reinterpret_cast<const T *>(in); 43 } 44 45 static StringRef generateStringRef(const char *Name, uint64_t Size) { 46 auto NulCharPtr = static_cast<const char *>(memchr(Name, '\0', Size)); 47 return NulCharPtr ? StringRef(Name, NulCharPtr - Name) 48 : StringRef(Name, Size); 49 } 50 51 void XCOFFObjectFile::checkSectionAddress(uintptr_t Addr, 52 uintptr_t TableAddress) const { 53 if (Addr < TableAddress) 54 report_fatal_error("Section header outside of section header table."); 55 56 uintptr_t Offset = Addr - TableAddress; 57 if (Offset >= getSectionHeaderSize() * getNumberOfSections()) 58 report_fatal_error("Section header outside of section header table."); 59 60 if (Offset % getSectionHeaderSize() != 0) 61 report_fatal_error( 62 "Section header pointer does not point to a valid section header."); 63 } 64 65 const XCOFFSectionHeader32 * 66 XCOFFObjectFile::toSection32(DataRefImpl Ref) const { 67 assert(!is64Bit() && "32-bit interface called on 64-bit object file."); 68 #ifndef NDEBUG 69 checkSectionAddress(Ref.p, getSectionHeaderTableAddress()); 70 #endif 71 return viewAs<XCOFFSectionHeader32>(Ref.p); 72 } 73 74 const XCOFFSectionHeader64 * 75 XCOFFObjectFile::toSection64(DataRefImpl Ref) const { 76 assert(is64Bit() && "64-bit interface called on a 32-bit object file."); 77 #ifndef NDEBUG 78 checkSectionAddress(Ref.p, getSectionHeaderTableAddress()); 79 #endif 80 return viewAs<XCOFFSectionHeader64>(Ref.p); 81 } 82 83 const XCOFFSymbolEntry *XCOFFObjectFile::toSymbolEntry(DataRefImpl Ref) const { 84 assert(!is64Bit() && "Symbol table support not implemented for 64-bit."); 85 assert(Ref.p != 0 && "Symbol table pointer can not be nullptr!"); 86 auto SymEntPtr = viewAs<XCOFFSymbolEntry>(Ref.p); 87 return SymEntPtr; 88 } 89 90 const XCOFFFileHeader32 *XCOFFObjectFile::fileHeader32() const { 91 assert(!is64Bit() && "32-bit interface called on 64-bit object file."); 92 return static_cast<const XCOFFFileHeader32 *>(FileHeader); 93 } 94 95 const XCOFFFileHeader64 *XCOFFObjectFile::fileHeader64() const { 96 assert(is64Bit() && "64-bit interface called on a 32-bit object file."); 97 return static_cast<const XCOFFFileHeader64 *>(FileHeader); 98 } 99 100 const XCOFFSectionHeader32 * 101 XCOFFObjectFile::sectionHeaderTable32() const { 102 assert(!is64Bit() && "32-bit interface called on 64-bit object file."); 103 return static_cast<const XCOFFSectionHeader32 *>(SectionHeaderTable); 104 } 105 106 const XCOFFSectionHeader64 * 107 XCOFFObjectFile::sectionHeaderTable64() const { 108 assert(is64Bit() && "64-bit interface called on a 32-bit object file."); 109 return static_cast<const XCOFFSectionHeader64 *>(SectionHeaderTable); 110 } 111 112 void XCOFFObjectFile::moveSymbolNext(DataRefImpl &Symb) const { 113 const XCOFFSymbolEntry *SymEntPtr = toSymbolEntry(Symb); 114 SymEntPtr += SymEntPtr->NumberOfAuxEntries + 1; 115 Symb.p = reinterpret_cast<uintptr_t>(SymEntPtr); 116 } 117 118 Expected<StringRef> XCOFFObjectFile::getSymbolName(DataRefImpl Symb) const { 119 const XCOFFSymbolEntry *SymEntPtr = toSymbolEntry(Symb); 120 121 if (SymEntPtr->NameInStrTbl.Magic != XCOFFSymbolEntry::NAME_IN_STR_TBL_MAGIC) 122 return generateStringRef(SymEntPtr->SymbolName, XCOFF::SymbolNameSize); 123 124 // A storage class value with the high-order bit on indicates that the name is 125 // a symbolic debugger stabstring. 126 if (SymEntPtr->StorageClass & 0x80) 127 return StringRef("Unimplemented Debug Name"); 128 129 uint32_t Offset = SymEntPtr->NameInStrTbl.Offset; 130 // The byte offset is relative to the start of the string table 131 // or .debug section. A byte offset value of 0 is a null or zero-length symbol 132 // name. A byte offset in the range 1 to 3 (inclusive) points into the length 133 // field; as a soft-error recovery mechanism, we treat such cases as having an 134 // offset of 0. 135 if (Offset < 4) 136 return StringRef(nullptr, 0); 137 138 if (StringTable.Data != nullptr && StringTable.Size > Offset) 139 return (StringTable.Data + Offset); 140 141 return make_error<GenericBinaryError>("Symbol Name parse failed", 142 object_error::parse_failed); 143 } 144 145 Expected<uint64_t> XCOFFObjectFile::getSymbolAddress(DataRefImpl Symb) const { 146 uint64_t Result = 0; 147 llvm_unreachable("Not yet implemented!"); 148 return Result; 149 } 150 151 uint64_t XCOFFObjectFile::getSymbolValueImpl(DataRefImpl Symb) const { 152 return toSymbolEntry(Symb)->Value; 153 } 154 155 uint64_t XCOFFObjectFile::getCommonSymbolSizeImpl(DataRefImpl Symb) const { 156 uint64_t Result = 0; 157 llvm_unreachable("Not yet implemented!"); 158 return Result; 159 } 160 161 Expected<SymbolRef::Type> 162 XCOFFObjectFile::getSymbolType(DataRefImpl Symb) const { 163 llvm_unreachable("Not yet implemented!"); 164 return SymbolRef::ST_Other; 165 } 166 167 Expected<section_iterator> 168 XCOFFObjectFile::getSymbolSection(DataRefImpl Symb) const { 169 const XCOFFSymbolEntry *SymEntPtr = toSymbolEntry(Symb); 170 int16_t SectNum = SymEntPtr->SectionNumber; 171 172 if (isReservedSectionNumber(SectNum)) 173 return section_end(); 174 175 Expected<DataRefImpl> ExpSec = getSectionByNum(SectNum); 176 if (!ExpSec) 177 return ExpSec.takeError(); 178 179 return section_iterator(SectionRef(ExpSec.get(), this)); 180 } 181 182 void XCOFFObjectFile::moveSectionNext(DataRefImpl &Sec) const { 183 const char *Ptr = reinterpret_cast<const char *>(Sec.p); 184 Sec.p = reinterpret_cast<uintptr_t>(Ptr + getSectionHeaderSize()); 185 } 186 187 Expected<StringRef> XCOFFObjectFile::getSectionName(DataRefImpl Sec) const { 188 return generateStringRef(getSectionNameInternal(Sec), XCOFF::SectionNameSize); 189 } 190 191 uint64_t XCOFFObjectFile::getSectionAddress(DataRefImpl Sec) const { 192 // Avoid ternary due to failure to convert the ubig32_t value to a unit64_t 193 // with MSVC. 194 if (is64Bit()) 195 return toSection64(Sec)->VirtualAddress; 196 197 return toSection32(Sec)->VirtualAddress; 198 } 199 200 uint64_t XCOFFObjectFile::getSectionIndex(DataRefImpl Sec) const { 201 // Section numbers in XCOFF are numbered beginning at 1. A section number of 202 // zero is used to indicate that a symbol is being imported or is undefined. 203 if (is64Bit()) 204 return toSection64(Sec) - sectionHeaderTable64() + 1; 205 else 206 return toSection32(Sec) - sectionHeaderTable32() + 1; 207 } 208 209 uint64_t XCOFFObjectFile::getSectionSize(DataRefImpl Sec) const { 210 // Avoid ternary due to failure to convert the ubig32_t value to a unit64_t 211 // with MSVC. 212 if (is64Bit()) 213 return toSection64(Sec)->SectionSize; 214 215 return toSection32(Sec)->SectionSize; 216 } 217 218 Expected<ArrayRef<uint8_t>> 219 XCOFFObjectFile::getSectionContents(DataRefImpl Sec) const { 220 llvm_unreachable("Not yet implemented!"); 221 } 222 223 uint64_t XCOFFObjectFile::getSectionAlignment(DataRefImpl Sec) const { 224 uint64_t Result = 0; 225 llvm_unreachable("Not yet implemented!"); 226 return Result; 227 } 228 229 bool XCOFFObjectFile::isSectionCompressed(DataRefImpl Sec) const { 230 bool Result = false; 231 llvm_unreachable("Not yet implemented!"); 232 return Result; 233 } 234 235 bool XCOFFObjectFile::isSectionText(DataRefImpl Sec) const { 236 return getSectionFlags(Sec) & XCOFF::STYP_TEXT; 237 } 238 239 bool XCOFFObjectFile::isSectionData(DataRefImpl Sec) const { 240 uint32_t Flags = getSectionFlags(Sec); 241 return Flags & (XCOFF::STYP_DATA | XCOFF::STYP_TDATA); 242 } 243 244 bool XCOFFObjectFile::isSectionBSS(DataRefImpl Sec) const { 245 uint32_t Flags = getSectionFlags(Sec); 246 return Flags & (XCOFF::STYP_BSS | XCOFF::STYP_TBSS); 247 } 248 249 bool XCOFFObjectFile::isSectionVirtual(DataRefImpl Sec) const { 250 bool Result = false; 251 llvm_unreachable("Not yet implemented!"); 252 return Result; 253 } 254 255 relocation_iterator XCOFFObjectFile::section_rel_begin(DataRefImpl Sec) const { 256 llvm_unreachable("Not yet implemented!"); 257 return relocation_iterator(RelocationRef()); 258 } 259 260 relocation_iterator XCOFFObjectFile::section_rel_end(DataRefImpl Sec) const { 261 llvm_unreachable("Not yet implemented!"); 262 return relocation_iterator(RelocationRef()); 263 } 264 265 void XCOFFObjectFile::moveRelocationNext(DataRefImpl &Rel) const { 266 llvm_unreachable("Not yet implemented!"); 267 return; 268 } 269 270 uint64_t XCOFFObjectFile::getRelocationOffset(DataRefImpl Rel) const { 271 llvm_unreachable("Not yet implemented!"); 272 uint64_t Result = 0; 273 return Result; 274 } 275 276 symbol_iterator XCOFFObjectFile::getRelocationSymbol(DataRefImpl Rel) const { 277 llvm_unreachable("Not yet implemented!"); 278 return symbol_iterator(SymbolRef()); 279 } 280 281 uint64_t XCOFFObjectFile::getRelocationType(DataRefImpl Rel) const { 282 llvm_unreachable("Not yet implemented!"); 283 uint64_t Result = 0; 284 return Result; 285 } 286 287 void XCOFFObjectFile::getRelocationTypeName( 288 DataRefImpl Rel, SmallVectorImpl<char> &Result) const { 289 llvm_unreachable("Not yet implemented!"); 290 return; 291 } 292 293 uint32_t XCOFFObjectFile::getSymbolFlags(DataRefImpl Symb) const { 294 uint32_t Result = 0; 295 llvm_unreachable("Not yet implemented!"); 296 return Result; 297 } 298 299 basic_symbol_iterator XCOFFObjectFile::symbol_begin() const { 300 assert(!is64Bit() && "64-bit support not implemented yet."); 301 DataRefImpl SymDRI; 302 SymDRI.p = reinterpret_cast<uintptr_t>(SymbolTblPtr); 303 return basic_symbol_iterator(SymbolRef(SymDRI, this)); 304 } 305 306 basic_symbol_iterator XCOFFObjectFile::symbol_end() const { 307 assert(!is64Bit() && "64-bit support not implemented yet."); 308 DataRefImpl SymDRI; 309 SymDRI.p = reinterpret_cast<uintptr_t>( 310 SymbolTblPtr + getLogicalNumberOfSymbolTableEntries32()); 311 return basic_symbol_iterator(SymbolRef(SymDRI, this)); 312 } 313 314 section_iterator XCOFFObjectFile::section_begin() const { 315 DataRefImpl DRI; 316 DRI.p = getSectionHeaderTableAddress(); 317 return section_iterator(SectionRef(DRI, this)); 318 } 319 320 section_iterator XCOFFObjectFile::section_end() const { 321 DataRefImpl DRI; 322 DRI.p = getWithOffset(getSectionHeaderTableAddress(), 323 getNumberOfSections() * getSectionHeaderSize()); 324 return section_iterator(SectionRef(DRI, this)); 325 } 326 327 uint8_t XCOFFObjectFile::getBytesInAddress() const { return is64Bit() ? 8 : 4; } 328 329 StringRef XCOFFObjectFile::getFileFormatName() const { 330 return is64Bit() ? "aix5coff64-rs6000" : "aixcoff-rs6000"; 331 } 332 333 Triple::ArchType XCOFFObjectFile::getArch() const { 334 return is64Bit() ? Triple::ppc64 : Triple::ppc; 335 } 336 337 SubtargetFeatures XCOFFObjectFile::getFeatures() const { 338 llvm_unreachable("Not yet implemented!"); 339 return SubtargetFeatures(); 340 } 341 342 bool XCOFFObjectFile::isRelocatableObject() const { 343 bool Result = false; 344 llvm_unreachable("Not yet implemented!"); 345 return Result; 346 } 347 348 Expected<uint64_t> XCOFFObjectFile::getStartAddress() const { 349 // TODO FIXME Should get from auxiliary_header->o_entry when support for the 350 // auxiliary_header is added. 351 return 0; 352 } 353 354 size_t XCOFFObjectFile::getFileHeaderSize() const { 355 return is64Bit() ? sizeof(XCOFFFileHeader64) : sizeof(XCOFFFileHeader32); 356 } 357 358 size_t XCOFFObjectFile::getSectionHeaderSize() const { 359 return is64Bit() ? sizeof(XCOFFSectionHeader64) : 360 sizeof(XCOFFSectionHeader32); 361 } 362 363 bool XCOFFObjectFile::is64Bit() const { 364 return Binary::ID_XCOFF64 == getType(); 365 } 366 367 uint16_t XCOFFObjectFile::getMagic() const { 368 return is64Bit() ? fileHeader64()->Magic : fileHeader32()->Magic; 369 } 370 371 Expected<DataRefImpl> XCOFFObjectFile::getSectionByNum(int16_t Num) const { 372 if (Num <= 0 || Num > getNumberOfSections()) 373 return errorCodeToError(object_error::invalid_section_index); 374 375 DataRefImpl DRI; 376 DRI.p = getWithOffset(getSectionHeaderTableAddress(), 377 getSectionHeaderSize() * (Num - 1)); 378 return DRI; 379 } 380 381 Expected<StringRef> 382 XCOFFObjectFile::getSymbolSectionName(const XCOFFSymbolEntry *SymEntPtr) const { 383 assert(!is64Bit() && "Symbol table support not implemented for 64-bit."); 384 int16_t SectionNum = SymEntPtr->SectionNumber; 385 386 switch (SectionNum) { 387 case XCOFF::N_DEBUG: 388 return "N_DEBUG"; 389 case XCOFF::N_ABS: 390 return "N_ABS"; 391 case XCOFF::N_UNDEF: 392 return "N_UNDEF"; 393 default: 394 Expected<DataRefImpl> SecRef = getSectionByNum(SectionNum); 395 if (SecRef) 396 return generateStringRef(getSectionNameInternal(SecRef.get()), 397 XCOFF::SectionNameSize); 398 return SecRef.takeError(); 399 } 400 } 401 402 bool XCOFFObjectFile::isReservedSectionNumber(int16_t SectionNumber) { 403 return (SectionNumber <= 0 && SectionNumber >= -2); 404 } 405 406 uint16_t XCOFFObjectFile::getNumberOfSections() const { 407 return is64Bit() ? fileHeader64()->NumberOfSections 408 : fileHeader32()->NumberOfSections; 409 } 410 411 int32_t XCOFFObjectFile::getTimeStamp() const { 412 return is64Bit() ? fileHeader64()->TimeStamp : fileHeader32()->TimeStamp; 413 } 414 415 uint16_t XCOFFObjectFile::getOptionalHeaderSize() const { 416 return is64Bit() ? fileHeader64()->AuxHeaderSize 417 : fileHeader32()->AuxHeaderSize; 418 } 419 420 uint32_t XCOFFObjectFile::getSymbolTableOffset32() const { 421 return fileHeader32()->SymbolTableOffset; 422 } 423 424 int32_t XCOFFObjectFile::getRawNumberOfSymbolTableEntries32() const { 425 // As far as symbol table size is concerned, if this field is negative it is 426 // to be treated as a 0. However since this field is also used for printing we 427 // don't want to truncate any negative values. 428 return fileHeader32()->NumberOfSymTableEntries; 429 } 430 431 uint32_t XCOFFObjectFile::getLogicalNumberOfSymbolTableEntries32() const { 432 return (fileHeader32()->NumberOfSymTableEntries >= 0 433 ? fileHeader32()->NumberOfSymTableEntries 434 : 0); 435 } 436 437 uint64_t XCOFFObjectFile::getSymbolTableOffset64() const { 438 return fileHeader64()->SymbolTableOffset; 439 } 440 441 uint32_t XCOFFObjectFile::getNumberOfSymbolTableEntries64() const { 442 return fileHeader64()->NumberOfSymTableEntries; 443 } 444 445 uint16_t XCOFFObjectFile::getFlags() const { 446 return is64Bit() ? fileHeader64()->Flags : fileHeader32()->Flags; 447 } 448 449 const char *XCOFFObjectFile::getSectionNameInternal(DataRefImpl Sec) const { 450 return is64Bit() ? toSection64(Sec)->Name : toSection32(Sec)->Name; 451 } 452 453 uintptr_t XCOFFObjectFile::getSectionHeaderTableAddress() const { 454 return reinterpret_cast<uintptr_t>(SectionHeaderTable); 455 } 456 457 int32_t XCOFFObjectFile::getSectionFlags(DataRefImpl Sec) const { 458 return is64Bit() ? toSection64(Sec)->Flags : toSection32(Sec)->Flags; 459 } 460 461 XCOFFObjectFile::XCOFFObjectFile(unsigned int Type, MemoryBufferRef Object) 462 : ObjectFile(Type, Object) { 463 assert(Type == Binary::ID_XCOFF32 || Type == Binary::ID_XCOFF64); 464 } 465 466 ArrayRef<XCOFFSectionHeader64> XCOFFObjectFile::sections64() const { 467 assert(is64Bit() && "64-bit interface called for non 64-bit file."); 468 const XCOFFSectionHeader64 *TablePtr = sectionHeaderTable64(); 469 return ArrayRef<XCOFFSectionHeader64>(TablePtr, 470 TablePtr + getNumberOfSections()); 471 } 472 473 ArrayRef<XCOFFSectionHeader32> XCOFFObjectFile::sections32() const { 474 assert(!is64Bit() && "32-bit interface called for non 32-bit file."); 475 const XCOFFSectionHeader32 *TablePtr = sectionHeaderTable32(); 476 return ArrayRef<XCOFFSectionHeader32>(TablePtr, 477 TablePtr + getNumberOfSections()); 478 } 479 480 Expected<XCOFFStringTable> 481 XCOFFObjectFile::parseStringTable(const XCOFFObjectFile *Obj, uint64_t Offset) { 482 // If there is a string table, then the buffer must contain at least 4 bytes 483 // for the string table's size. Not having a string table is not an error. 484 if (auto EC = Binary::checkOffset( 485 Obj->Data, reinterpret_cast<uintptr_t>(Obj->base() + Offset), 4)) 486 return XCOFFStringTable{0, nullptr}; 487 488 // Read the size out of the buffer. 489 uint32_t Size = support::endian::read32be(Obj->base() + Offset); 490 491 // If the size is less then 4, then the string table is just a size and no 492 // string data. 493 if (Size <= 4) 494 return XCOFFStringTable{4, nullptr}; 495 496 auto StringTableOrErr = 497 getObject<char>(Obj->Data, Obj->base() + Offset, Size); 498 if (Error E = StringTableOrErr.takeError()) 499 return std::move(E); 500 501 const char *StringTablePtr = StringTableOrErr.get(); 502 if (StringTablePtr[Size - 1] != '\0') 503 return errorCodeToError(object_error::string_table_non_null_end); 504 505 return XCOFFStringTable{Size, StringTablePtr}; 506 } 507 508 Expected<std::unique_ptr<XCOFFObjectFile>> 509 XCOFFObjectFile::create(unsigned Type, MemoryBufferRef MBR) { 510 // Can't use make_unique because of the private constructor. 511 std::unique_ptr<XCOFFObjectFile> Obj; 512 Obj.reset(new XCOFFObjectFile(Type, MBR)); 513 514 uint64_t CurOffset = 0; 515 const auto *Base = Obj->base(); 516 MemoryBufferRef Data = Obj->Data; 517 518 // Parse file header. 519 auto FileHeaderOrErr = 520 getObject<void>(Data, Base + CurOffset, Obj->getFileHeaderSize()); 521 if (Error E = FileHeaderOrErr.takeError()) 522 return std::move(E); 523 Obj->FileHeader = FileHeaderOrErr.get(); 524 525 CurOffset += Obj->getFileHeaderSize(); 526 // TODO FIXME we don't have support for an optional header yet, so just skip 527 // past it. 528 CurOffset += Obj->getOptionalHeaderSize(); 529 530 // Parse the section header table if it is present. 531 if (Obj->getNumberOfSections()) { 532 auto SecHeadersOrErr = getObject<void>(Data, Base + CurOffset, 533 Obj->getNumberOfSections() * 534 Obj->getSectionHeaderSize()); 535 if (Error E = SecHeadersOrErr.takeError()) 536 return std::move(E); 537 Obj->SectionHeaderTable = SecHeadersOrErr.get(); 538 } 539 540 // 64-bit object supports only file header and section headers for now. 541 if (Obj->is64Bit()) 542 return std::move(Obj); 543 544 // If there is no symbol table we are done parsing the memory buffer. 545 if (Obj->getLogicalNumberOfSymbolTableEntries32() == 0) 546 return std::move(Obj); 547 548 // Parse symbol table. 549 CurOffset = Obj->fileHeader32()->SymbolTableOffset; 550 uint64_t SymbolTableSize = (uint64_t)(sizeof(XCOFFSymbolEntry)) * 551 Obj->getLogicalNumberOfSymbolTableEntries32(); 552 auto SymTableOrErr = 553 getObject<XCOFFSymbolEntry>(Data, Base + CurOffset, SymbolTableSize); 554 if (Error E = SymTableOrErr.takeError()) 555 return std::move(E); 556 Obj->SymbolTblPtr = SymTableOrErr.get(); 557 CurOffset += SymbolTableSize; 558 559 // Parse String table. 560 Expected<XCOFFStringTable> StringTableOrErr = 561 parseStringTable(Obj.get(), CurOffset); 562 if (Error E = StringTableOrErr.takeError()) 563 return std::move(E); 564 Obj->StringTable = StringTableOrErr.get(); 565 566 return std::move(Obj); 567 } 568 569 Expected<std::unique_ptr<ObjectFile>> 570 ObjectFile::createXCOFFObjectFile(MemoryBufferRef MemBufRef, 571 unsigned FileType) { 572 return XCOFFObjectFile::create(FileType, MemBufRef); 573 } 574 575 StringRef XCOFFSectionHeader32::getName() const { 576 return generateStringRef(Name, XCOFF::SectionNameSize); 577 } 578 579 StringRef XCOFFSectionHeader64::getName() const { 580 return generateStringRef(Name, XCOFF::SectionNameSize); 581 } 582 583 } // namespace object 584 } // namespace llvm 585