LLVM  10.0.0svn
XCOFFObjectFile.cpp
Go to the documentation of this file.
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 
14 #include <cstddef>
15 #include <cstring>
16 
17 namespace llvm {
18 namespace object {
19 
20 enum {
21  FUNCTION_SYM = 0x20,
23 };
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 
46  auto NulCharPtr =
47  static_cast<const char *>(memchr(Name, '\0', XCOFF::NameSize));
48  return NulCharPtr ? StringRef(Name, NulCharPtr - Name)
49  : StringRef(Name, XCOFF::NameSize);
50 }
51 
52 void XCOFFObjectFile::checkSectionAddress(uintptr_t Addr,
53  uintptr_t TableAddress) const {
54  if (Addr < TableAddress)
55  report_fatal_error("Section header outside of section header table.");
56 
57  uintptr_t Offset = Addr - TableAddress;
58  if (Offset >= getSectionHeaderSize() * getNumberOfSections())
59  report_fatal_error("Section header outside of section header table.");
60 
61  if (Offset % getSectionHeaderSize() != 0)
63  "Section header pointer does not point to a valid section header.");
64 }
65 
67 XCOFFObjectFile::toSection32(DataRefImpl Ref) const {
68  assert(!is64Bit() && "32-bit interface called on 64-bit object file.");
69 #ifndef NDEBUG
70  checkSectionAddress(Ref.p, getSectionHeaderTableAddress());
71 #endif
72  return viewAs<XCOFFSectionHeader32>(Ref.p);
73 }
74 
76 XCOFFObjectFile::toSection64(DataRefImpl Ref) const {
77  assert(is64Bit() && "64-bit interface called on a 32-bit object file.");
78 #ifndef NDEBUG
79  checkSectionAddress(Ref.p, getSectionHeaderTableAddress());
80 #endif
81  return viewAs<XCOFFSectionHeader64>(Ref.p);
82 }
83 
85  assert(!is64Bit() && "Symbol table support not implemented for 64-bit.");
86  assert(Ref.p != 0 && "Symbol table pointer can not be nullptr!");
87 #ifndef NDEBUG
89 #endif
90  auto SymEntPtr = viewAs<XCOFFSymbolEntry>(Ref.p);
91  return SymEntPtr;
92 }
93 
94 const XCOFFFileHeader32 *XCOFFObjectFile::fileHeader32() const {
95  assert(!is64Bit() && "32-bit interface called on 64-bit object file.");
96  return static_cast<const XCOFFFileHeader32 *>(FileHeader);
97 }
98 
99 const XCOFFFileHeader64 *XCOFFObjectFile::fileHeader64() const {
100  assert(is64Bit() && "64-bit interface called on a 32-bit object file.");
101  return static_cast<const XCOFFFileHeader64 *>(FileHeader);
102 }
103 
104 const XCOFFSectionHeader32 *
105 XCOFFObjectFile::sectionHeaderTable32() const {
106  assert(!is64Bit() && "32-bit interface called on 64-bit object file.");
107  return static_cast<const XCOFFSectionHeader32 *>(SectionHeaderTable);
108 }
109 
110 const XCOFFSectionHeader64 *
111 XCOFFObjectFile::sectionHeaderTable64() const {
112  assert(is64Bit() && "64-bit interface called on a 32-bit object file.");
113  return static_cast<const XCOFFSectionHeader64 *>(SectionHeaderTable);
114 }
115 
117  const XCOFFSymbolEntry *SymEntPtr = toSymbolEntry(Symb);
118  SymEntPtr += SymEntPtr->NumberOfAuxEntries + 1;
119 #ifndef NDEBUG
120  // This function is used by basic_symbol_iterator, which allows to
121  // point to the end-of-symbol-table address.
122  if (reinterpret_cast<uintptr_t>(SymEntPtr) != getEndOfSymbolTableAddress())
123  checkSymbolEntryPointer(reinterpret_cast<uintptr_t>(SymEntPtr));
124 #endif
125  Symb.p = reinterpret_cast<uintptr_t>(SymEntPtr);
126 }
127 
129 XCOFFObjectFile::getStringTableEntry(uint32_t Offset) const {
130  // The byte offset is relative to the start of the string table.
131  // 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>("Bad offset for string table entry",
143 }
144 
147  if (CFileEntPtr->NameInStrTbl.Magic !=
149  return generateXCOFFFixedNameStringRef(CFileEntPtr->Name);
150  return getStringTableEntry(CFileEntPtr->NameInStrTbl.Offset);
151 }
152 
154  const XCOFFSymbolEntry *SymEntPtr = toSymbolEntry(Symb);
155 
156  // A storage class value with the high-order bit on indicates that the name is
157  // a symbolic debugger stabstring.
158  if (SymEntPtr->StorageClass & 0x80)
159  return StringRef("Unimplemented Debug Name");
160 
162  return generateXCOFFFixedNameStringRef(SymEntPtr->SymbolName);
163 
164  return getStringTableEntry(SymEntPtr->NameInStrTbl.Offset);
165 }
166 
168  uint64_t Result = 0;
169  llvm_unreachable("Not yet implemented!");
170  return Result;
171 }
172 
174  assert(!is64Bit() && "Symbol table support not implemented for 64-bit.");
175  return toSymbolEntry(Symb)->Value;
176 }
177 
179  uint64_t Result = 0;
180  llvm_unreachable("Not yet implemented!");
181  return Result;
182 }
183 
186  llvm_unreachable("Not yet implemented!");
187  return SymbolRef::ST_Other;
188 }
189 
192  const XCOFFSymbolEntry *SymEntPtr = toSymbolEntry(Symb);
193  int16_t SectNum = SymEntPtr->SectionNumber;
194 
195  if (isReservedSectionNumber(SectNum))
196  return section_end();
197 
198  Expected<DataRefImpl> ExpSec = getSectionByNum(SectNum);
199  if (!ExpSec)
200  return ExpSec.takeError();
201 
202  return section_iterator(SectionRef(ExpSec.get(), this));
203 }
204 
206  const char *Ptr = reinterpret_cast<const char *>(Sec.p);
207  Sec.p = reinterpret_cast<uintptr_t>(Ptr + getSectionHeaderSize());
208 }
209 
211  return generateXCOFFFixedNameStringRef(getSectionNameInternal(Sec));
212 }
213 
215  // Avoid ternary due to failure to convert the ubig32_t value to a unit64_t
216  // with MSVC.
217  if (is64Bit())
218  return toSection64(Sec)->VirtualAddress;
219 
220  return toSection32(Sec)->VirtualAddress;
221 }
222 
224  // Section numbers in XCOFF are numbered beginning at 1. A section number of
225  // zero is used to indicate that a symbol is being imported or is undefined.
226  if (is64Bit())
227  return toSection64(Sec) - sectionHeaderTable64() + 1;
228  else
229  return toSection32(Sec) - sectionHeaderTable32() + 1;
230 }
231 
233  // Avoid ternary due to failure to convert the ubig32_t value to a unit64_t
234  // with MSVC.
235  if (is64Bit())
236  return toSection64(Sec)->SectionSize;
237 
238  return toSection32(Sec)->SectionSize;
239 }
240 
243  llvm_unreachable("Not yet implemented!");
244 }
245 
247  uint64_t Result = 0;
248  llvm_unreachable("Not yet implemented!");
249  return Result;
250 }
251 
253  bool Result = false;
254  llvm_unreachable("Not yet implemented!");
255  return Result;
256 }
257 
259  return getSectionFlags(Sec) & XCOFF::STYP_TEXT;
260 }
261 
263  uint32_t Flags = getSectionFlags(Sec);
264  return Flags & (XCOFF::STYP_DATA | XCOFF::STYP_TDATA);
265 }
266 
268  uint32_t Flags = getSectionFlags(Sec);
269  return Flags & (XCOFF::STYP_BSS | XCOFF::STYP_TBSS);
270 }
271 
273  bool Result = false;
274  llvm_unreachable("Not yet implemented!");
275  return Result;
276 }
277 
279  llvm_unreachable("Not yet implemented!");
281 }
282 
284  llvm_unreachable("Not yet implemented!");
286 }
287 
289  llvm_unreachable("Not yet implemented!");
290  return;
291 }
292 
294  llvm_unreachable("Not yet implemented!");
295  uint64_t Result = 0;
296  return Result;
297 }
298 
300  llvm_unreachable("Not yet implemented!");
301  return symbol_iterator(SymbolRef());
302 }
303 
305  llvm_unreachable("Not yet implemented!");
306  uint64_t Result = 0;
307  return Result;
308 }
309 
311  DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
312  llvm_unreachable("Not yet implemented!");
313  return;
314 }
315 
317  uint32_t Result = 0;
318  llvm_unreachable("Not yet implemented!");
319  return Result;
320 }
321 
323  assert(!is64Bit() && "64-bit support not implemented yet.");
324  DataRefImpl SymDRI;
325  SymDRI.p = reinterpret_cast<uintptr_t>(SymbolTblPtr);
326  return basic_symbol_iterator(SymbolRef(SymDRI, this));
327 }
328 
330  assert(!is64Bit() && "64-bit support not implemented yet.");
331  DataRefImpl SymDRI;
332  SymDRI.p = reinterpret_cast<uintptr_t>(
333  SymbolTblPtr + getLogicalNumberOfSymbolTableEntries32());
334  return basic_symbol_iterator(SymbolRef(SymDRI, this));
335 }
336 
338  DataRefImpl DRI;
339  DRI.p = getSectionHeaderTableAddress();
340  return section_iterator(SectionRef(DRI, this));
341 }
342 
344  DataRefImpl DRI;
345  DRI.p = getWithOffset(getSectionHeaderTableAddress(),
346  getNumberOfSections() * getSectionHeaderSize());
347  return section_iterator(SectionRef(DRI, this));
348 }
349 
350 uint8_t XCOFFObjectFile::getBytesInAddress() const { return is64Bit() ? 8 : 4; }
351 
353  return is64Bit() ? "aix5coff64-rs6000" : "aixcoff-rs6000";
354 }
355 
357  return is64Bit() ? Triple::ppc64 : Triple::ppc;
358 }
359 
361  llvm_unreachable("Not yet implemented!");
362  return SubtargetFeatures();
363 }
364 
366  bool Result = false;
367  llvm_unreachable("Not yet implemented!");
368  return Result;
369 }
370 
372  // TODO FIXME Should get from auxiliary_header->o_entry when support for the
373  // auxiliary_header is added.
374  return 0;
375 }
376 
377 size_t XCOFFObjectFile::getFileHeaderSize() const {
378  return is64Bit() ? sizeof(XCOFFFileHeader64) : sizeof(XCOFFFileHeader32);
379 }
380 
381 size_t XCOFFObjectFile::getSectionHeaderSize() const {
382  return is64Bit() ? sizeof(XCOFFSectionHeader64) :
383  sizeof(XCOFFSectionHeader32);
384 }
385 
387  return Binary::ID_XCOFF64 == getType();
388 }
389 
390 uint16_t XCOFFObjectFile::getMagic() const {
391  return is64Bit() ? fileHeader64()->Magic : fileHeader32()->Magic;
392 }
393 
395  if (Num <= 0 || Num > getNumberOfSections())
397 
398  DataRefImpl DRI;
399  DRI.p = getWithOffset(getSectionHeaderTableAddress(),
400  getSectionHeaderSize() * (Num - 1));
401  return DRI;
402 }
403 
406  assert(!is64Bit() && "Symbol table support not implemented for 64-bit.");
407  int16_t SectionNum = SymEntPtr->SectionNumber;
408 
409  switch (SectionNum) {
410  case XCOFF::N_DEBUG:
411  return "N_DEBUG";
412  case XCOFF::N_ABS:
413  return "N_ABS";
414  case XCOFF::N_UNDEF:
415  return "N_UNDEF";
416  default:
417  Expected<DataRefImpl> SecRef = getSectionByNum(SectionNum);
418  if (SecRef)
420  getSectionNameInternal(SecRef.get()));
421  return SecRef.takeError();
422  }
423 }
424 
425 bool XCOFFObjectFile::isReservedSectionNumber(int16_t SectionNumber) {
426  return (SectionNumber <= 0 && SectionNumber >= -2);
427 }
428 
430  return is64Bit() ? fileHeader64()->NumberOfSections
431  : fileHeader32()->NumberOfSections;
432 }
433 
435  return is64Bit() ? fileHeader64()->TimeStamp : fileHeader32()->TimeStamp;
436 }
437 
439  return is64Bit() ? fileHeader64()->AuxHeaderSize
440  : fileHeader32()->AuxHeaderSize;
441 }
442 
444  return fileHeader32()->SymbolTableOffset;
445 }
446 
448  // As far as symbol table size is concerned, if this field is negative it is
449  // to be treated as a 0. However since this field is also used for printing we
450  // don't want to truncate any negative values.
451  return fileHeader32()->NumberOfSymTableEntries;
452 }
453 
455  return (fileHeader32()->NumberOfSymTableEntries >= 0
456  ? fileHeader32()->NumberOfSymTableEntries
457  : 0);
458 }
459 
461  return fileHeader64()->SymbolTableOffset;
462 }
463 
465  return fileHeader64()->NumberOfSymTableEntries;
466 }
467 
468 uintptr_t XCOFFObjectFile::getEndOfSymbolTableAddress() const {
469  uint32_t NumberOfSymTableEntries =
472  return getWithOffset(reinterpret_cast<uintptr_t>(SymbolTblPtr),
473  XCOFF::SymbolTableEntrySize * NumberOfSymTableEntries);
474 }
475 
476 void XCOFFObjectFile::checkSymbolEntryPointer(uintptr_t SymbolEntPtr) const {
477  if (SymbolEntPtr < reinterpret_cast<uintptr_t>(SymbolTblPtr))
478  report_fatal_error("Symbol table entry is outside of symbol table.");
479 
480  if (SymbolEntPtr >= getEndOfSymbolTableAddress())
481  report_fatal_error("Symbol table entry is outside of symbol table.");
482 
483  ptrdiff_t Offset = reinterpret_cast<const char *>(SymbolEntPtr) -
484  reinterpret_cast<const char *>(SymbolTblPtr);
485 
486  if (Offset % XCOFF::SymbolTableEntrySize != 0)
488  "Symbol table entry position is not valid inside of symbol table.");
489 }
490 
491 uint32_t XCOFFObjectFile::getSymbolIndex(uintptr_t SymbolEntPtr) const {
492  return (reinterpret_cast<const char *>(SymbolEntPtr) -
493  reinterpret_cast<const char *>(SymbolTblPtr)) /
495 }
496 
497 uint16_t XCOFFObjectFile::getFlags() const {
498  return is64Bit() ? fileHeader64()->Flags : fileHeader32()->Flags;
499 }
500 
501 const char *XCOFFObjectFile::getSectionNameInternal(DataRefImpl Sec) const {
502  return is64Bit() ? toSection64(Sec)->Name : toSection32(Sec)->Name;
503 }
504 
505 uintptr_t XCOFFObjectFile::getSectionHeaderTableAddress() const {
506  return reinterpret_cast<uintptr_t>(SectionHeaderTable);
507 }
508 
510  return is64Bit() ? toSection64(Sec)->Flags : toSection32(Sec)->Flags;
511 }
512 
513 XCOFFObjectFile::XCOFFObjectFile(unsigned int Type, MemoryBufferRef Object)
514  : ObjectFile(Type, Object) {
515  assert(Type == Binary::ID_XCOFF32 || Type == Binary::ID_XCOFF64);
516 }
517 
519  assert(is64Bit() && "64-bit interface called for non 64-bit file.");
520  const XCOFFSectionHeader64 *TablePtr = sectionHeaderTable64();
521  return ArrayRef<XCOFFSectionHeader64>(TablePtr,
522  TablePtr + getNumberOfSections());
523 }
524 
526  assert(!is64Bit() && "32-bit interface called for non 32-bit file.");
527  const XCOFFSectionHeader32 *TablePtr = sectionHeaderTable32();
528  return ArrayRef<XCOFFSectionHeader32>(TablePtr,
529  TablePtr + getNumberOfSections());
530 }
531 
533 XCOFFObjectFile::parseStringTable(const XCOFFObjectFile *Obj, uint64_t Offset) {
534  // If there is a string table, then the buffer must contain at least 4 bytes
535  // for the string table's size. Not having a string table is not an error.
536  if (auto EC = Binary::checkOffset(
537  Obj->Data, reinterpret_cast<uintptr_t>(Obj->base() + Offset), 4))
538  return XCOFFStringTable{0, nullptr};
539 
540  // Read the size out of the buffer.
542 
543  // If the size is less then 4, then the string table is just a size and no
544  // string data.
545  if (Size <= 4)
546  return XCOFFStringTable{4, nullptr};
547 
548  auto StringTableOrErr =
549  getObject<char>(Obj->Data, Obj->base() + Offset, Size);
550  if (Error E = StringTableOrErr.takeError())
551  return std::move(E);
552 
553  const char *StringTablePtr = StringTableOrErr.get();
554  if (StringTablePtr[Size - 1] != '\0')
556 
557  return XCOFFStringTable{Size, StringTablePtr};
558 }
559 
561 XCOFFObjectFile::create(unsigned Type, MemoryBufferRef MBR) {
562  // Can't use std::make_unique because of the private constructor.
563  std::unique_ptr<XCOFFObjectFile> Obj;
564  Obj.reset(new XCOFFObjectFile(Type, MBR));
565 
566  uint64_t CurOffset = 0;
567  const auto *Base = Obj->base();
568  MemoryBufferRef Data = Obj->Data;
569 
570  // Parse file header.
571  auto FileHeaderOrErr =
572  getObject<void>(Data, Base + CurOffset, Obj->getFileHeaderSize());
573  if (Error E = FileHeaderOrErr.takeError())
574  return std::move(E);
575  Obj->FileHeader = FileHeaderOrErr.get();
576 
577  CurOffset += Obj->getFileHeaderSize();
578  // TODO FIXME we don't have support for an optional header yet, so just skip
579  // past it.
580  CurOffset += Obj->getOptionalHeaderSize();
581 
582  // Parse the section header table if it is present.
583  if (Obj->getNumberOfSections()) {
584  auto SecHeadersOrErr = getObject<void>(Data, Base + CurOffset,
585  Obj->getNumberOfSections() *
586  Obj->getSectionHeaderSize());
587  if (Error E = SecHeadersOrErr.takeError())
588  return std::move(E);
589  Obj->SectionHeaderTable = SecHeadersOrErr.get();
590  }
591 
592  // 64-bit object supports only file header and section headers for now.
593  if (Obj->is64Bit())
594  return std::move(Obj);
595 
596  // If there is no symbol table we are done parsing the memory buffer.
597  if (Obj->getLogicalNumberOfSymbolTableEntries32() == 0)
598  return std::move(Obj);
599 
600  // Parse symbol table.
601  CurOffset = Obj->fileHeader32()->SymbolTableOffset;
602  uint64_t SymbolTableSize = (uint64_t)(sizeof(XCOFFSymbolEntry)) *
603  Obj->getLogicalNumberOfSymbolTableEntries32();
604  auto SymTableOrErr =
605  getObject<XCOFFSymbolEntry>(Data, Base + CurOffset, SymbolTableSize);
606  if (Error E = SymTableOrErr.takeError())
607  return std::move(E);
608  Obj->SymbolTblPtr = SymTableOrErr.get();
609  CurOffset += SymbolTableSize;
610 
611  // Parse String table.
612  Expected<XCOFFStringTable> StringTableOrErr =
613  parseStringTable(Obj.get(), CurOffset);
614  if (Error E = StringTableOrErr.takeError())
615  return std::move(E);
616  Obj->StringTable = StringTableOrErr.get();
617 
618  return std::move(Obj);
619 }
620 
623  unsigned FileType) {
624  return XCOFFObjectFile::create(FileType, MemBufRef);
625 }
626 
629 }
630 
633 }
634 
636  return OwningObjectPtr->toSymbolEntry(SymEntDataRef)->StorageClass;
637 }
638 
640  return OwningObjectPtr->toSymbolEntry(SymEntDataRef)->NumberOfAuxEntries;
641 }
642 
644  assert(!OwningObjectPtr->is64Bit() &&
645  "32-bit interface called on 64-bit object file.");
646  assert(hasCsectAuxEnt() && "No Csect Auxiliary Entry is found.");
647 
648  // In XCOFF32, the csect auxilliary entry is always the last auxiliary
649  // entry for the symbol.
650  uintptr_t AuxAddr = getWithOffset(
651  SymEntDataRef.p, XCOFF::SymbolTableEntrySize * getNumberOfAuxEntries());
652 
653 #ifndef NDEBUG
654  OwningObjectPtr->checkSymbolEntryPointer(AuxAddr);
655 #endif
656 
657  return reinterpret_cast<const XCOFFCsectAuxEnt32 *>(AuxAddr);
658 }
659 
660 uint16_t XCOFFSymbolRef::getType() const {
661  return OwningObjectPtr->toSymbolEntry(SymEntDataRef)->SymbolType;
662 }
663 
665  return OwningObjectPtr->toSymbolEntry(SymEntDataRef)->SectionNumber;
666 }
667 
669  XCOFF::StorageClass SC = getStorageClass();
670  return (SC == XCOFF::C_EXT || SC == XCOFF::C_WEAKEXT ||
671  SC == XCOFF::C_HIDEXT);
672 }
673 
675  if (OwningObjectPtr->is64Bit())
676  report_fatal_error("64-bit support is unimplemented yet.");
677 
678  if (getType() & FUNCTION_SYM)
679  return true;
680 
681  if (!hasCsectAuxEnt())
682  return false;
683 
684  const XCOFFCsectAuxEnt32 *CsectAuxEnt = getXCOFFCsectAuxEnt32();
685 
686  // A function definition should be a label definition.
687  if ((CsectAuxEnt->SymbolAlignmentAndType & SYM_TYPE_MASK) != XCOFF::XTY_LD)
688  return false;
689 
690  if (CsectAuxEnt->StorageMappingClass != XCOFF::XMC_PR)
691  return false;
692 
693  int16_t SectNum = getSectionNumber();
694  Expected<DataRefImpl> SI = OwningObjectPtr->getSectionByNum(SectNum);
695  if (!SI)
696  return false;
697 
698  return (OwningObjectPtr->getSectionFlags(SI.get()) & XCOFF::STYP_TEXT);
699 }
700 
701 } // namespace object
702 } // namespace llvm
void getRelocationTypeName(DataRefImpl Rel, SmallVectorImpl< char > &Result) const override
Expected< StringRef > getSymbolSectionName(const XCOFFSymbolEntry *SymEntPtr) const
uint64_t getRelocationType(DataRefImpl Rel) const override
bool isSectionData(DataRefImpl Sec) const override
friend class SymbolRef
Definition: ObjectFile.h:239
void moveRelocationNext(DataRefImpl &Rel) const override
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:139
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Expected< section_iterator > getSymbolSection(DataRefImpl Symb) const override
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
friend class SectionRef
Definition: ObjectFile.h:253
basic_symbol_iterator symbol_end() const override
static std::error_code checkOffset(MemoryBufferRef M, uintptr_t Addr, const uint64_t Size)
Definition: Binary.h:163
XCOFF::StorageMappingClass StorageMappingClass
support::big32_t NumberOfSymTableEntries
uint64_t getSymbolValueImpl(DataRefImpl Symb) const override
const uint8_t * base() const
Definition: ObjectFile.h:227
Error takeError()
Take ownership of the stored error.
Definition: Error.h:552
Expected< uint64_t > getStartAddress() const override
static Expected< std::unique_ptr< ObjectFile > > createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType)
Expected< ArrayRef< uint8_t > > getSectionContents(DataRefImpl Sec) const override
uint32_t getSymbolFlags(DataRefImpl Symb) const override
ArrayRef< XCOFFSectionHeader64 > sections64() const
void moveSectionNext(DataRefImpl &Sec) const override
relocation_iterator section_rel_end(DataRefImpl Sec) const override
uint32_t getLogicalNumberOfSymbolTableEntries32() const
uint32_t read32be(const void *P)
Definition: Endian.h:386
const XCOFFSymbolEntry * toSymbolEntry(DataRefImpl Ref) const
Expected< SymbolRef::Type > getSymbolType(DataRefImpl Symb) const override
static Expected< const T * > getObject(MemoryBufferRef M, const void *Ptr, const uint64_t Size=sizeof(T))
The access may reference the value stored in memory.
uint64_t getRelocationOffset(DataRefImpl Rel) const override
Tagged union holding either a T or a Error.
Definition: yaml2obj.h:21
section_iterator section_begin() const override
int32_t getRawNumberOfSymbolTableEntries32() const
content_iterator< SectionRef > section_iterator
Definition: ObjectFile.h:48
StorageClass
Definition: XCOFF.h:76
char SymbolName[XCOFF::NameSize]
uint16_t getOptionalHeaderSize() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
Expected< StringRef > getSymbolName(DataRefImpl Symb) const override
SubtargetFeatures getFeatures() const override
uint64_t getSectionAlignment(DataRefImpl Sec) const override
support::ubig16_t NumberOfSections
void moveSymbolNext(DataRefImpl &Symb) const override
Program Code.
Definition: XCOFF.h:30
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
uint64_t getSectionAddress(DataRefImpl Sec) const override
unsigned int getType() const
Definition: Binary.h:99
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Definition: Error.cpp:87
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override
int32_t getSectionFlags(DataRefImpl Sec) const
uint32_t getNumberOfSymbolTableEntries64() const
bool isSectionText(DataRefImpl Sec) const override
relocation_iterator section_rel_begin(DataRefImpl Sec) const override
void checkSymbolEntryPointer(uintptr_t SymbolEntPtr) const
Label definition.
Definition: XCOFF.h:146
Triple::ArchType getArch() const override
XCOFF::StorageClass StorageClass
basic_symbol_iterator symbol_begin() const override
const XCOFFCsectAuxEnt32 * getXCOFFCsectAuxEnt32() const
static const T * viewAs(uintptr_t in)
Expected< uint64_t > getSymbolAddress(DataRefImpl Symb) const override
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
uint64_t getSectionSize(DataRefImpl Sec) const override
uint8_t getBytesInAddress() const override
The number of bytes used to represent an address in this object file format.
section_iterator section_end() const override
FileType
Defines the file type this file represents.
Definition: InterfaceFile.h:57
friend class RelocationRef
Definition: ObjectFile.h:278
XCOFF::StorageClass getStorageClass() const
support::ubig64_t SymbolTableOffset
CHAIN = SC CHAIN, Imm128 - System call.
bool isSectionCompressed(DataRefImpl Sec) const override
support::ubig16_t NumberOfSections
reference get()
Returns a reference to the stored T value.
Definition: Error.h:532
bool isSectionBSS(DataRefImpl Sec) const override
content_iterator< BasicSymbolRef > basic_symbol_iterator
Definition: SymbolicFile.h:138
bool isRelocatableObject() const override
True if this is a relocatable object (.o/.obj).
MemoryBufferRef Data
Definition: Binary.h:37
Manages the enabling and disabling of subtarget specific features.
uint64_t getSymbolTableOffset64() const
uint32_t getSymbolTableOffset32() const
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override
Expected< StringRef > getSectionName(DataRefImpl Sec) const override
Expected< DataRefImpl > getSectionByNum(int16_t Num) const
uint32_t Size
Definition: Profile.cpp:46
static uintptr_t getWithOffset(uintptr_t Base, ptrdiff_t Offset)
uint64_t getSectionIndex(DataRefImpl Sec) const override
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
support::ubig32_t SymbolTableOffset
StringRef getFileFormatName() const override
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
content_iterator< RelocationRef > relocation_iterator
Definition: ObjectFile.h:77
support::ubig32_t NumberOfSymTableEntries
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
Expected< StringRef > getCFileName(const XCOFFFileAuxEnt *CFileEntPtr) const
char Name[XCOFF::NameSize+XCOFF::FileNamePadSize]
uint32_t getSymbolIndex(uintptr_t SymEntPtr) const
static StringRef generateXCOFFFixedNameStringRef(const char *Name)
bool isSectionVirtual(DataRefImpl Sec) const override
ArrayRef< XCOFFSectionHeader32 > sections32() const