LLVM  14.0.0git
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 "llvm/ADT/StringSwitch.h"
17 #include <cstddef>
18 #include <cstring>
19 
20 namespace llvm {
21 
22 using namespace XCOFF;
23 
24 namespace object {
25 
26 static const uint8_t FunctionSym = 0x20;
27 static const uint16_t NoRelMask = 0x0001;
28 static const size_t SymbolAuxTypeOffset = 17;
29 
30 // Checks that [Ptr, Ptr + Size) bytes fall inside the memory buffer
31 // 'M'. Returns a pointer to the underlying object on success.
32 template <typename T>
33 static Expected<const T *> getObject(MemoryBufferRef M, const void *Ptr,
34  const uint64_t Size = sizeof(T)) {
35  uintptr_t Addr = reinterpret_cast<uintptr_t>(Ptr);
36  if (Error E = Binary::checkOffset(M, Addr, Size))
37  return std::move(E);
38  return reinterpret_cast<const T *>(Addr);
39 }
40 
41 static uintptr_t getWithOffset(uintptr_t Base, ptrdiff_t Offset) {
42  return reinterpret_cast<uintptr_t>(reinterpret_cast<const char *>(Base) +
43  Offset);
44 }
45 
46 template <typename T> static const T *viewAs(uintptr_t in) {
47  return reinterpret_cast<const T *>(in);
48 }
49 
51  auto NulCharPtr =
52  static_cast<const char *>(memchr(Name, '\0', XCOFF::NameSize));
53  return NulCharPtr ? StringRef(Name, NulCharPtr - Name)
55 }
56 
57 template <typename T> StringRef XCOFFSectionHeader<T>::getName() const {
58  const T &DerivedXCOFFSectionHeader = static_cast<const T &>(*this);
59  return generateXCOFFFixedNameStringRef(DerivedXCOFFSectionHeader.Name);
60 }
61 
62 template <typename T> uint16_t XCOFFSectionHeader<T>::getSectionType() const {
63  const T &DerivedXCOFFSectionHeader = static_cast<const T &>(*this);
64  return DerivedXCOFFSectionHeader.Flags & SectionFlagsTypeMask;
65 }
66 
67 template <typename T>
69  return getSectionType() & SectionFlagsReservedMask;
70 }
71 
72 template <typename AddressType>
74  return Info & XR_SIGN_INDICATOR_MASK;
75 }
76 
77 template <typename AddressType>
79  return Info & XR_FIXUP_INDICATOR_MASK;
80 }
81 
82 template <typename AddressType>
84  // The relocation encodes the bit length being relocated minus 1. Add back
85  // the 1 to get the actual length being relocated.
86  return (Info & XR_BIASED_LENGTH_MASK) + 1;
87 }
88 
89 uintptr_t
90 XCOFFObjectFile::getAdvancedSymbolEntryAddress(uintptr_t CurrentAddress,
91  uint32_t Distance) {
92  return getWithOffset(CurrentAddress, Distance * XCOFF::SymbolTableEntrySize);
93 }
94 
96 XCOFFObjectFile::getSymbolAuxType(uintptr_t AuxEntryAddress) const {
97  assert(is64Bit() && "64-bit interface called on a 32-bit object file.");
98  return viewAs<XCOFF::SymbolAuxType>(
99  getWithOffset(AuxEntryAddress, SymbolAuxTypeOffset));
100 }
101 
102 void XCOFFObjectFile::checkSectionAddress(uintptr_t Addr,
103  uintptr_t TableAddress) const {
104  if (Addr < TableAddress)
105  report_fatal_error("Section header outside of section header table.");
106 
107  uintptr_t Offset = Addr - TableAddress;
108  if (Offset >= getSectionHeaderSize() * getNumberOfSections())
109  report_fatal_error("Section header outside of section header table.");
110 
111  if (Offset % getSectionHeaderSize() != 0)
113  "Section header pointer does not point to a valid section header.");
114 }
115 
116 const XCOFFSectionHeader32 *
117 XCOFFObjectFile::toSection32(DataRefImpl Ref) const {
118  assert(!is64Bit() && "32-bit interface called on 64-bit object file.");
119 #ifndef NDEBUG
120  checkSectionAddress(Ref.p, getSectionHeaderTableAddress());
121 #endif
122  return viewAs<XCOFFSectionHeader32>(Ref.p);
123 }
124 
125 const XCOFFSectionHeader64 *
126 XCOFFObjectFile::toSection64(DataRefImpl Ref) const {
127  assert(is64Bit() && "64-bit interface called on a 32-bit object file.");
128 #ifndef NDEBUG
129  checkSectionAddress(Ref.p, getSectionHeaderTableAddress());
130 #endif
131  return viewAs<XCOFFSectionHeader64>(Ref.p);
132 }
133 
134 XCOFFSymbolRef XCOFFObjectFile::toSymbolRef(DataRefImpl Ref) const {
135  assert(Ref.p != 0 && "Symbol table pointer can not be nullptr!");
136 #ifndef NDEBUG
137  checkSymbolEntryPointer(Ref.p);
138 #endif
139  return XCOFFSymbolRef(Ref, this);
140 }
141 
142 const XCOFFFileHeader32 *XCOFFObjectFile::fileHeader32() const {
143  assert(!is64Bit() && "32-bit interface called on 64-bit object file.");
144  return static_cast<const XCOFFFileHeader32 *>(FileHeader);
145 }
146 
147 const XCOFFFileHeader64 *XCOFFObjectFile::fileHeader64() const {
148  assert(is64Bit() && "64-bit interface called on a 32-bit object file.");
149  return static_cast<const XCOFFFileHeader64 *>(FileHeader);
150 }
151 
152 template <typename T> const T *XCOFFObjectFile::sectionHeaderTable() const {
153  return static_cast<const T *>(SectionHeaderTable);
154 }
155 
156 const XCOFFSectionHeader32 *
157 XCOFFObjectFile::sectionHeaderTable32() const {
158  assert(!is64Bit() && "32-bit interface called on 64-bit object file.");
159  return static_cast<const XCOFFSectionHeader32 *>(SectionHeaderTable);
160 }
161 
162 const XCOFFSectionHeader64 *
163 XCOFFObjectFile::sectionHeaderTable64() const {
164  assert(is64Bit() && "64-bit interface called on a 32-bit object file.");
165  return static_cast<const XCOFFSectionHeader64 *>(SectionHeaderTable);
166 }
167 
168 void XCOFFObjectFile::moveSymbolNext(DataRefImpl &Symb) const {
169  uintptr_t NextSymbolAddr = getAdvancedSymbolEntryAddress(
170  Symb.p, toSymbolRef(Symb).getNumberOfAuxEntries() + 1);
171 #ifndef NDEBUG
172  // This function is used by basic_symbol_iterator, which allows to
173  // point to the end-of-symbol-table address.
174  if (NextSymbolAddr != getEndOfSymbolTableAddress())
175  checkSymbolEntryPointer(NextSymbolAddr);
176 #endif
177  Symb.p = NextSymbolAddr;
178 }
179 
181 XCOFFObjectFile::getStringTableEntry(uint32_t Offset) const {
182  // The byte offset is relative to the start of the string table.
183  // A byte offset value of 0 is a null or zero-length symbol
184  // name. A byte offset in the range 1 to 3 (inclusive) points into the length
185  // field; as a soft-error recovery mechanism, we treat such cases as having an
186  // offset of 0.
187  if (Offset < 4)
188  return StringRef(nullptr, 0);
189 
190  if (StringTable.Data != nullptr && StringTable.Size > Offset)
191  return (StringTable.Data + Offset);
192 
193  return make_error<GenericBinaryError>("Bad offset for string table entry",
194  object_error::parse_failed);
195 }
196 
197 StringRef XCOFFObjectFile::getStringTable() const {
198  // If the size is less than or equal to 4, then the string table contains no
199  // string data.
200  return StringRef(StringTable.Data,
201  StringTable.Size <= 4 ? 0 : StringTable.Size);
202 }
203 
205 XCOFFObjectFile::getCFileName(const XCOFFFileAuxEnt *CFileEntPtr) const {
206  if (CFileEntPtr->NameInStrTbl.Magic != XCOFFSymbolRef::NAME_IN_STR_TBL_MAGIC)
207  return generateXCOFFFixedNameStringRef(CFileEntPtr->Name);
208  return getStringTableEntry(CFileEntPtr->NameInStrTbl.Offset);
209 }
210 
212  return toSymbolRef(Symb).getName();
213 }
214 
215 Expected<uint64_t> XCOFFObjectFile::getSymbolAddress(DataRefImpl Symb) const {
216  return toSymbolRef(Symb).getValue();
217 }
218 
219 uint64_t XCOFFObjectFile::getSymbolValueImpl(DataRefImpl Symb) const {
220  return toSymbolRef(Symb).getValue();
221 }
222 
223 uint64_t XCOFFObjectFile::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
224  uint64_t Result = 0;
225  llvm_unreachable("Not yet implemented!");
226  return Result;
227 }
228 
231  // TODO: Return the correct symbol type.
232  return SymbolRef::ST_Other;
233 }
234 
236 XCOFFObjectFile::getSymbolSection(DataRefImpl Symb) const {
237  const int16_t SectNum = toSymbolRef(Symb).getSectionNumber();
238 
239  if (isReservedSectionNumber(SectNum))
240  return section_end();
241 
242  Expected<DataRefImpl> ExpSec = getSectionByNum(SectNum);
243  if (!ExpSec)
244  return ExpSec.takeError();
245 
246  return section_iterator(SectionRef(ExpSec.get(), this));
247 }
248 
249 void XCOFFObjectFile::moveSectionNext(DataRefImpl &Sec) const {
250  const char *Ptr = reinterpret_cast<const char *>(Sec.p);
251  Sec.p = reinterpret_cast<uintptr_t>(Ptr + getSectionHeaderSize());
252 }
253 
254 Expected<StringRef> XCOFFObjectFile::getSectionName(DataRefImpl Sec) const {
255  return generateXCOFFFixedNameStringRef(getSectionNameInternal(Sec));
256 }
257 
258 uint64_t XCOFFObjectFile::getSectionAddress(DataRefImpl Sec) const {
259  // Avoid ternary due to failure to convert the ubig32_t value to a unit64_t
260  // with MSVC.
261  if (is64Bit())
262  return toSection64(Sec)->VirtualAddress;
263 
264  return toSection32(Sec)->VirtualAddress;
265 }
266 
267 uint64_t XCOFFObjectFile::getSectionIndex(DataRefImpl Sec) const {
268  // Section numbers in XCOFF are numbered beginning at 1. A section number of
269  // zero is used to indicate that a symbol is being imported or is undefined.
270  if (is64Bit())
271  return toSection64(Sec) - sectionHeaderTable64() + 1;
272  else
273  return toSection32(Sec) - sectionHeaderTable32() + 1;
274 }
275 
276 uint64_t XCOFFObjectFile::getSectionSize(DataRefImpl Sec) const {
277  // Avoid ternary due to failure to convert the ubig32_t value to a unit64_t
278  // with MSVC.
279  if (is64Bit())
280  return toSection64(Sec)->SectionSize;
281 
282  return toSection32(Sec)->SectionSize;
283 }
284 
286 XCOFFObjectFile::getSectionContents(DataRefImpl Sec) const {
287  if (isSectionVirtual(Sec))
288  return ArrayRef<uint8_t>();
289 
290  uint64_t OffsetToRaw;
291  if (is64Bit())
292  OffsetToRaw = toSection64(Sec)->FileOffsetToRawData;
293  else
294  OffsetToRaw = toSection32(Sec)->FileOffsetToRawData;
295 
296  const uint8_t * ContentStart = base() + OffsetToRaw;
297  uint64_t SectionSize = getSectionSize(Sec);
298  if (Error E = Binary::checkOffset(
299  Data, reinterpret_cast<uintptr_t>(ContentStart), SectionSize))
300  return std::move(E);
301 
302  return makeArrayRef(ContentStart,SectionSize);
303 }
304 
305 uint64_t XCOFFObjectFile::getSectionAlignment(DataRefImpl Sec) const {
306  uint64_t Result = 0;
307  llvm_unreachable("Not yet implemented!");
308  return Result;
309 }
310 
311 Expected<uintptr_t> XCOFFObjectFile::getLoaderSectionAddress() const {
312  uint64_t OffsetToLoaderSection = 0;
313  uint64_t SizeOfLoaderSection = 0;
314 
315  if (is64Bit()) {
316  for (const auto &Sec64 : sections64())
317  if (Sec64.getSectionType() == XCOFF::STYP_LOADER) {
318  OffsetToLoaderSection = Sec64.FileOffsetToRawData;
319  SizeOfLoaderSection = Sec64.SectionSize;
320  break;
321  }
322  } else {
323  for (const auto &Sec32 : sections32())
324  if (Sec32.getSectionType() == XCOFF::STYP_LOADER) {
325  OffsetToLoaderSection = Sec32.FileOffsetToRawData;
326  SizeOfLoaderSection = Sec32.SectionSize;
327  break;
328  }
329  }
330 
331  // No loader section is not an error.
332  if (!SizeOfLoaderSection)
333  return 0;
334 
335  uintptr_t LoderSectionStart =
336  reinterpret_cast<uintptr_t>(base() + OffsetToLoaderSection);
337  if (Error E =
338  Binary::checkOffset(Data, LoderSectionStart, SizeOfLoaderSection))
339  return std::move(E);
340  return LoderSectionStart;
341 }
342 
343 bool XCOFFObjectFile::isSectionCompressed(DataRefImpl Sec) const {
344  return false;
345 }
346 
347 bool XCOFFObjectFile::isSectionText(DataRefImpl Sec) const {
348  return getSectionFlags(Sec) & XCOFF::STYP_TEXT;
349 }
350 
351 bool XCOFFObjectFile::isSectionData(DataRefImpl Sec) const {
352  uint32_t Flags = getSectionFlags(Sec);
353  return Flags & (XCOFF::STYP_DATA | XCOFF::STYP_TDATA);
354 }
355 
356 bool XCOFFObjectFile::isSectionBSS(DataRefImpl Sec) const {
357  uint32_t Flags = getSectionFlags(Sec);
358  return Flags & (XCOFF::STYP_BSS | XCOFF::STYP_TBSS);
359 }
360 
361 bool XCOFFObjectFile::isDebugSection(DataRefImpl Sec) const {
362  uint32_t Flags = getSectionFlags(Sec);
363  return Flags & (XCOFF::STYP_DEBUG | XCOFF::STYP_DWARF);
364 }
365 
366 bool XCOFFObjectFile::isSectionVirtual(DataRefImpl Sec) const {
367  return is64Bit() ? toSection64(Sec)->FileOffsetToRawData == 0
368  : toSection32(Sec)->FileOffsetToRawData == 0;
369 }
370 
371 relocation_iterator XCOFFObjectFile::section_rel_begin(DataRefImpl Sec) const {
373  if (is64Bit()) {
374  const XCOFFSectionHeader64 *SectionEntPtr = toSection64(Sec);
375  auto RelocationsOrErr =
376  relocations<XCOFFSectionHeader64, XCOFFRelocation64>(*SectionEntPtr);
377  if (Error E = RelocationsOrErr.takeError()) {
378  // TODO: report the error up the stack.
381  }
382  Ret.p = reinterpret_cast<uintptr_t>(&*RelocationsOrErr.get().begin());
383  } else {
384  const XCOFFSectionHeader32 *SectionEntPtr = toSection32(Sec);
385  auto RelocationsOrErr =
386  relocations<XCOFFSectionHeader32, XCOFFRelocation32>(*SectionEntPtr);
387  if (Error E = RelocationsOrErr.takeError()) {
388  // TODO: report the error up the stack.
391  }
392  Ret.p = reinterpret_cast<uintptr_t>(&*RelocationsOrErr.get().begin());
393  }
394  return relocation_iterator(RelocationRef(Ret, this));
395 }
396 
397 relocation_iterator XCOFFObjectFile::section_rel_end(DataRefImpl Sec) const {
399  if (is64Bit()) {
400  const XCOFFSectionHeader64 *SectionEntPtr = toSection64(Sec);
401  auto RelocationsOrErr =
402  relocations<XCOFFSectionHeader64, XCOFFRelocation64>(*SectionEntPtr);
403  if (Error E = RelocationsOrErr.takeError()) {
404  // TODO: report the error up the stack.
407  }
408  Ret.p = reinterpret_cast<uintptr_t>(&*RelocationsOrErr.get().end());
409  } else {
410  const XCOFFSectionHeader32 *SectionEntPtr = toSection32(Sec);
411  auto RelocationsOrErr =
412  relocations<XCOFFSectionHeader32, XCOFFRelocation32>(*SectionEntPtr);
413  if (Error E = RelocationsOrErr.takeError()) {
414  // TODO: report the error up the stack.
417  }
418  Ret.p = reinterpret_cast<uintptr_t>(&*RelocationsOrErr.get().end());
419  }
420  return relocation_iterator(RelocationRef(Ret, this));
421 }
422 
423 void XCOFFObjectFile::moveRelocationNext(DataRefImpl &Rel) const {
424  if (is64Bit())
425  Rel.p = reinterpret_cast<uintptr_t>(viewAs<XCOFFRelocation64>(Rel.p) + 1);
426  else
427  Rel.p = reinterpret_cast<uintptr_t>(viewAs<XCOFFRelocation32>(Rel.p) + 1);
428 }
429 
430 uint64_t XCOFFObjectFile::getRelocationOffset(DataRefImpl Rel) const {
431  if (is64Bit()) {
432  const XCOFFRelocation64 *Reloc = viewAs<XCOFFRelocation64>(Rel.p);
433  const XCOFFSectionHeader64 *Sec64 = sectionHeaderTable64();
434  const uint64_t RelocAddress = Reloc->VirtualAddress;
435  const uint16_t NumberOfSections = getNumberOfSections();
436  for (uint16_t I = 0; I < NumberOfSections; ++I) {
437  // Find which section this relocation belongs to, and get the
438  // relocation offset relative to the start of the section.
439  if (Sec64->VirtualAddress <= RelocAddress &&
440  RelocAddress < Sec64->VirtualAddress + Sec64->SectionSize) {
441  return RelocAddress - Sec64->VirtualAddress;
442  }
443  ++Sec64;
444  }
445  } else {
446  const XCOFFRelocation32 *Reloc = viewAs<XCOFFRelocation32>(Rel.p);
447  const XCOFFSectionHeader32 *Sec32 = sectionHeaderTable32();
448  const uint32_t RelocAddress = Reloc->VirtualAddress;
449  const uint16_t NumberOfSections = getNumberOfSections();
450  for (uint16_t I = 0; I < NumberOfSections; ++I) {
451  // Find which section this relocation belongs to, and get the
452  // relocation offset relative to the start of the section.
453  if (Sec32->VirtualAddress <= RelocAddress &&
454  RelocAddress < Sec32->VirtualAddress + Sec32->SectionSize) {
455  return RelocAddress - Sec32->VirtualAddress;
456  }
457  ++Sec32;
458  }
459  }
460  return InvalidRelocOffset;
461 }
462 
463 symbol_iterator XCOFFObjectFile::getRelocationSymbol(DataRefImpl Rel) const {
464  uint32_t Index;
465  if (is64Bit()) {
466  const XCOFFRelocation64 *Reloc = viewAs<XCOFFRelocation64>(Rel.p);
467  Index = Reloc->SymbolIndex;
468 
469  if (Index >= getNumberOfSymbolTableEntries64())
470  return symbol_end();
471  } else {
472  const XCOFFRelocation32 *Reloc = viewAs<XCOFFRelocation32>(Rel.p);
473  Index = Reloc->SymbolIndex;
474 
475  if (Index >= getLogicalNumberOfSymbolTableEntries32())
476  return symbol_end();
477  }
478  DataRefImpl SymDRI;
479  SymDRI.p = getSymbolEntryAddressByIndex(Index);
480  return symbol_iterator(SymbolRef(SymDRI, this));
481 }
482 
483 uint64_t XCOFFObjectFile::getRelocationType(DataRefImpl Rel) const {
484  if (is64Bit())
485  return viewAs<XCOFFRelocation64>(Rel.p)->Type;
486  return viewAs<XCOFFRelocation32>(Rel.p)->Type;
487 }
488 
489 void XCOFFObjectFile::getRelocationTypeName(
490  DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
491  StringRef Res;
492  if (is64Bit()) {
493  const XCOFFRelocation64 *Reloc = viewAs<XCOFFRelocation64>(Rel.p);
494  Res = XCOFF::getRelocationTypeString(Reloc->Type);
495  } else {
496  const XCOFFRelocation32 *Reloc = viewAs<XCOFFRelocation32>(Rel.p);
497  Res = XCOFF::getRelocationTypeString(Reloc->Type);
498  }
499  Result.append(Res.begin(), Res.end());
500 }
501 
502 Expected<uint32_t> XCOFFObjectFile::getSymbolFlags(DataRefImpl Symb) const {
503  uint32_t Result = 0;
504  // TODO: Return correct symbol flags.
505  return Result;
506 }
507 
508 basic_symbol_iterator XCOFFObjectFile::symbol_begin() const {
509  DataRefImpl SymDRI;
510  SymDRI.p = reinterpret_cast<uintptr_t>(SymbolTblPtr);
511  return basic_symbol_iterator(SymbolRef(SymDRI, this));
512 }
513 
514 basic_symbol_iterator XCOFFObjectFile::symbol_end() const {
515  DataRefImpl SymDRI;
516  const uint32_t NumberOfSymbolTableEntries = getNumberOfSymbolTableEntries();
517  SymDRI.p = getSymbolEntryAddressByIndex(NumberOfSymbolTableEntries);
518  return basic_symbol_iterator(SymbolRef(SymDRI, this));
519 }
520 
521 section_iterator XCOFFObjectFile::section_begin() const {
522  DataRefImpl DRI;
523  DRI.p = getSectionHeaderTableAddress();
524  return section_iterator(SectionRef(DRI, this));
525 }
526 
527 section_iterator XCOFFObjectFile::section_end() const {
528  DataRefImpl DRI;
529  DRI.p = getWithOffset(getSectionHeaderTableAddress(),
530  getNumberOfSections() * getSectionHeaderSize());
531  return section_iterator(SectionRef(DRI, this));
532 }
533 
534 uint8_t XCOFFObjectFile::getBytesInAddress() const { return is64Bit() ? 8 : 4; }
535 
536 StringRef XCOFFObjectFile::getFileFormatName() const {
537  return is64Bit() ? "aix5coff64-rs6000" : "aixcoff-rs6000";
538 }
539 
540 Triple::ArchType XCOFFObjectFile::getArch() const {
541  return is64Bit() ? Triple::ppc64 : Triple::ppc;
542 }
543 
545  return SubtargetFeatures();
546 }
547 
548 bool XCOFFObjectFile::isRelocatableObject() const {
549  if (is64Bit())
550  return !(fileHeader64()->Flags & NoRelMask);
551  return !(fileHeader32()->Flags & NoRelMask);
552 }
553 
554 Expected<uint64_t> XCOFFObjectFile::getStartAddress() const {
555  // TODO FIXME Should get from auxiliary_header->o_entry when support for the
556  // auxiliary_header is added.
557  return 0;
558 }
559 
560 StringRef XCOFFObjectFile::mapDebugSectionName(StringRef Name) const {
562  .Case("dwinfo", "debug_info")
563  .Case("dwline", "debug_line")
564  .Case("dwpbnms", "debug_pubnames")
565  .Case("dwpbtyp", "debug_pubtypes")
566  .Case("dwarnge", "debug_aranges")
567  .Case("dwabrev", "debug_abbrev")
568  .Case("dwstr", "debug_str")
569  .Case("dwrnges", "debug_ranges")
570  .Case("dwloc", "debug_loc")
571  .Case("dwframe", "debug_frame")
572  .Case("dwmac", "debug_macinfo")
573  .Default(Name);
574 }
575 
576 size_t XCOFFObjectFile::getFileHeaderSize() const {
577  return is64Bit() ? sizeof(XCOFFFileHeader64) : sizeof(XCOFFFileHeader32);
578 }
579 
580 size_t XCOFFObjectFile::getSectionHeaderSize() const {
581  return is64Bit() ? sizeof(XCOFFSectionHeader64) :
582  sizeof(XCOFFSectionHeader32);
583 }
584 
586  return Binary::ID_XCOFF64 == getType();
587 }
588 
590  return is64Bit() ? fileHeader64()->Magic : fileHeader32()->Magic;
591 }
592 
593 Expected<DataRefImpl> XCOFFObjectFile::getSectionByNum(int16_t Num) const {
594  if (Num <= 0 || Num > getNumberOfSections())
595  return createStringError(object_error::invalid_section_index,
596  "the section index (" + Twine(Num) +
597  ") is invalid");
598 
599  DataRefImpl DRI;
600  DRI.p = getWithOffset(getSectionHeaderTableAddress(),
601  getSectionHeaderSize() * (Num - 1));
602  return DRI;
603 }
604 
606 XCOFFObjectFile::getSymbolSectionName(XCOFFSymbolRef SymEntPtr) const {
607  const int16_t SectionNum = SymEntPtr.getSectionNumber();
608 
609  switch (SectionNum) {
610  case XCOFF::N_DEBUG:
611  return "N_DEBUG";
612  case XCOFF::N_ABS:
613  return "N_ABS";
614  case XCOFF::N_UNDEF:
615  return "N_UNDEF";
616  default:
617  Expected<DataRefImpl> SecRef = getSectionByNum(SectionNum);
618  if (SecRef)
620  getSectionNameInternal(SecRef.get()));
621  return SecRef.takeError();
622  }
623 }
624 
626  XCOFFSymbolRef XCOFFSymRef(Sym.getRawDataRefImpl(), this);
627  return XCOFFSymRef.getSectionNumber();
628 }
629 
630 bool XCOFFObjectFile::isReservedSectionNumber(int16_t SectionNumber) {
631  return (SectionNumber <= 0 && SectionNumber >= -2);
632 }
633 
634 uint16_t XCOFFObjectFile::getNumberOfSections() const {
635  return is64Bit() ? fileHeader64()->NumberOfSections
636  : fileHeader32()->NumberOfSections;
637 }
638 
639 int32_t XCOFFObjectFile::getTimeStamp() const {
640  return is64Bit() ? fileHeader64()->TimeStamp : fileHeader32()->TimeStamp;
641 }
642 
643 uint16_t XCOFFObjectFile::getOptionalHeaderSize() const {
644  return is64Bit() ? fileHeader64()->AuxHeaderSize
645  : fileHeader32()->AuxHeaderSize;
646 }
647 
648 uint32_t XCOFFObjectFile::getSymbolTableOffset32() const {
649  return fileHeader32()->SymbolTableOffset;
650 }
651 
652 int32_t XCOFFObjectFile::getRawNumberOfSymbolTableEntries32() const {
653  // As far as symbol table size is concerned, if this field is negative it is
654  // to be treated as a 0. However since this field is also used for printing we
655  // don't want to truncate any negative values.
656  return fileHeader32()->NumberOfSymTableEntries;
657 }
658 
659 uint32_t XCOFFObjectFile::getLogicalNumberOfSymbolTableEntries32() const {
660  return (fileHeader32()->NumberOfSymTableEntries >= 0
661  ? fileHeader32()->NumberOfSymTableEntries
662  : 0);
663 }
664 
665 uint64_t XCOFFObjectFile::getSymbolTableOffset64() const {
666  return fileHeader64()->SymbolTableOffset;
667 }
668 
669 uint32_t XCOFFObjectFile::getNumberOfSymbolTableEntries64() const {
670  return fileHeader64()->NumberOfSymTableEntries;
671 }
672 
673 uint32_t XCOFFObjectFile::getNumberOfSymbolTableEntries() const {
674  return is64Bit() ? getNumberOfSymbolTableEntries64()
675  : getLogicalNumberOfSymbolTableEntries32();
676 }
677 
678 uintptr_t XCOFFObjectFile::getEndOfSymbolTableAddress() const {
679  const uint32_t NumberOfSymTableEntries = getNumberOfSymbolTableEntries();
680  return getWithOffset(reinterpret_cast<uintptr_t>(SymbolTblPtr),
681  XCOFF::SymbolTableEntrySize * NumberOfSymTableEntries);
682 }
683 
684 void XCOFFObjectFile::checkSymbolEntryPointer(uintptr_t SymbolEntPtr) const {
685  if (SymbolEntPtr < reinterpret_cast<uintptr_t>(SymbolTblPtr))
686  report_fatal_error("Symbol table entry is outside of symbol table.");
687 
688  if (SymbolEntPtr >= getEndOfSymbolTableAddress())
689  report_fatal_error("Symbol table entry is outside of symbol table.");
690 
691  ptrdiff_t Offset = reinterpret_cast<const char *>(SymbolEntPtr) -
692  reinterpret_cast<const char *>(SymbolTblPtr);
693 
696  "Symbol table entry position is not valid inside of symbol table.");
697 }
698 
699 uint32_t XCOFFObjectFile::getSymbolIndex(uintptr_t SymbolEntPtr) const {
700  return (reinterpret_cast<const char *>(SymbolEntPtr) -
701  reinterpret_cast<const char *>(SymbolTblPtr)) /
703 }
704 
705 uintptr_t XCOFFObjectFile::getSymbolEntryAddressByIndex(uint32_t Index) const {
706  return getAdvancedSymbolEntryAddress(
707  reinterpret_cast<uintptr_t>(getPointerToSymbolTable()), Index);
708 }
709 
711 XCOFFObjectFile::getSymbolNameByIndex(uint32_t Index) const {
712  const uint32_t NumberOfSymTableEntries = getNumberOfSymbolTableEntries();
713 
714  if (Index >= NumberOfSymTableEntries)
715  return errorCodeToError(object_error::invalid_symbol_index);
716 
717  DataRefImpl SymDRI;
718  SymDRI.p = getSymbolEntryAddressByIndex(Index);
719  return getSymbolName(SymDRI);
720 }
721 
723  return is64Bit() ? fileHeader64()->Flags : fileHeader32()->Flags;
724 }
725 
726 const char *XCOFFObjectFile::getSectionNameInternal(DataRefImpl Sec) const {
727  return is64Bit() ? toSection64(Sec)->Name : toSection32(Sec)->Name;
728 }
729 
730 uintptr_t XCOFFObjectFile::getSectionHeaderTableAddress() const {
731  return reinterpret_cast<uintptr_t>(SectionHeaderTable);
732 }
733 
735  return is64Bit() ? toSection64(Sec)->Flags : toSection32(Sec)->Flags;
736 }
737 
738 XCOFFObjectFile::XCOFFObjectFile(unsigned int Type, MemoryBufferRef Object)
739  : ObjectFile(Type, Object) {
741 }
742 
744  assert(is64Bit() && "64-bit interface called for non 64-bit file.");
745  const XCOFFSectionHeader64 *TablePtr = sectionHeaderTable64();
746  return ArrayRef<XCOFFSectionHeader64>(TablePtr,
747  TablePtr + getNumberOfSections());
748 }
749 
751  assert(!is64Bit() && "32-bit interface called for non 32-bit file.");
752  const XCOFFSectionHeader32 *TablePtr = sectionHeaderTable32();
753  return ArrayRef<XCOFFSectionHeader32>(TablePtr,
754  TablePtr + getNumberOfSections());
755 }
756 
757 // In an XCOFF32 file, when the field value is 65535, then an STYP_OVRFLO
758 // section header contains the actual count of relocation entries in the s_paddr
759 // field. STYP_OVRFLO headers contain the section index of their corresponding
760 // sections as their raw "NumberOfRelocations" field value.
761 template <typename T>
763  const XCOFFSectionHeader<T> &Sec) const {
764  const T &Section = static_cast<const T &>(Sec);
765  if (is64Bit())
766  return Section.NumberOfRelocations;
767 
768  uint16_t SectionIndex = &Section - sectionHeaderTable<T>() + 1;
769  if (Section.NumberOfRelocations < XCOFF::RelocOverflow)
770  return Section.NumberOfRelocations;
771  for (const auto &Sec : sections32()) {
772  if (Sec.Flags == XCOFF::STYP_OVRFLO &&
773  Sec.NumberOfRelocations == SectionIndex)
774  return Sec.PhysicalAddress;
775  }
777 }
778 
779 template <typename Shdr, typename Reloc>
781  uintptr_t RelocAddr = getWithOffset(reinterpret_cast<uintptr_t>(FileHeader),
782  Sec.FileOffsetToRelocationInfo);
783  auto NumRelocEntriesOrErr = getNumberOfRelocationEntries(Sec);
784  if (Error E = NumRelocEntriesOrErr.takeError())
785  return std::move(E);
786 
787  uint32_t NumRelocEntries = NumRelocEntriesOrErr.get();
788  static_assert((sizeof(Reloc) == XCOFF::RelocationSerializationSize64 ||
789  sizeof(Reloc) == XCOFF::RelocationSerializationSize32),
790  "Relocation structure is incorrect");
791  auto RelocationOrErr =
792  getObject<Reloc>(Data, reinterpret_cast<void *>(RelocAddr),
793  NumRelocEntries * sizeof(Reloc));
794  if (Error E = RelocationOrErr.takeError())
795  return std::move(E);
796 
797  const Reloc *StartReloc = RelocationOrErr.get();
798 
799  return ArrayRef<Reloc>(StartReloc, StartReloc + NumRelocEntries);
800 }
801 
803 XCOFFObjectFile::parseStringTable(const XCOFFObjectFile *Obj, uint64_t Offset) {
804  // If there is a string table, then the buffer must contain at least 4 bytes
805  // for the string table's size. Not having a string table is not an error.
807  Obj->Data, reinterpret_cast<uintptr_t>(Obj->base() + Offset), 4)) {
809  return XCOFFStringTable{0, nullptr};
810  }
811 
812  // Read the size out of the buffer.
814 
815  // If the size is less then 4, then the string table is just a size and no
816  // string data.
817  if (Size <= 4)
818  return XCOFFStringTable{4, nullptr};
819 
820  auto StringTableOrErr =
821  getObject<char>(Obj->Data, Obj->base() + Offset, Size);
822  if (Error E = StringTableOrErr.takeError())
823  return std::move(E);
824 
825  const char *StringTablePtr = StringTableOrErr.get();
826  if (StringTablePtr[Size - 1] != '\0')
828 
829  return XCOFFStringTable{Size, StringTablePtr};
830 }
831 
832 // This function returns the import file table. Each entry in the import file
833 // table consists of: "path_name\0base_name\0archive_member_name\0".
835  Expected<uintptr_t> LoaderSectionAddrOrError = getLoaderSectionAddress();
836  if (!LoaderSectionAddrOrError)
837  return LoaderSectionAddrOrError.takeError();
838 
839  uintptr_t LoaderSectionAddr = LoaderSectionAddrOrError.get();
840  if (!LoaderSectionAddr)
841  return StringRef();
842 
843  uint64_t OffsetToImportFileTable = 0;
844  uint64_t LengthOfImportFileTable = 0;
845  if (is64Bit()) {
846  const LoaderSectionHeader64 *LoaderSec64 =
847  viewAs<LoaderSectionHeader64>(LoaderSectionAddr);
848  OffsetToImportFileTable = LoaderSec64->OffsetToImpid;
849  LengthOfImportFileTable = LoaderSec64->LengthOfImpidStrTbl;
850  } else {
851  const LoaderSectionHeader32 *LoaderSec32 =
852  viewAs<LoaderSectionHeader32>(LoaderSectionAddr);
853  OffsetToImportFileTable = LoaderSec32->OffsetToImpid;
854  LengthOfImportFileTable = LoaderSec32->LengthOfImpidStrTbl;
855  }
856 
857  auto ImportTableOrErr = getObject<char>(
858  Data,
859  reinterpret_cast<void *>(LoaderSectionAddr + OffsetToImportFileTable),
860  LengthOfImportFileTable);
861  if (Error E = ImportTableOrErr.takeError())
862  return std::move(E);
863 
864  const char *ImportTablePtr = ImportTableOrErr.get();
865  if (ImportTablePtr[LengthOfImportFileTable - 1] != '\0')
866  return createStringError(
868  "the import file table must end with a null terminator");
869 
870  return StringRef(ImportTablePtr, LengthOfImportFileTable);
871 }
872 
874 XCOFFObjectFile::create(unsigned Type, MemoryBufferRef MBR) {
875  // Can't use std::make_unique because of the private constructor.
876  std::unique_ptr<XCOFFObjectFile> Obj;
877  Obj.reset(new XCOFFObjectFile(Type, MBR));
878 
879  uint64_t CurOffset = 0;
880  const auto *Base = Obj->base();
881  MemoryBufferRef Data = Obj->Data;
882 
883  // Parse file header.
884  auto FileHeaderOrErr =
885  getObject<void>(Data, Base + CurOffset, Obj->getFileHeaderSize());
886  if (Error E = FileHeaderOrErr.takeError())
887  return std::move(E);
888  Obj->FileHeader = FileHeaderOrErr.get();
889 
890  CurOffset += Obj->getFileHeaderSize();
891  // TODO FIXME we don't have support for an optional header yet, so just skip
892  // past it.
893  CurOffset += Obj->getOptionalHeaderSize();
894 
895  // Parse the section header table if it is present.
896  if (Obj->getNumberOfSections()) {
897  auto SecHeadersOrErr = getObject<void>(Data, Base + CurOffset,
898  Obj->getNumberOfSections() *
899  Obj->getSectionHeaderSize());
900  if (Error E = SecHeadersOrErr.takeError())
901  return std::move(E);
902  Obj->SectionHeaderTable = SecHeadersOrErr.get();
903  }
904 
905  const uint32_t NumberOfSymbolTableEntries =
906  Obj->getNumberOfSymbolTableEntries();
907 
908  // If there is no symbol table we are done parsing the memory buffer.
909  if (NumberOfSymbolTableEntries == 0)
910  return std::move(Obj);
911 
912  // Parse symbol table.
913  CurOffset = Obj->is64Bit() ? Obj->getSymbolTableOffset64()
914  : Obj->getSymbolTableOffset32();
915  const uint64_t SymbolTableSize =
916  static_cast<uint64_t>(XCOFF::SymbolTableEntrySize) *
917  NumberOfSymbolTableEntries;
918  auto SymTableOrErr =
919  getObject<void *>(Data, Base + CurOffset, SymbolTableSize);
920  if (Error E = SymTableOrErr.takeError())
921  return std::move(E);
922  Obj->SymbolTblPtr = SymTableOrErr.get();
923  CurOffset += SymbolTableSize;
924 
925  // Parse String table.
926  Expected<XCOFFStringTable> StringTableOrErr =
927  parseStringTable(Obj.get(), CurOffset);
928  if (Error E = StringTableOrErr.takeError())
929  return std::move(E);
930  Obj->StringTable = StringTableOrErr.get();
931 
932  return std::move(Obj);
933 }
934 
935 Expected<std::unique_ptr<ObjectFile>>
937  unsigned FileType) {
938  return XCOFFObjectFile::create(FileType, MemBufRef);
939 }
940 
942  if (!isCsectSymbol())
943  return false;
944 
945  if (getSymbolType() & FunctionSym)
946  return true;
947 
949  if (!ExpCsectAuxEnt)
950  return false;
951 
952  const XCOFFCsectAuxRef CsectAuxRef = ExpCsectAuxEnt.get();
953 
954  // A function definition should be a label definition.
955  // FIXME: This is not necessarily the case when -ffunction-sections is
956  // enabled.
957  if (!CsectAuxRef.isLabel())
958  return false;
959 
960  if (CsectAuxRef.getStorageMappingClass() != XCOFF::XMC_PR)
961  return false;
962 
963  const int16_t SectNum = getSectionNumber();
964  Expected<DataRefImpl> SI = OwningObjectPtr->getSectionByNum(SectNum);
965  if (!SI) {
966  // If we could not get the section, then this symbol should not be
967  // a function. So consume the error and return `false` to move on.
968  consumeError(SI.takeError());
969  return false;
970  }
971 
972  return (OwningObjectPtr->getSectionFlags(SI.get()) & XCOFF::STYP_TEXT);
973 }
974 
977  return (SC == XCOFF::C_EXT || SC == XCOFF::C_WEAKEXT ||
978  SC == XCOFF::C_HIDEXT);
979 }
980 
982  assert(isCsectSymbol() &&
983  "Calling csect symbol interface with a non-csect symbol.");
984 
985  uint8_t NumberOfAuxEntries = getNumberOfAuxEntries();
986 
987  Expected<StringRef> NameOrErr = getName();
988  if (auto Err = NameOrErr.takeError())
989  return std::move(Err);
990 
991  if (!NumberOfAuxEntries) {
993  "csect symbol \"" + *NameOrErr +
994  "\" contains no auxiliary entry");
995  }
996 
997  if (!OwningObjectPtr->is64Bit()) {
998  // In XCOFF32, the csect auxilliary entry is always the last auxiliary
999  // entry for the symbol.
1001  getEntryAddress(), NumberOfAuxEntries);
1002  return XCOFFCsectAuxRef(viewAs<XCOFFCsectAuxEnt32>(AuxAddr));
1003  }
1004 
1005  // XCOFF64 uses SymbolAuxType to identify the auxiliary entry type.
1006  // We need to iterate through all the auxiliary entries to find it.
1007  for (uint8_t Index = NumberOfAuxEntries; Index > 0; --Index) {
1009  getEntryAddress(), Index);
1010  if (*OwningObjectPtr->getSymbolAuxType(AuxAddr) ==
1012 #ifndef NDEBUG
1013  OwningObjectPtr->checkSymbolEntryPointer(AuxAddr);
1014 #endif
1015  return XCOFFCsectAuxRef(viewAs<XCOFFCsectAuxEnt64>(AuxAddr));
1016  }
1017  }
1018 
1019  return createStringError(
1021  "a csect auxiliary entry is not found for symbol \"" + *NameOrErr + "\"");
1022 }
1023 
1025  // A storage class value with the high-order bit on indicates that the name is
1026  // a symbolic debugger stabstring.
1027  if (getStorageClass() & 0x80)
1028  return StringRef("Unimplemented Debug Name");
1029 
1030  if (Entry32) {
1033 
1034  return OwningObjectPtr->getStringTableEntry(Entry32->NameInStrTbl.Offset);
1035  }
1036 
1037  return OwningObjectPtr->getStringTableEntry(Entry64->Offset);
1038 }
1039 
1040 // Explictly instantiate template classes.
1043 
1046 
1050  llvm::object::XCOFFSectionHeader64 const &) const;
1054  llvm::object::XCOFFSectionHeader32 const &) const;
1055 
1057  if (Bytes.size() < 4)
1058  return false;
1059 
1060  return support::endian::read32be(Bytes.data()) == 0;
1061 }
1062 
1063 #define GETVALUEWITHMASK(X) (Data & (TracebackTable::X))
1064 #define GETVALUEWITHMASKSHIFT(X, S) \
1065  ((Data & (TracebackTable::X)) >> (TracebackTable::S))
1066 
1068  Error Err = Error::success();
1069  TBVectorExt TBTVecExt(TBvectorStrRef, Err);
1070  if (Err)
1071  return std::move(Err);
1072  return TBTVecExt;
1073 }
1074 
1075 TBVectorExt::TBVectorExt(StringRef TBvectorStrRef, Error &Err) {
1076  const uint8_t *Ptr = reinterpret_cast<const uint8_t *>(TBvectorStrRef.data());
1078  uint32_t VecParmsTypeValue = support::endian::read32be(Ptr + 2);
1079  unsigned ParmsNum =
1080  GETVALUEWITHMASKSHIFT(NumberOfVectorParmsMask, NumberOfVectorParmsShift);
1081 
1082  ErrorAsOutParameter EAO(&Err);
1083  Expected<SmallString<32>> VecParmsTypeOrError =
1084  parseVectorParmsType(VecParmsTypeValue, ParmsNum);
1085  if (!VecParmsTypeOrError)
1086  Err = VecParmsTypeOrError.takeError();
1087  else
1088  VecParmsInfo = VecParmsTypeOrError.get();
1089 }
1090 
1092  return GETVALUEWITHMASKSHIFT(NumberOfVRSavedMask, NumberOfVRSavedShift);
1093 }
1094 
1096  return GETVALUEWITHMASK(IsVRSavedOnStackMask);
1097 }
1098 
1100  return GETVALUEWITHMASK(HasVarArgsMask);
1101 }
1102 
1104  return GETVALUEWITHMASKSHIFT(NumberOfVectorParmsMask,
1105  NumberOfVectorParmsShift);
1106 }
1107 
1109  return GETVALUEWITHMASK(HasVMXInstructionMask);
1110 }
1111 #undef GETVALUEWITHMASK
1112 #undef GETVALUEWITHMASKSHIFT
1113 
1115  uint64_t &Size) {
1116  Error Err = Error::success();
1117  XCOFFTracebackTable TBT(Ptr, Size, Err);
1118  if (Err)
1119  return std::move(Err);
1120  return TBT;
1121 }
1122 
1123 XCOFFTracebackTable::XCOFFTracebackTable(const uint8_t *Ptr, uint64_t &Size,
1124  Error &Err)
1125  : TBPtr(Ptr) {
1126  ErrorAsOutParameter EAO(&Err);
1127  DataExtractor DE(ArrayRef<uint8_t>(Ptr, Size), /*IsLittleEndian=*/false,
1128  /*AddressSize=*/0);
1129  DataExtractor::Cursor Cur(/*Offset=*/0);
1130 
1131  // Skip 8 bytes of mandatory fields.
1132  DE.getU64(Cur);
1133 
1134  unsigned FixedParmsNum = getNumberOfFixedParms();
1135  unsigned FloatingParmsNum = getNumberOfFPParms();
1136  uint32_t ParamsTypeValue = 0;
1137 
1138  // Begin to parse optional fields.
1139  if (Cur && (FixedParmsNum + FloatingParmsNum) > 0)
1140  ParamsTypeValue = DE.getU32(Cur);
1141 
1142  if (Cur && hasTraceBackTableOffset())
1143  TraceBackTableOffset = DE.getU32(Cur);
1144 
1145  if (Cur && isInterruptHandler())
1146  HandlerMask = DE.getU32(Cur);
1147 
1148  if (Cur && hasControlledStorage()) {
1149  NumOfCtlAnchors = DE.getU32(Cur);
1150  if (Cur && NumOfCtlAnchors) {
1152  Disp.reserve(NumOfCtlAnchors.getValue());
1153  for (uint32_t I = 0; I < NumOfCtlAnchors && Cur; ++I)
1154  Disp.push_back(DE.getU32(Cur));
1155  if (Cur)
1156  ControlledStorageInfoDisp = std::move(Disp);
1157  }
1158  }
1159 
1160  if (Cur && isFuncNamePresent()) {
1161  uint16_t FunctionNameLen = DE.getU16(Cur);
1162  if (Cur)
1163  FunctionName = DE.getBytes(Cur, FunctionNameLen);
1164  }
1165 
1166  if (Cur && isAllocaUsed())
1167  AllocaRegister = DE.getU8(Cur);
1168 
1169  unsigned VectorParmsNum = 0;
1170  if (Cur && hasVectorInfo()) {
1171  StringRef VectorExtRef = DE.getBytes(Cur, 6);
1172  if (Cur) {
1173  Expected<TBVectorExt> TBVecExtOrErr = TBVectorExt::create(VectorExtRef);
1174  if (!TBVecExtOrErr) {
1175  Err = TBVecExtOrErr.takeError();
1176  return;
1177  }
1178  VecExt = TBVecExtOrErr.get();
1179  VectorParmsNum = VecExt.getValue().getNumberOfVectorParms();
1180  }
1181  }
1182 
1183  // As long as there is no fixed-point or floating-point parameter, this
1184  // field remains not present even when hasVectorInfo gives true and
1185  // indicates the presence of vector parameters.
1186  if (Cur && (FixedParmsNum + FloatingParmsNum) > 0) {
1187  Expected<SmallString<32>> ParmsTypeOrError =
1188  hasVectorInfo()
1189  ? parseParmsTypeWithVecInfo(ParamsTypeValue, FixedParmsNum,
1190  FloatingParmsNum, VectorParmsNum)
1191  : parseParmsType(ParamsTypeValue, FixedParmsNum, FloatingParmsNum);
1192 
1193  if (!ParmsTypeOrError) {
1194  Err = ParmsTypeOrError.takeError();
1195  return;
1196  }
1197  ParmsType = ParmsTypeOrError.get();
1198  }
1199 
1200  if (Cur && hasExtensionTable())
1201  ExtensionTable = DE.getU8(Cur);
1202 
1203  if (!Cur)
1204  Err = Cur.takeError();
1205 
1206  Size = Cur.tell();
1207 }
1208 
1209 #define GETBITWITHMASK(P, X) \
1210  (support::endian::read32be(TBPtr + (P)) & (TracebackTable::X))
1211 #define GETBITWITHMASKSHIFT(P, X, S) \
1212  ((support::endian::read32be(TBPtr + (P)) & (TracebackTable::X)) >> \
1213  (TracebackTable::S))
1214 
1216  return GETBITWITHMASKSHIFT(0, VersionMask, VersionShift);
1217 }
1218 
1220  return GETBITWITHMASKSHIFT(0, LanguageIdMask, LanguageIdShift);
1221 }
1222 
1224  return GETBITWITHMASK(0, IsGlobaLinkageMask);
1225 }
1226 
1228  return GETBITWITHMASK(0, IsOutOfLineEpilogOrPrologueMask);
1229 }
1230 
1232  return GETBITWITHMASK(0, HasTraceBackTableOffsetMask);
1233 }
1234 
1236  return GETBITWITHMASK(0, IsInternalProcedureMask);
1237 }
1238 
1240  return GETBITWITHMASK(0, HasControlledStorageMask);
1241 }
1242 
1244  return GETBITWITHMASK(0, IsTOClessMask);
1245 }
1246 
1248  return GETBITWITHMASK(0, IsFloatingPointPresentMask);
1249 }
1250 
1252  return GETBITWITHMASK(0, IsFloatingPointOperationLogOrAbortEnabledMask);
1253 }
1254 
1256  return GETBITWITHMASK(0, IsInterruptHandlerMask);
1257 }
1258 
1260  return GETBITWITHMASK(0, IsFunctionNamePresentMask);
1261 }
1262 
1264  return GETBITWITHMASK(0, IsAllocaUsedMask);
1265 }
1266 
1268  return GETBITWITHMASKSHIFT(0, OnConditionDirectiveMask,
1269  OnConditionDirectiveShift);
1270 }
1271 
1273  return GETBITWITHMASK(0, IsCRSavedMask);
1274 }
1275 
1277  return GETBITWITHMASK(0, IsLRSavedMask);
1278 }
1279 
1281  return GETBITWITHMASK(4, IsBackChainStoredMask);
1282 }
1283 
1285  return GETBITWITHMASK(4, IsFixupMask);
1286 }
1287 
1289  return GETBITWITHMASKSHIFT(4, FPRSavedMask, FPRSavedShift);
1290 }
1291 
1293  return GETBITWITHMASK(4, HasExtensionTableMask);
1294 }
1295 
1297  return GETBITWITHMASK(4, HasVectorInfoMask);
1298 }
1299 
1301  return GETBITWITHMASKSHIFT(4, GPRSavedMask, GPRSavedShift);
1302 }
1303 
1305  return GETBITWITHMASKSHIFT(4, NumberOfFixedParmsMask,
1306  NumberOfFixedParmsShift);
1307 }
1308 
1310  return GETBITWITHMASKSHIFT(4, NumberOfFloatingPointParmsMask,
1311  NumberOfFloatingPointParmsShift);
1312 }
1313 
1315  return GETBITWITHMASK(4, HasParmsOnStackMask);
1316 }
1317 
1318 #undef GETBITWITHMASK
1319 #undef GETBITWITHMASKSHIFT
1320 } // namespace object
1321 } // namespace llvm
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::StringSwitch::Case
StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:67
llvm::object::XCOFFTracebackTable::isTOCless
bool isTOCless() const
Definition: XCOFFObjectFile.cpp:1243
llvm::object::XCOFFTracebackTable::isInterruptHandler
bool isInterruptHandler() const
Definition: XCOFFObjectFile.cpp:1255
getName
static StringRef getName(Value *V)
Definition: ProvenanceAnalysisEvaluator.cpp:42
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::object::XCOFFSectionHeader32
Definition: XCOFFObjectFile.h:73
llvm::object::XCOFFTracebackTable::hasParmsOnStack
bool hasParmsOnStack() const
Definition: XCOFFObjectFile.cpp:1314
llvm::object::XCOFFSymbolRef::getXCOFFCsectAuxRef
Expected< XCOFFCsectAuxRef > getXCOFFCsectAuxRef() const
Definition: XCOFFObjectFile.cpp:981
llvm::object::TBVectorExt::hasVarArgs
bool hasVarArgs() const
Definition: XCOFFObjectFile.cpp:1099
llvm::object::XCOFFSymbolRef::getName
Expected< StringRef > getName() const
Definition: XCOFFObjectFile.cpp:1024
llvm::XCOFF::RelocationSerializationSize64
constexpr size_t RelocationSerializationSize64
Definition: XCOFF.h:36
llvm::object::XCOFFFileHeader32
Definition: XCOFFObjectFile.h:26
llvm::StringSwitch::Default
LLVM_NODISCARD R Default(T Value)
Definition: StringSwitch.h:181
is64Bit
static bool is64Bit(const char *name)
Definition: X86Disassembler.cpp:1023
llvm::XCOFF::STYP_BSS
@ STYP_BSS
Definition: XCOFF.h:82
llvm::SmallVector< uint32_t, 8 >
llvm::object::XCOFFRelocation::VirtualAddress
AddressType VirtualAddress
Definition: XCOFFObjectFile.h:272
llvm::object::XCOFFTracebackTable::isFloatingPointPresent
bool isFloatingPointPresent() const
Definition: XCOFFObjectFile.cpp:1247
llvm::object::NoRelMask
static const uint16_t NoRelMask
Definition: XCOFFObjectFile.cpp:27
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
llvm::object::XCOFFTracebackTable::getVersion
uint8_t getVersion() const
Definition: XCOFFObjectFile.cpp:1215
llvm::XCOFF::XMC_PR
@ XMC_PR
Program Code.
Definition: XCOFF.h:48
llvm::object::XCOFFTracebackTable::isBackChainStored
bool isBackChainStored() const
Definition: XCOFFObjectFile.cpp:1280
llvm::object::LoaderSectionHeader64::OffsetToImpid
support::big64_t OffsetToImpid
Definition: XCOFFObjectFile.h:118
llvm::object::XCOFFSectionHeader
Definition: XCOFFObjectFile.h:54
llvm::object::getWithOffset
static uintptr_t getWithOffset(uintptr_t Base, ptrdiff_t Offset)
Definition: XCOFFObjectFile.cpp:41
llvm::object::relocation_iterator
content_iterator< RelocationRef > relocation_iterator
Definition: ObjectFile.h:76
llvm::object::XCOFFObjectFile::is64Bit
bool is64Bit() const
Definition: XCOFFObjectFile.cpp:585
llvm::object::XCOFFTracebackTable::isOutOfLineEpilogOrPrologue
bool isOutOfLineEpilogOrPrologue() const
Definition: XCOFFObjectFile.cpp:1227
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::object::XCOFFRelocation64
Definition: XCOFFObjectFile.h:292
llvm::object::Binary::Data
MemoryBufferRef Data
Definition: Binary.h:37
llvm::object::XCOFFFileAuxEnt::NameInStrTblType::Magic
support::big32_t Magic
Definition: XCOFFObjectFile.h:236
llvm::Triple::ppc
@ ppc
Definition: Triple.h:67
llvm::object::TBVectorExt::hasVMXInstruction
bool hasVMXInstruction() const
Definition: XCOFFObjectFile.cpp:1108
T
#define T
Definition: Mips16ISelLowering.cpp:341
GETBITWITHMASKSHIFT
#define GETBITWITHMASKSHIFT(P, X, S)
Definition: XCOFFObjectFile.cpp:1211
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::object::XCOFFFileAuxEnt::Name
char Name[XCOFF::NameSize+XCOFF::FileNamePadSize]
Definition: XCOFFObjectFile.h:241
llvm::RawInstrProf::getMagic
uint64_t getMagic()
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:116
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::support::endian::read32be
uint32_t read32be(const void *P)
Definition: Endian.h:384
llvm::XCOFF::STYP_LOADER
@ STYP_LOADER
Definition: XCOFF.h:87
llvm::object::XCOFFSymbolRef::getNumberOfAuxEntries
uint8_t getNumberOfAuxEntries() const
Definition: XCOFFObjectFile.h:560
llvm::object::XCOFFFileHeader64
Definition: XCOFFObjectFile.h:40
llvm::object::LoaderSectionHeader64::LengthOfImpidStrTbl
support::ubig32_t LengthOfImpidStrTbl
Definition: XCOFFObjectFile.h:115
llvm::consumeError
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:1035
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
llvm::object::XCOFFSymbolRef::isFunction
bool isFunction() const
Definition: XCOFFObjectFile.cpp:941
llvm::XCOFF::STYP_DWARF
@ STYP_DWARF
Definition: XCOFF.h:79
llvm::ArrayRef::data
const T * data() const
Definition: ArrayRef.h:162
llvm::object::XCOFFCsectAuxRef
Definition: XCOFFObjectFile.h:151
llvm::object::XCOFFObjectFile::getImportFileTable
Expected< StringRef > getImportFileTable() const
Definition: XCOFFObjectFile.cpp:834
llvm::object::XCOFFSymbolRef
Definition: XCOFFObjectFile.h:517
llvm::ARMBuildAttrs::Section
@ Section
Legacy Tags.
Definition: ARMBuildAttributes.h:78
llvm::object::XCOFFSectionHeader32::VirtualAddress
support::ubig32_t VirtualAddress
Definition: XCOFFObjectFile.h:76
llvm::object::XCOFFObjectFile::getSectionByNum
Expected< DataRefImpl > getSectionByNum(int16_t Num) const
Definition: XCOFFObjectFile.cpp:593
getSectionFlags
static uint32_t getSectionFlags(const MachOObjectFile &O, DataRefImpl Sec)
Definition: MachOObjectFile.cpp:175
llvm::object::XCOFFTracebackTable::isFuncNamePresent
bool isFuncNamePresent() const
Definition: XCOFFObjectFile.cpp:1259
llvm::Intrinsic::getType
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
Definition: Function.cpp:1335
llvm::object::Binary::ID_XCOFF64
@ ID_XCOFF64
Definition: Binary.h:58
llvm::object::XCOFFTracebackTable::getNumOfGPRsSaved
uint8_t getNumOfGPRsSaved() const
Definition: XCOFFObjectFile.cpp:1300
llvm::XCOFF::N_ABS
@ N_ABS
Definition: XCOFF.h:40
SubtargetFeature.h
llvm::object::XCOFFFileAuxEnt::NameInStrTblType::Offset
support::ubig32_t Offset
Definition: XCOFFObjectFile.h:237
llvm::Triple::ArchType
ArchType
Definition: Triple.h:47
llvm::PPCISD::SC
@ SC
CHAIN = SC CHAIN, Imm128 - System call.
Definition: PPCISelLowering.h:410
llvm::ModRefInfo::Ref
@ Ref
The access may reference the value stored in memory.
ptrdiff_t
GETVALUEWITHMASK
#define GETVALUEWITHMASK(X)
Definition: XCOFFObjectFile.cpp:1063
llvm::object::XCOFFObjectFile::getStringTableEntry
Expected< StringRef > getStringTableEntry(uint32_t Offset) const
Definition: XCOFFObjectFile.cpp:181
llvm::object::BasicSymbolRef::getRawDataRefImpl
DataRefImpl getRawDataRefImpl() const
Definition: SymbolicFile.h:206
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::object::TBVectorExt::getNumberOfVectorParms
uint8_t getNumberOfVectorParms() const
Definition: XCOFFObjectFile.cpp:1103
llvm::object::XCOFFObjectFile::getAdvancedSymbolEntryAddress
static uintptr_t getAdvancedSymbolEntryAddress(uintptr_t CurrentAddress, uint32_t Distance)
Definition: XCOFFObjectFile.cpp:90
llvm::object::XCOFFTracebackTable::isFixup
bool isFixup() const
Definition: XCOFFObjectFile.cpp:1284
llvm::errorCodeToError
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Definition: Error.cpp:87
llvm::SubtargetFeatures
Manages the enabling and disabling of subtarget specific features.
Definition: SubtargetFeature.h:183
XCOFFObjectFile.h
llvm::object::viewAs
static const T * viewAs(uintptr_t in)
Definition: XCOFFObjectFile.cpp:46
llvm::object::XCOFFSectionHeader64::SectionSize
support::ubig64_t SectionSize
Definition: XCOFFObjectFile.h:90
llvm::Triple::ppc64
@ ppc64
Definition: Triple.h:69
llvm::XCOFF::SymbolTableEntrySize
constexpr size_t SymbolTableEntrySize
Definition: XCOFF.h:34
in
The object format emitted by the WebAssembly backed is documented in
Definition: README.txt:11
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:140
llvm::ErrorAsOutParameter
Helper for Errors used as out-parameters.
Definition: Error.h:1089
llvm::object::object_error::parse_failed
@ parse_failed
llvm::object::XCOFFTracebackTable::isGlobalLinkage
bool isGlobalLinkage() const
Definition: XCOFFObjectFile.cpp:1223
llvm::object::DataRefImpl::p
uintptr_t p
Definition: SymbolicFile.h:39
llvm::object::XCOFFObjectFile::getSectionFlags
int32_t getSectionFlags(DataRefImpl Sec) const
Definition: XCOFFObjectFile.cpp:734
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
llvm::XCOFF::N_DEBUG
@ N_DEBUG
Definition: XCOFF.h:40
llvm::object::XCOFFObjectFile::relocations
Expected< ArrayRef< Reloc > > relocations(const Shdr &Sec) const
Definition: XCOFFObjectFile.cpp:780
llvm::object::XCOFFRelocation::Type
XCOFF::RelocationType Type
Definition: XCOFFObjectFile.h:278
llvm::object::LoaderSectionHeader32
Definition: XCOFFObjectFile.h:100
llvm::object::XCOFFCsectAuxRef::isLabel
bool isLabel() const
Definition: XCOFFObjectFile.h:206
llvm::XCOFF::C_EXT
@ C_EXT
Definition: XCOFF.h:141
llvm::object::XCOFFTracebackTable::isLRSaved
bool isLRSaved() const
Definition: XCOFFObjectFile.cpp:1276
llvm::MachO::FileType
FileType
Defines the file type this file represents.
Definition: InterfaceFile.h:57
llvm::object::XCOFFObjectFile::checkSymbolEntryPointer
void checkSymbolEntryPointer(uintptr_t SymbolEntPtr) const
Definition: XCOFFObjectFile.cpp:684
llvm::XCOFF::NameSize
constexpr size_t NameSize
Definition: XCOFF.h:29
llvm::OutputFileType::Object
@ Object
llvm::object::SectionRef
This is a value type class that represents a single section in the list of sections in the object fil...
Definition: ObjectFile.h:80
llvm::object::XCOFFTracebackTable::isCRSaved
bool isCRSaved() const
Definition: XCOFFObjectFile.cpp:1272
llvm::object::XCOFFCsectAuxRef::getStorageMappingClass
XCOFF::StorageMappingClass getStorageMappingClass() const
Definition: XCOFFObjectFile.h:188
llvm::object::XCOFFSymbolEntry32::NameInStrTblType::Offset
support::ubig32_t Offset
Definition: XCOFFObjectFile.h:483
llvm::XCOFF::STYP_TDATA
@ STYP_TDATA
Definition: XCOFF.h:85
llvm::XCOFF::StorageClass
StorageClass
Definition: XCOFF.h:113
llvm::object::TBVectorExt::create
static Expected< TBVectorExt > create(StringRef TBvectorStrRef)
Definition: XCOFFObjectFile.cpp:1067
llvm::object::LoaderSectionHeader64
Definition: XCOFFObjectFile.h:111
object
bar al al movzbl eax ret Missed when stored in a memory object
Definition: README.txt:1411
llvm::object::XCOFFSymbolEntry64::Offset
support::ubig32_t Offset
Definition: XCOFFObjectFile.h:505
llvm::object::XCOFFTracebackTable::getNumberOfFPParms
uint8_t getNumberOfFPParms() const
Definition: XCOFFObjectFile.cpp:1309
llvm::XCOFF::parseParmsTypeWithVecInfo
Expected< SmallString< 32 > > parseParmsTypeWithVecInfo(uint32_t Value, unsigned FixedParmsNum, unsigned FloatingParmsNum, unsigned VectorParmsNum)
Definition: XCOFF.cpp:188
llvm::object::FunctionSym
static const uint8_t FunctionSym
Definition: XCOFFObjectFile.cpp:26
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
uint64_t
llvm::object::object_error::string_table_non_null_end
@ string_table_non_null_end
llvm::object::symbol_iterator
Definition: ObjectFile.h:207
llvm::StringRef::end
iterator end() const
Definition: StringRef.h:130
getSymbolType
static std::unique_ptr< PDBSymbol > getSymbolType(const PDBSymbol &Symbol)
Definition: UDTLayout.cpp:33
llvm::XCOFF::parseVectorParmsType
Expected< SmallString< 32 > > parseVectorParmsType(uint32_t Value, unsigned ParmsNum)
Definition: XCOFF.cpp:240
llvm::XCOFF::STYP_OVRFLO
@ STYP_OVRFLO
Definition: XCOFF.h:90
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:80
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::object::XCOFFObjectFile::getNumberOfRelocationEntries
Expected< uint32_t > getNumberOfRelocationEntries(const XCOFFSectionHeader< T > &Sec) const
Definition: XCOFFObjectFile.cpp:762
llvm::object::XCOFFTracebackTable::hasTraceBackTableOffset
bool hasTraceBackTableOffset() const
Definition: XCOFFObjectFile.cpp:1231
llvm::XCOFF::C_HIDEXT
@ C_HIDEXT
Definition: XCOFF.h:149
llvm::object::TBVectorExt
Definition: XCOFFObjectFile.h:580
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SI
StandardInstrumentations SI(Debug, VerifyEach)
base
therefore end up llgh r3 lr r0 br r14 but truncating the load would lh r3 br r14 Functions ret i64 and ought to be implemented ngr r0 br r14 but two address optimizations reverse the order of the AND and ngr r2 lgr r0 br r14 CodeGen SystemZ and ll has several examples of this Out of range displacements are usually handled by loading the full address into a register In many cases it would be better to create an anchor point instead E g i64 base
Definition: README.txt:125
llvm::object::content_iterator
Definition: SymbolicFile.h:67
llvm::object::XCOFFSymbolRef::getSectionNumber
int16_t getSectionNumber() const
Definition: XCOFFObjectFile.h:542
llvm::object::ObjectFile::base
const uint8_t * base() const
Definition: ObjectFile.h:234
llvm::object::XCOFFStringTable
Definition: XCOFFObjectFile.h:125
llvm::DataExtractor::Cursor
A class representing a position in a DataExtractor, as well as any error encountered during extractio...
Definition: DataExtractor.h:54
llvm::object::ObjectFile::createXCOFFObjectFile
static Expected< std::unique_ptr< ObjectFile > > createXCOFFObjectFile(MemoryBufferRef Object, unsigned FileType)
Definition: XCOFFObjectFile.cpp:936
llvm::XCOFF::parseParmsType
Expected< SmallString< 32 > > parseParmsType(uint32_t Value, unsigned FixedParmsNum, unsigned FloatingParmsNum)
Definition: XCOFF.cpp:110
llvm::ArrayRef< uint8_t >
llvm::object::section_iterator
content_iterator< SectionRef > section_iterator
Definition: ObjectFile.h:47
llvm::object::generateXCOFFFixedNameStringRef
static StringRef generateXCOFFFixedNameStringRef(const char *Name)
Definition: XCOFFObjectFile.cpp:50
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::object::XCOFFSymbolRef::getStorageClass
XCOFF::StorageClass getStorageClass() const
Definition: XCOFFObjectFile.h:558
llvm::object::ObjectFile
This class is the base class for all object file types.
Definition: ObjectFile.h:228
llvm::object::XCOFFTracebackTable::create
static Expected< XCOFFTracebackTable > create(const uint8_t *Ptr, uint64_t &Size)
Parse an XCOFF Traceback Table from Ptr with Size bytes.
Definition: XCOFFObjectFile.cpp:1114
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::object::XCOFFTracebackTable::hasControlledStorage
bool hasControlledStorage() const
Definition: XCOFFObjectFile.cpp:1239
llvm::Expected::get
reference get()
Returns a reference to the stored T value.
Definition: Error.h:569
llvm::XCOFF::C_WEAKEXT
@ C_WEAKEXT
Definition: XCOFF.h:142
llvm::object::XCOFFRelocation::SymbolIndex
support::ubig32_t SymbolIndex
Definition: XCOFFObjectFile.h:273
uint32_t
llvm::COFF::SectionSize
@ SectionSize
Definition: COFF.h:61
llvm::object::XCOFFObjectFile::sections32
ArrayRef< XCOFFSectionHeader32 > sections32() const
Definition: XCOFFObjectFile.cpp:750
llvm::object::DataRefImpl
Definition: SymbolicFile.h:33
llvm::object::LoaderSectionHeader32::OffsetToImpid
support::big32_t OffsetToImpid
Definition: XCOFFObjectFile.h:106
llvm::XCOFF::SymbolAuxType
SymbolAuxType
Definition: XCOFF.h:282
llvm::object::XCOFFFileAuxEnt::NameInStrTbl
NameInStrTblType NameInStrTbl
Definition: XCOFFObjectFile.h:242
llvm::object::TBVectorExt::getNumberOfVRSaved
uint8_t getNumberOfVRSaved() const
Definition: XCOFFObjectFile.cpp:1091
llvm::object::XCOFFObjectFile::getSymbolAuxType
const XCOFF::SymbolAuxType * getSymbolAuxType(uintptr_t AuxEntryAddress) const
Definition: XCOFFObjectFile.cpp:96
llvm::XCOFF::N_UNDEF
@ N_UNDEF
Definition: XCOFF.h:40
llvm::object::XCOFFObjectFile::sections64
ArrayRef< XCOFFSectionHeader64 > sections64() const
Definition: XCOFFObjectFile.cpp:743
llvm::object::SymbolAuxTypeOffset
static const size_t SymbolAuxTypeOffset
Definition: XCOFFObjectFile.cpp:28
GETBITWITHMASK
#define GETBITWITHMASK(P, X)
Definition: XCOFFObjectFile.cpp:1209
llvm::object::XCOFFObjectFile::getNumberOfSections
uint16_t getNumberOfSections() const
Definition: XCOFFObjectFile.cpp:634
llvm::object::XCOFFTracebackTable::isAllocaUsed
bool isAllocaUsed() const
Definition: XCOFFObjectFile.cpp:1263
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::createStringError
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition: Error.h:1231
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::object::XCOFFSectionHeader32::SectionSize
support::ubig32_t SectionSize
Definition: XCOFFObjectFile.h:77
uint16_t
getFlags
static uint32_t getFlags(const Symbol *Sym)
Definition: TapiFile.cpp:23
llvm::XCOFF::STYP_DEBUG
@ STYP_DEBUG
Definition: XCOFF.h:88
llvm::object::XCOFFTracebackTable::getNumberOfFixedParms
uint8_t getNumberOfFixedParms() const
Definition: XCOFFObjectFile.cpp:1304
llvm::object::XCOFFTracebackTable::hasExtensionTable
bool hasExtensionTable() const
Definition: XCOFFObjectFile.cpp:1292
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
getObject
static Error getObject(const T *&Obj, MemoryBufferRef M, const void *Ptr, const uint64_t Size=sizeof(T))
Definition: COFFObjectFile.cpp:58
llvm::object::XCOFFTracebackTable::isInternalProcedure
bool isInternalProcedure() const
Definition: XCOFFObjectFile.cpp:1235
DataExtractor.h
llvm::object::XCOFFTracebackTable::getNumOfFPRsSaved
uint8_t getNumOfFPRsSaved() const
Definition: XCOFFObjectFile.cpp:1288
llvm::XCOFF::AUX_CSECT
@ AUX_CSECT
Identifies a csect auxiliary entry.
Definition: XCOFF.h:287
llvm::object::Binary::ID_XCOFF32
@ ID_XCOFF32
Definition: Binary.h:57
StringSwitch.h
llvm::object::XCOFFRelocation32
Definition: XCOFFObjectFile.h:291
llvm::XCOFF::getRelocationTypeString
StringRef getRelocationTypeString(XCOFF::RelocationType Type)
Definition: XCOFF.cpp:53
llvm::object::XCOFFSectionHeader64::VirtualAddress
support::ubig64_t VirtualAddress
Definition: XCOFFObjectFile.h:89
llvm::object::TBVectorExt::isVRSavedOnStack
bool isVRSavedOnStack() const
Definition: XCOFFObjectFile.cpp:1095
llvm::makeArrayRef
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:476
getFeatures
static FeatureBitset getFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS, ArrayRef< SubtargetSubTypeKV > ProcDesc, ArrayRef< SubtargetFeatureKV > ProcFeatures)
Definition: MCSubtargetInfo.cpp:150
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:589
llvm::object::XCOFFSectionHeader64
Definition: XCOFFObjectFile.h:86
llvm::object::XCOFFSymbolEntry32::SymbolName
char SymbolName[XCOFF::NameSize]
Definition: XCOFFObjectFile.h:487
llvm::DataExtractor
Definition: DataExtractor.h:41
llvm::object::XCOFFTracebackTable::getOnConditionDirective
uint8_t getOnConditionDirective() const
Definition: XCOFFObjectFile.cpp:1267
llvm::XCOFF::STYP_DATA
@ STYP_DATA
Definition: XCOFF.h:81
getSymbolSectionID
static unsigned getSymbolSectionID(const ObjectFile &O, SymbolRef Sym)
Definition: SymbolSize.cpp:39
GETVALUEWITHMASKSHIFT
#define GETVALUEWITHMASKSHIFT(X, S)
Definition: XCOFFObjectFile.cpp:1064
llvm::COFF::isReservedSectionNumber
bool isReservedSectionNumber(int32_t SectionNumber)
Definition: COFF.h:730
llvm::XCOFF::STYP_TEXT
@ STYP_TEXT
Definition: XCOFF.h:80
llvm::object::XCOFFTracebackTable::isFloatingPointOperationLogOrAbortEnabled
bool isFloatingPointOperationLogOrAbortEnabled() const
Definition: XCOFFObjectFile.cpp:1251
llvm::object::XCOFFSymbolRef::isCsectSymbol
bool isCsectSymbol() const
Definition: XCOFFObjectFile.cpp:975
llvm::object::XCOFFSymbolRef::NAME_IN_STR_TBL_MAGIC
@ NAME_IN_STR_TBL_MAGIC
Definition: XCOFFObjectFile.h:519
llvm::object::XCOFFObjectFile
Definition: XCOFFObjectFile.h:296
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:165
llvm::object::XCOFFTracebackTable
This class provides methods to extract traceback table data from a buffer.
Definition: XCOFFObjectFile.h:599
llvm::object::Binary::checkOffset
static Error checkOffset(MemoryBufferRef M, uintptr_t Addr, const uint64_t Size)
Definition: Binary.h:166
llvm::StringRef::data
const LLVM_NODISCARD char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:149
llvm::SmallVectorImpl< char >
llvm::object::XCOFFSymbolRef::getSymbolType
uint16_t getSymbolType() const
Definition: XCOFFObjectFile.h:544
llvm::object::SymbolRef
This is a value type class that represents a single symbol in the list of symbols in the object file.
Definition: ObjectFile.h:167
llvm::StringSwitch
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:42
llvm::object::XCOFFSymbolRef::getEntryAddress
uintptr_t getEntryAddress() const
Definition: XCOFFObjectFile.h:564
llvm::XCOFF::RelocationSerializationSize32
constexpr size_t RelocationSerializationSize32
Definition: XCOFF.h:35
llvm::XCOFF::STYP_TBSS
@ STYP_TBSS
Definition: XCOFF.h:86
llvm::object::RelocationRef
This is a value type class that represents a single relocation in the list of relocations in the obje...
Definition: ObjectFile.h:51
getSymbolName
static StringRef getSymbolName(SymbolKind SymKind)
Definition: CodeViewDebug.cpp:2994
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition: SmallVector.h:624
llvm::object::XCOFFSymbolEntry32::NameInStrTbl
NameInStrTblType NameInStrTbl
Definition: XCOFFObjectFile.h:488
llvm::StringRef::begin
iterator begin() const
Definition: StringRef.h:128
llvm::object::XCOFFFileAuxEnt
Definition: XCOFFObjectFile.h:234
llvm::XCOFF::RelocOverflow
constexpr uint16_t RelocOverflow
Definition: XCOFF.h:37
llvm::object::basic_symbol_iterator
content_iterator< BasicSymbolRef > basic_symbol_iterator
Definition: SymbolicFile.h:141
llvm::object::XCOFFRelocation
Definition: XCOFFObjectFile.h:256
llvm::Optional::getValue
constexpr const T & getValue() const LLVM_LVALUE_FUNCTION
Definition: Optional.h:282
llvm::object::doesXCOFFTracebackTableBegin
bool doesXCOFFTracebackTableBegin(ArrayRef< uint8_t > Bytes)
Definition: XCOFFObjectFile.cpp:1056
llvm::sampleprof::Base
@ Base
Definition: Discriminator.h:58
llvm::object::XCOFFTracebackTable::hasVectorInfo
bool hasVectorInfo() const
Definition: XCOFFObjectFile.cpp:1296
Shdr
Elf_Shdr Shdr
Definition: ELFObjHandler.cpp:79
llvm::object::LoaderSectionHeader32::LengthOfImpidStrTbl
support::ubig32_t LengthOfImpidStrTbl
Definition: XCOFFObjectFile.h:104
llvm::object::XCOFFSymbolEntry32::NameInStrTblType::Magic
support::big32_t Magic
Definition: XCOFFObjectFile.h:482
llvm::support::endian::read16be
uint16_t read16be(const void *P)
Definition: Endian.h:383
llvm::object::XCOFFTracebackTable::getLanguageID
uint8_t getLanguageID() const
Definition: XCOFFObjectFile.cpp:1219