LLVM  16.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>
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 
50 static StringRef generateXCOFFFixedNameStringRef(const char *Name) {
51  auto NulCharPtr =
52  static_cast<const char *>(memchr(Name, '\0', XCOFF::NameSize));
53  return NulCharPtr ? StringRef(Name, NulCharPtr - Name)
54  : StringRef(Name, XCOFF::NameSize);
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 
91 
92 template <typename T>
94  uint64_t Offset) {
95  if (LoaderSecHeader->LengthOfStrTbl > Offset)
96  return (reinterpret_cast<const char *>(LoaderSecHeader) +
97  LoaderSecHeader->OffsetToStrTbl + Offset);
98 
99  return createError("entry with offset 0x" + Twine::utohexstr(Offset) +
100  " in the loader section's string table with size 0x" +
101  Twine::utohexstr(LoaderSecHeader->LengthOfStrTbl) +
102  " is invalid");
103 }
104 
106  const LoaderSectionHeader32 *LoaderSecHeader32) const {
107  const NameOffsetInStrTbl *NameInStrTbl =
108  reinterpret_cast<const NameOffsetInStrTbl *>(SymbolName);
109  if (NameInStrTbl->IsNameInStrTbl != XCOFFSymbolRef::NAME_IN_STR_TBL_MAGIC)
111 
112  return getLoaderSecSymNameInStrTbl(LoaderSecHeader32, NameInStrTbl->Offset);
113 }
114 
116  const LoaderSectionHeader64 *LoaderSecHeader64) const {
117  return getLoaderSecSymNameInStrTbl(LoaderSecHeader64, Offset);
118 }
119 
120 uintptr_t
121 XCOFFObjectFile::getAdvancedSymbolEntryAddress(uintptr_t CurrentAddress,
122  uint32_t Distance) {
123  return getWithOffset(CurrentAddress, Distance * XCOFF::SymbolTableEntrySize);
124 }
125 
126 const XCOFF::SymbolAuxType *
127 XCOFFObjectFile::getSymbolAuxType(uintptr_t AuxEntryAddress) const {
128  assert(is64Bit() && "64-bit interface called on a 32-bit object file.");
129  return viewAs<XCOFF::SymbolAuxType>(
130  getWithOffset(AuxEntryAddress, SymbolAuxTypeOffset));
131 }
132 
133 void XCOFFObjectFile::checkSectionAddress(uintptr_t Addr,
134  uintptr_t TableAddress) const {
135  if (Addr < TableAddress)
136  report_fatal_error("Section header outside of section header table.");
137 
138  uintptr_t Offset = Addr - TableAddress;
139  if (Offset >= getSectionHeaderSize() * getNumberOfSections())
140  report_fatal_error("Section header outside of section header table.");
141 
142  if (Offset % getSectionHeaderSize() != 0)
144  "Section header pointer does not point to a valid section header.");
145 }
146 
147 const XCOFFSectionHeader32 *
148 XCOFFObjectFile::toSection32(DataRefImpl Ref) const {
149  assert(!is64Bit() && "32-bit interface called on 64-bit object file.");
150 #ifndef NDEBUG
151  checkSectionAddress(Ref.p, getSectionHeaderTableAddress());
152 #endif
153  return viewAs<XCOFFSectionHeader32>(Ref.p);
154 }
155 
156 const XCOFFSectionHeader64 *
157 XCOFFObjectFile::toSection64(DataRefImpl Ref) const {
158  assert(is64Bit() && "64-bit interface called on a 32-bit object file.");
159 #ifndef NDEBUG
160  checkSectionAddress(Ref.p, getSectionHeaderTableAddress());
161 #endif
162  return viewAs<XCOFFSectionHeader64>(Ref.p);
163 }
164 
165 XCOFFSymbolRef XCOFFObjectFile::toSymbolRef(DataRefImpl Ref) const {
166  assert(Ref.p != 0 && "Symbol table pointer can not be nullptr!");
167 #ifndef NDEBUG
168  checkSymbolEntryPointer(Ref.p);
169 #endif
170  return XCOFFSymbolRef(Ref, this);
171 }
172 
173 const XCOFFFileHeader32 *XCOFFObjectFile::fileHeader32() const {
174  assert(!is64Bit() && "32-bit interface called on 64-bit object file.");
175  return static_cast<const XCOFFFileHeader32 *>(FileHeader);
176 }
177 
178 const XCOFFFileHeader64 *XCOFFObjectFile::fileHeader64() const {
179  assert(is64Bit() && "64-bit interface called on a 32-bit object file.");
180  return static_cast<const XCOFFFileHeader64 *>(FileHeader);
181 }
182 
183 const XCOFFAuxiliaryHeader32 *XCOFFObjectFile::auxiliaryHeader32() const {
184  assert(!is64Bit() && "32-bit interface called on 64-bit object file.");
185  return static_cast<const XCOFFAuxiliaryHeader32 *>(AuxiliaryHeader);
186 }
187 
188 const XCOFFAuxiliaryHeader64 *XCOFFObjectFile::auxiliaryHeader64() const {
189  assert(is64Bit() && "64-bit interface called on a 32-bit object file.");
190  return static_cast<const XCOFFAuxiliaryHeader64 *>(AuxiliaryHeader);
191 }
192 
193 template <typename T> const T *XCOFFObjectFile::sectionHeaderTable() const {
194  return static_cast<const T *>(SectionHeaderTable);
195 }
196 
197 const XCOFFSectionHeader32 *
198 XCOFFObjectFile::sectionHeaderTable32() const {
199  assert(!is64Bit() && "32-bit interface called on 64-bit object file.");
200  return static_cast<const XCOFFSectionHeader32 *>(SectionHeaderTable);
201 }
202 
203 const XCOFFSectionHeader64 *
204 XCOFFObjectFile::sectionHeaderTable64() const {
205  assert(is64Bit() && "64-bit interface called on a 32-bit object file.");
206  return static_cast<const XCOFFSectionHeader64 *>(SectionHeaderTable);
207 }
208 
209 void XCOFFObjectFile::moveSymbolNext(DataRefImpl &Symb) const {
210  uintptr_t NextSymbolAddr = getAdvancedSymbolEntryAddress(
211  Symb.p, toSymbolRef(Symb).getNumberOfAuxEntries() + 1);
212 #ifndef NDEBUG
213  // This function is used by basic_symbol_iterator, which allows to
214  // point to the end-of-symbol-table address.
215  if (NextSymbolAddr != getEndOfSymbolTableAddress())
216  checkSymbolEntryPointer(NextSymbolAddr);
217 #endif
218  Symb.p = NextSymbolAddr;
219 }
220 
222 XCOFFObjectFile::getStringTableEntry(uint32_t Offset) const {
223  // The byte offset is relative to the start of the string table.
224  // A byte offset value of 0 is a null or zero-length symbol
225  // name. A byte offset in the range 1 to 3 (inclusive) points into the length
226  // field; as a soft-error recovery mechanism, we treat such cases as having an
227  // offset of 0.
228  if (Offset < 4)
229  return StringRef(nullptr, 0);
230 
231  if (StringTable.Data != nullptr && StringTable.Size > Offset)
232  return (StringTable.Data + Offset);
233 
234  return createError("entry with offset 0x" + Twine::utohexstr(Offset) +
235  " in a string table with size 0x" +
236  Twine::utohexstr(StringTable.Size) + " is invalid");
237 }
238 
239 StringRef XCOFFObjectFile::getStringTable() const {
240  // If the size is less than or equal to 4, then the string table contains no
241  // string data.
242  return StringRef(StringTable.Data,
243  StringTable.Size <= 4 ? 0 : StringTable.Size);
244 }
245 
247 XCOFFObjectFile::getCFileName(const XCOFFFileAuxEnt *CFileEntPtr) const {
248  if (CFileEntPtr->NameInStrTbl.Magic != XCOFFSymbolRef::NAME_IN_STR_TBL_MAGIC)
249  return generateXCOFFFixedNameStringRef(CFileEntPtr->Name);
250  return getStringTableEntry(CFileEntPtr->NameInStrTbl.Offset);
251 }
252 
254  return toSymbolRef(Symb).getName();
255 }
256 
257 Expected<uint64_t> XCOFFObjectFile::getSymbolAddress(DataRefImpl Symb) const {
258  return toSymbolRef(Symb).getValue();
259 }
260 
261 uint64_t XCOFFObjectFile::getSymbolValueImpl(DataRefImpl Symb) const {
262  return toSymbolRef(Symb).getValue();
263 }
264 
265 uint32_t XCOFFObjectFile::getSymbolAlignment(DataRefImpl Symb) const {
266  uint64_t Result = 0;
267  XCOFFSymbolRef XCOFFSym = toSymbolRef(Symb);
268  if (XCOFFSym.isCsectSymbol()) {
269  Expected<XCOFFCsectAuxRef> CsectAuxRefOrError =
270  XCOFFSym.getXCOFFCsectAuxRef();
271  if (!CsectAuxRefOrError)
272  // TODO: report the error up the stack.
273  consumeError(CsectAuxRefOrError.takeError());
274  else
275  Result = 1ULL << CsectAuxRefOrError.get().getAlignmentLog2();
276  }
277  return Result;
278 }
279 
280 uint64_t XCOFFObjectFile::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
281  uint64_t Result = 0;
282  XCOFFSymbolRef XCOFFSym = toSymbolRef(Symb);
283  if (XCOFFSym.isCsectSymbol()) {
284  Expected<XCOFFCsectAuxRef> CsectAuxRefOrError =
285  XCOFFSym.getXCOFFCsectAuxRef();
286  if (!CsectAuxRefOrError)
287  // TODO: report the error up the stack.
288  consumeError(CsectAuxRefOrError.takeError());
289  else {
290  XCOFFCsectAuxRef CsectAuxRef = CsectAuxRefOrError.get();
291  assert(CsectAuxRef.getSymbolType() == XCOFF::XTY_CM);
292  Result = CsectAuxRef.getSectionOrLength();
293  }
294  }
295  return Result;
296 }
297 
300  XCOFFSymbolRef XCOFFSym = toSymbolRef(Symb);
301 
302  if (XCOFFSym.isFunction())
303  return SymbolRef::ST_Function;
304 
305  if (XCOFF::C_FILE == XCOFFSym.getStorageClass())
306  return SymbolRef::ST_File;
307 
308  int16_t SecNum = XCOFFSym.getSectionNumber();
309  if (SecNum <= 0)
310  return SymbolRef::ST_Other;
311 
312  Expected<DataRefImpl> SecDRIOrErr =
313  getSectionByNum(XCOFFSym.getSectionNumber());
314 
315  if (!SecDRIOrErr)
316  return SecDRIOrErr.takeError();
317 
318  DataRefImpl SecDRI = SecDRIOrErr.get();
319 
320  Expected<StringRef> SymNameOrError = XCOFFSym.getName();
321  if (SymNameOrError) {
322  // The "TOC" symbol is treated as SymbolRef::ST_Other.
323  if (SymNameOrError.get() == "TOC")
324  return SymbolRef::ST_Other;
325 
326  // The symbol for a section name is treated as SymbolRef::ST_Other.
327  StringRef SecName;
328  if (is64Bit())
329  SecName = XCOFFObjectFile::toSection64(SecDRIOrErr.get())->getName();
330  else
331  SecName = XCOFFObjectFile::toSection32(SecDRIOrErr.get())->getName();
332 
333  if (SecName == SymNameOrError.get())
334  return SymbolRef::ST_Other;
335  } else
336  return SymNameOrError.takeError();
337 
338  if (isSectionData(SecDRI) || isSectionBSS(SecDRI))
339  return SymbolRef::ST_Data;
340 
341  if (isDebugSection(SecDRI))
342  return SymbolRef::ST_Debug;
343 
344  return SymbolRef::ST_Other;
345 }
346 
348 XCOFFObjectFile::getSymbolSection(DataRefImpl Symb) const {
349  const int16_t SectNum = toSymbolRef(Symb).getSectionNumber();
350 
351  if (isReservedSectionNumber(SectNum))
352  return section_end();
353 
354  Expected<DataRefImpl> ExpSec = getSectionByNum(SectNum);
355  if (!ExpSec)
356  return ExpSec.takeError();
357 
358  return section_iterator(SectionRef(ExpSec.get(), this));
359 }
360 
361 void XCOFFObjectFile::moveSectionNext(DataRefImpl &Sec) const {
362  const char *Ptr = reinterpret_cast<const char *>(Sec.p);
363  Sec.p = reinterpret_cast<uintptr_t>(Ptr + getSectionHeaderSize());
364 }
365 
366 Expected<StringRef> XCOFFObjectFile::getSectionName(DataRefImpl Sec) const {
367  return generateXCOFFFixedNameStringRef(getSectionNameInternal(Sec));
368 }
369 
370 uint64_t XCOFFObjectFile::getSectionAddress(DataRefImpl Sec) const {
371  // Avoid ternary due to failure to convert the ubig32_t value to a unit64_t
372  // with MSVC.
373  if (is64Bit())
374  return toSection64(Sec)->VirtualAddress;
375 
376  return toSection32(Sec)->VirtualAddress;
377 }
378 
379 uint64_t XCOFFObjectFile::getSectionIndex(DataRefImpl Sec) const {
380  // Section numbers in XCOFF are numbered beginning at 1. A section number of
381  // zero is used to indicate that a symbol is being imported or is undefined.
382  if (is64Bit())
383  return toSection64(Sec) - sectionHeaderTable64() + 1;
384  else
385  return toSection32(Sec) - sectionHeaderTable32() + 1;
386 }
387 
388 uint64_t XCOFFObjectFile::getSectionSize(DataRefImpl Sec) const {
389  // Avoid ternary due to failure to convert the ubig32_t value to a unit64_t
390  // with MSVC.
391  if (is64Bit())
392  return toSection64(Sec)->SectionSize;
393 
394  return toSection32(Sec)->SectionSize;
395 }
396 
398 XCOFFObjectFile::getSectionContents(DataRefImpl Sec) const {
399  if (isSectionVirtual(Sec))
400  return ArrayRef<uint8_t>();
401 
402  uint64_t OffsetToRaw;
403  if (is64Bit())
404  OffsetToRaw = toSection64(Sec)->FileOffsetToRawData;
405  else
406  OffsetToRaw = toSection32(Sec)->FileOffsetToRawData;
407 
408  const uint8_t * ContentStart = base() + OffsetToRaw;
409  uint64_t SectionSize = getSectionSize(Sec);
410  if (Error E = Binary::checkOffset(
411  Data, reinterpret_cast<uintptr_t>(ContentStart), SectionSize))
412  return createError(
413  toString(std::move(E)) + ": section data with offset 0x" +
414  Twine::utohexstr(OffsetToRaw) + " and size 0x" +
415  Twine::utohexstr(SectionSize) + " goes past the end of the file");
416 
417  return makeArrayRef(ContentStart,SectionSize);
418 }
419 
420 uint64_t XCOFFObjectFile::getSectionAlignment(DataRefImpl Sec) const {
421  uint64_t Result = 0;
422  llvm_unreachable("Not yet implemented!");
423  return Result;
424 }
425 
426 uint64_t XCOFFObjectFile::getSectionFileOffsetToRawData(DataRefImpl Sec) const {
427  if (is64Bit())
428  return toSection64(Sec)->FileOffsetToRawData;
429 
430  return toSection32(Sec)->FileOffsetToRawData;
431 }
432 
433 Expected<uintptr_t> XCOFFObjectFile::getSectionFileOffsetToRawData(
434  XCOFF::SectionTypeFlags SectType) const {
435  DataRefImpl DRI = getSectionByType(SectType);
436 
437  if (DRI.p == 0) // No section is not an error.
438  return 0;
439 
440  uint64_t SectionOffset = getSectionFileOffsetToRawData(DRI);
441  uint64_t SizeOfSection = getSectionSize(DRI);
442 
443  uintptr_t SectionStart = reinterpret_cast<uintptr_t>(base() + SectionOffset);
444  if (Error E = Binary::checkOffset(Data, SectionStart, SizeOfSection)) {
445  SmallString<32> UnknownType;
446  Twine(("<Unknown:") + Twine::utohexstr(SectType) + ">")
447  .toVector(UnknownType);
448  const char *SectionName = UnknownType.c_str();
449 
450  switch (SectType) {
451 #define ECASE(Value, String) \
452  case XCOFF::Value: \
453  SectionName = String; \
454  break
455 
456  ECASE(STYP_PAD, "pad");
457  ECASE(STYP_DWARF, "dwarf");
458  ECASE(STYP_TEXT, "text");
459  ECASE(STYP_DATA, "data");
460  ECASE(STYP_BSS, "bss");
461  ECASE(STYP_EXCEPT, "expect");
462  ECASE(STYP_INFO, "info");
463  ECASE(STYP_TDATA, "tdata");
464  ECASE(STYP_TBSS, "tbss");
465  ECASE(STYP_LOADER, "loader");
466  ECASE(STYP_DEBUG, "debug");
467  ECASE(STYP_TYPCHK, "typchk");
468  ECASE(STYP_OVRFLO, "ovrflo");
469 #undef ECASE
470  }
471  return createError(toString(std::move(E)) + ": " + SectionName +
472  " section with offset 0x" +
473  Twine::utohexstr(SectionOffset) + " and size 0x" +
474  Twine::utohexstr(SizeOfSection) +
475  " goes past the end of the file");
476  }
477  return SectionStart;
478 }
479 
480 bool XCOFFObjectFile::isSectionCompressed(DataRefImpl Sec) const {
481  return false;
482 }
483 
484 bool XCOFFObjectFile::isSectionText(DataRefImpl Sec) const {
485  return getSectionFlags(Sec) & XCOFF::STYP_TEXT;
486 }
487 
488 bool XCOFFObjectFile::isSectionData(DataRefImpl Sec) const {
489  uint32_t Flags = getSectionFlags(Sec);
490  return Flags & (XCOFF::STYP_DATA | XCOFF::STYP_TDATA);
491 }
492 
493 bool XCOFFObjectFile::isSectionBSS(DataRefImpl Sec) const {
494  uint32_t Flags = getSectionFlags(Sec);
495  return Flags & (XCOFF::STYP_BSS | XCOFF::STYP_TBSS);
496 }
497 
499  uint32_t Flags = getSectionFlags(Sec);
500  return Flags & (XCOFF::STYP_DEBUG | XCOFF::STYP_DWARF);
501 }
502 
503 bool XCOFFObjectFile::isSectionVirtual(DataRefImpl Sec) const {
504  return is64Bit() ? toSection64(Sec)->FileOffsetToRawData == 0
505  : toSection32(Sec)->FileOffsetToRawData == 0;
506 }
507 
508 relocation_iterator XCOFFObjectFile::section_rel_begin(DataRefImpl Sec) const {
510  if (is64Bit()) {
511  const XCOFFSectionHeader64 *SectionEntPtr = toSection64(Sec);
512  auto RelocationsOrErr =
513  relocations<XCOFFSectionHeader64, XCOFFRelocation64>(*SectionEntPtr);
514  if (Error E = RelocationsOrErr.takeError()) {
515  // TODO: report the error up the stack.
518  }
519  Ret.p = reinterpret_cast<uintptr_t>(&*RelocationsOrErr.get().begin());
520  } else {
521  const XCOFFSectionHeader32 *SectionEntPtr = toSection32(Sec);
522  auto RelocationsOrErr =
523  relocations<XCOFFSectionHeader32, XCOFFRelocation32>(*SectionEntPtr);
524  if (Error E = RelocationsOrErr.takeError()) {
525  // TODO: report the error up the stack.
528  }
529  Ret.p = reinterpret_cast<uintptr_t>(&*RelocationsOrErr.get().begin());
530  }
531  return relocation_iterator(RelocationRef(Ret, this));
532 }
533 
534 relocation_iterator XCOFFObjectFile::section_rel_end(DataRefImpl Sec) const {
536  if (is64Bit()) {
537  const XCOFFSectionHeader64 *SectionEntPtr = toSection64(Sec);
538  auto RelocationsOrErr =
539  relocations<XCOFFSectionHeader64, XCOFFRelocation64>(*SectionEntPtr);
540  if (Error E = RelocationsOrErr.takeError()) {
541  // TODO: report the error up the stack.
544  }
545  Ret.p = reinterpret_cast<uintptr_t>(&*RelocationsOrErr.get().end());
546  } else {
547  const XCOFFSectionHeader32 *SectionEntPtr = toSection32(Sec);
548  auto RelocationsOrErr =
549  relocations<XCOFFSectionHeader32, XCOFFRelocation32>(*SectionEntPtr);
550  if (Error E = RelocationsOrErr.takeError()) {
551  // TODO: report the error up the stack.
554  }
555  Ret.p = reinterpret_cast<uintptr_t>(&*RelocationsOrErr.get().end());
556  }
557  return relocation_iterator(RelocationRef(Ret, this));
558 }
559 
560 void XCOFFObjectFile::moveRelocationNext(DataRefImpl &Rel) const {
561  if (is64Bit())
562  Rel.p = reinterpret_cast<uintptr_t>(viewAs<XCOFFRelocation64>(Rel.p) + 1);
563  else
564  Rel.p = reinterpret_cast<uintptr_t>(viewAs<XCOFFRelocation32>(Rel.p) + 1);
565 }
566 
567 uint64_t XCOFFObjectFile::getRelocationOffset(DataRefImpl Rel) const {
568  if (is64Bit()) {
569  const XCOFFRelocation64 *Reloc = viewAs<XCOFFRelocation64>(Rel.p);
570  const XCOFFSectionHeader64 *Sec64 = sectionHeaderTable64();
571  const uint64_t RelocAddress = Reloc->VirtualAddress;
572  const uint16_t NumberOfSections = getNumberOfSections();
573  for (uint16_t I = 0; I < NumberOfSections; ++I) {
574  // Find which section this relocation belongs to, and get the
575  // relocation offset relative to the start of the section.
576  if (Sec64->VirtualAddress <= RelocAddress &&
577  RelocAddress < Sec64->VirtualAddress + Sec64->SectionSize) {
578  return RelocAddress - Sec64->VirtualAddress;
579  }
580  ++Sec64;
581  }
582  } else {
583  const XCOFFRelocation32 *Reloc = viewAs<XCOFFRelocation32>(Rel.p);
584  const XCOFFSectionHeader32 *Sec32 = sectionHeaderTable32();
585  const uint32_t RelocAddress = Reloc->VirtualAddress;
586  const uint16_t NumberOfSections = getNumberOfSections();
587  for (uint16_t I = 0; I < NumberOfSections; ++I) {
588  // Find which section this relocation belongs to, and get the
589  // relocation offset relative to the start of the section.
590  if (Sec32->VirtualAddress <= RelocAddress &&
591  RelocAddress < Sec32->VirtualAddress + Sec32->SectionSize) {
592  return RelocAddress - Sec32->VirtualAddress;
593  }
594  ++Sec32;
595  }
596  }
597  return InvalidRelocOffset;
598 }
599 
600 symbol_iterator XCOFFObjectFile::getRelocationSymbol(DataRefImpl Rel) const {
601  uint32_t Index;
602  if (is64Bit()) {
603  const XCOFFRelocation64 *Reloc = viewAs<XCOFFRelocation64>(Rel.p);
604  Index = Reloc->SymbolIndex;
605 
606  if (Index >= getNumberOfSymbolTableEntries64())
607  return symbol_end();
608  } else {
609  const XCOFFRelocation32 *Reloc = viewAs<XCOFFRelocation32>(Rel.p);
610  Index = Reloc->SymbolIndex;
611 
612  if (Index >= getLogicalNumberOfSymbolTableEntries32())
613  return symbol_end();
614  }
615  DataRefImpl SymDRI;
616  SymDRI.p = getSymbolEntryAddressByIndex(Index);
617  return symbol_iterator(SymbolRef(SymDRI, this));
618 }
619 
620 uint64_t XCOFFObjectFile::getRelocationType(DataRefImpl Rel) const {
621  if (is64Bit())
622  return viewAs<XCOFFRelocation64>(Rel.p)->Type;
623  return viewAs<XCOFFRelocation32>(Rel.p)->Type;
624 }
625 
626 void XCOFFObjectFile::getRelocationTypeName(
627  DataRefImpl Rel, SmallVectorImpl<char> &Result) const {
628  StringRef Res;
629  if (is64Bit()) {
630  const XCOFFRelocation64 *Reloc = viewAs<XCOFFRelocation64>(Rel.p);
631  Res = XCOFF::getRelocationTypeString(Reloc->Type);
632  } else {
633  const XCOFFRelocation32 *Reloc = viewAs<XCOFFRelocation32>(Rel.p);
634  Res = XCOFF::getRelocationTypeString(Reloc->Type);
635  }
636  Result.append(Res.begin(), Res.end());
637 }
638 
639 Expected<uint32_t> XCOFFObjectFile::getSymbolFlags(DataRefImpl Symb) const {
640  XCOFFSymbolRef XCOFFSym = toSymbolRef(Symb);
641  uint32_t Result = SymbolRef::SF_None;
642 
643  if (XCOFFSym.getSectionNumber() == XCOFF::N_ABS)
644  Result |= SymbolRef::SF_Absolute;
645 
647  if (XCOFF::C_EXT == SC || XCOFF::C_WEAKEXT == SC)
648  Result |= SymbolRef::SF_Global;
649 
650  if (XCOFF::C_WEAKEXT == SC)
651  Result |= SymbolRef::SF_Weak;
652 
653  if (XCOFFSym.isCsectSymbol()) {
654  Expected<XCOFFCsectAuxRef> CsectAuxEntOrErr =
655  XCOFFSym.getXCOFFCsectAuxRef();
656  if (CsectAuxEntOrErr) {
657  if (CsectAuxEntOrErr.get().getSymbolType() == XCOFF::XTY_CM)
658  Result |= SymbolRef::SF_Common;
659  } else
660  return CsectAuxEntOrErr.takeError();
661  }
662 
663  if (XCOFFSym.getSectionNumber() == XCOFF::N_UNDEF)
664  Result |= SymbolRef::SF_Undefined;
665 
666  // There is no visibility in old 32 bit XCOFF object file interpret.
667  if (is64Bit() || (auxiliaryHeader32() && (auxiliaryHeader32()->getVersion() ==
669  uint16_t SymType = XCOFFSym.getSymbolType();
670  if ((SymType & VISIBILITY_MASK) == SYM_V_HIDDEN)
671  Result |= SymbolRef::SF_Hidden;
672 
673  if ((SymType & VISIBILITY_MASK) == SYM_V_EXPORTED)
674  Result |= SymbolRef::SF_Exported;
675  }
676  return Result;
677 }
678 
679 basic_symbol_iterator XCOFFObjectFile::symbol_begin() const {
680  DataRefImpl SymDRI;
681  SymDRI.p = reinterpret_cast<uintptr_t>(SymbolTblPtr);
682  return basic_symbol_iterator(SymbolRef(SymDRI, this));
683 }
684 
685 basic_symbol_iterator XCOFFObjectFile::symbol_end() const {
686  DataRefImpl SymDRI;
687  const uint32_t NumberOfSymbolTableEntries = getNumberOfSymbolTableEntries();
688  SymDRI.p = getSymbolEntryAddressByIndex(NumberOfSymbolTableEntries);
689  return basic_symbol_iterator(SymbolRef(SymDRI, this));
690 }
691 
692 section_iterator XCOFFObjectFile::section_begin() const {
693  DataRefImpl DRI;
694  DRI.p = getSectionHeaderTableAddress();
695  return section_iterator(SectionRef(DRI, this));
696 }
697 
698 section_iterator XCOFFObjectFile::section_end() const {
699  DataRefImpl DRI;
700  DRI.p = getWithOffset(getSectionHeaderTableAddress(),
701  getNumberOfSections() * getSectionHeaderSize());
702  return section_iterator(SectionRef(DRI, this));
703 }
704 
705 uint8_t XCOFFObjectFile::getBytesInAddress() const { return is64Bit() ? 8 : 4; }
706 
707 StringRef XCOFFObjectFile::getFileFormatName() const {
708  return is64Bit() ? "aix5coff64-rs6000" : "aixcoff-rs6000";
709 }
710 
711 Triple::ArchType XCOFFObjectFile::getArch() const {
712  return is64Bit() ? Triple::ppc64 : Triple::ppc;
713 }
714 
716  return SubtargetFeatures();
717 }
718 
719 bool XCOFFObjectFile::isRelocatableObject() const {
720  if (is64Bit())
721  return !(fileHeader64()->Flags & NoRelMask);
722  return !(fileHeader32()->Flags & NoRelMask);
723 }
724 
725 Expected<uint64_t> XCOFFObjectFile::getStartAddress() const {
726  // TODO FIXME Should get from auxiliary_header->o_entry when support for the
727  // auxiliary_header is added.
728  return 0;
729 }
730 
731 StringRef XCOFFObjectFile::mapDebugSectionName(StringRef Name) const {
732  return StringSwitch<StringRef>(Name)
733  .Case("dwinfo", "debug_info")
734  .Case("dwline", "debug_line")
735  .Case("dwpbnms", "debug_pubnames")
736  .Case("dwpbtyp", "debug_pubtypes")
737  .Case("dwarnge", "debug_aranges")
738  .Case("dwabrev", "debug_abbrev")
739  .Case("dwstr", "debug_str")
740  .Case("dwrnges", "debug_ranges")
741  .Case("dwloc", "debug_loc")
742  .Case("dwframe", "debug_frame")
743  .Case("dwmac", "debug_macinfo")
744  .Default(Name);
745 }
746 
747 size_t XCOFFObjectFile::getFileHeaderSize() const {
748  return is64Bit() ? sizeof(XCOFFFileHeader64) : sizeof(XCOFFFileHeader32);
749 }
750 
751 size_t XCOFFObjectFile::getSectionHeaderSize() const {
752  return is64Bit() ? sizeof(XCOFFSectionHeader64) :
753  sizeof(XCOFFSectionHeader32);
754 }
755 
757  return Binary::ID_XCOFF64 == getType();
758 }
759 
760 Expected<StringRef> XCOFFObjectFile::getRawData(const char *Start,
761  uint64_t Size,
762  StringRef Name) const {
763  uintptr_t StartPtr = reinterpret_cast<uintptr_t>(Start);
764  // TODO: this path is untested.
765  if (Error E = Binary::checkOffset(Data, StartPtr, Size))
766  return createError(toString(std::move(E)) + ": " + Name.data() +
767  " data with offset 0x" + Twine::utohexstr(StartPtr) +
768  " and size 0x" + Twine::utohexstr(Size) +
769  " goes past the end of the file");
770  return StringRef(Start, Size);
771 }
772 
774  return is64Bit() ? fileHeader64()->Magic : fileHeader32()->Magic;
775 }
776 
777 Expected<DataRefImpl> XCOFFObjectFile::getSectionByNum(int16_t Num) const {
778  if (Num <= 0 || Num > getNumberOfSections())
779  return createStringError(object_error::invalid_section_index,
780  "the section index (" + Twine(Num) +
781  ") is invalid");
782 
783  DataRefImpl DRI;
784  DRI.p = getWithOffset(getSectionHeaderTableAddress(),
785  getSectionHeaderSize() * (Num - 1));
786  return DRI;
787 }
788 
790 XCOFFObjectFile::getSectionByType(XCOFF::SectionTypeFlags SectType) const {
791  DataRefImpl DRI;
792  auto GetSectionAddr = [&](const auto &Sections) -> uintptr_t {
793  for (const auto &Sec : Sections)
794  if (Sec.getSectionType() == SectType)
795  return reinterpret_cast<uintptr_t>(&Sec);
796  return uintptr_t(0);
797  };
798  if (is64Bit())
799  DRI.p = GetSectionAddr(sections64());
800  else
801  DRI.p = GetSectionAddr(sections32());
802  return DRI;
803 }
804 
805 Expected<StringRef>
806 XCOFFObjectFile::getSymbolSectionName(XCOFFSymbolRef SymEntPtr) const {
807  const int16_t SectionNum = SymEntPtr.getSectionNumber();
808 
809  switch (SectionNum) {
810  case XCOFF::N_DEBUG:
811  return "N_DEBUG";
812  case XCOFF::N_ABS:
813  return "N_ABS";
814  case XCOFF::N_UNDEF:
815  return "N_UNDEF";
816  default:
817  Expected<DataRefImpl> SecRef = getSectionByNum(SectionNum);
818  if (SecRef)
820  getSectionNameInternal(SecRef.get()));
821  return SecRef.takeError();
822  }
823 }
824 
826  XCOFFSymbolRef XCOFFSymRef(Sym.getRawDataRefImpl(), this);
827  return XCOFFSymRef.getSectionNumber();
828 }
829 
830 bool XCOFFObjectFile::isReservedSectionNumber(int16_t SectionNumber) {
831  return (SectionNumber <= 0 && SectionNumber >= -2);
832 }
833 
834 uint16_t XCOFFObjectFile::getNumberOfSections() const {
835  return is64Bit() ? fileHeader64()->NumberOfSections
836  : fileHeader32()->NumberOfSections;
837 }
838 
839 int32_t XCOFFObjectFile::getTimeStamp() const {
840  return is64Bit() ? fileHeader64()->TimeStamp : fileHeader32()->TimeStamp;
841 }
842 
843 uint16_t XCOFFObjectFile::getOptionalHeaderSize() const {
844  return is64Bit() ? fileHeader64()->AuxHeaderSize
845  : fileHeader32()->AuxHeaderSize;
846 }
847 
848 uint32_t XCOFFObjectFile::getSymbolTableOffset32() const {
849  return fileHeader32()->SymbolTableOffset;
850 }
851 
852 int32_t XCOFFObjectFile::getRawNumberOfSymbolTableEntries32() const {
853  // As far as symbol table size is concerned, if this field is negative it is
854  // to be treated as a 0. However since this field is also used for printing we
855  // don't want to truncate any negative values.
856  return fileHeader32()->NumberOfSymTableEntries;
857 }
858 
859 uint32_t XCOFFObjectFile::getLogicalNumberOfSymbolTableEntries32() const {
860  return (fileHeader32()->NumberOfSymTableEntries >= 0
861  ? fileHeader32()->NumberOfSymTableEntries
862  : 0);
863 }
864 
865 uint64_t XCOFFObjectFile::getSymbolTableOffset64() const {
866  return fileHeader64()->SymbolTableOffset;
867 }
868 
869 uint32_t XCOFFObjectFile::getNumberOfSymbolTableEntries64() const {
870  return fileHeader64()->NumberOfSymTableEntries;
871 }
872 
873 uint32_t XCOFFObjectFile::getNumberOfSymbolTableEntries() const {
874  return is64Bit() ? getNumberOfSymbolTableEntries64()
875  : getLogicalNumberOfSymbolTableEntries32();
876 }
877 
878 uintptr_t XCOFFObjectFile::getEndOfSymbolTableAddress() const {
879  const uint32_t NumberOfSymTableEntries = getNumberOfSymbolTableEntries();
880  return getWithOffset(reinterpret_cast<uintptr_t>(SymbolTblPtr),
881  XCOFF::SymbolTableEntrySize * NumberOfSymTableEntries);
882 }
883 
884 void XCOFFObjectFile::checkSymbolEntryPointer(uintptr_t SymbolEntPtr) const {
885  if (SymbolEntPtr < reinterpret_cast<uintptr_t>(SymbolTblPtr))
886  report_fatal_error("Symbol table entry is outside of symbol table.");
887 
888  if (SymbolEntPtr >= getEndOfSymbolTableAddress())
889  report_fatal_error("Symbol table entry is outside of symbol table.");
890 
891  ptrdiff_t Offset = reinterpret_cast<const char *>(SymbolEntPtr) -
892  reinterpret_cast<const char *>(SymbolTblPtr);
893 
894  if (Offset % XCOFF::SymbolTableEntrySize != 0)
896  "Symbol table entry position is not valid inside of symbol table.");
897 }
898 
899 uint32_t XCOFFObjectFile::getSymbolIndex(uintptr_t SymbolEntPtr) const {
900  return (reinterpret_cast<const char *>(SymbolEntPtr) -
901  reinterpret_cast<const char *>(SymbolTblPtr)) /
903 }
904 
905 uint64_t XCOFFObjectFile::getSymbolSize(DataRefImpl Symb) const {
906  uint64_t Result = 0;
907  XCOFFSymbolRef XCOFFSym = toSymbolRef(Symb);
908  if (XCOFFSym.isCsectSymbol()) {
909  Expected<XCOFFCsectAuxRef> CsectAuxRefOrError =
910  XCOFFSym.getXCOFFCsectAuxRef();
911  if (!CsectAuxRefOrError)
912  // TODO: report the error up the stack.
913  consumeError(CsectAuxRefOrError.takeError());
914  else {
915  XCOFFCsectAuxRef CsectAuxRef = CsectAuxRefOrError.get();
916  uint8_t SymType = CsectAuxRef.getSymbolType();
917  if (SymType == XCOFF::XTY_SD || SymType == XCOFF::XTY_CM)
918  Result = CsectAuxRef.getSectionOrLength();
919  }
920  }
921  return Result;
922 }
923 
924 uintptr_t XCOFFObjectFile::getSymbolEntryAddressByIndex(uint32_t Index) const {
925  return getAdvancedSymbolEntryAddress(
926  reinterpret_cast<uintptr_t>(getPointerToSymbolTable()), Index);
927 }
928 
930 XCOFFObjectFile::getSymbolNameByIndex(uint32_t Index) const {
931  const uint32_t NumberOfSymTableEntries = getNumberOfSymbolTableEntries();
932 
933  if (Index >= NumberOfSymTableEntries)
934  return createError("symbol index " + Twine(Index) +
935  " exceeds symbol count " +
936  Twine(NumberOfSymTableEntries));
937 
938  DataRefImpl SymDRI;
939  SymDRI.p = getSymbolEntryAddressByIndex(Index);
940  return getSymbolName(SymDRI);
941 }
942 
944  return is64Bit() ? fileHeader64()->Flags : fileHeader32()->Flags;
945 }
946 
947 const char *XCOFFObjectFile::getSectionNameInternal(DataRefImpl Sec) const {
948  return is64Bit() ? toSection64(Sec)->Name : toSection32(Sec)->Name;
949 }
950 
951 uintptr_t XCOFFObjectFile::getSectionHeaderTableAddress() const {
952  return reinterpret_cast<uintptr_t>(SectionHeaderTable);
953 }
954 
956  return is64Bit() ? toSection64(Sec)->Flags : toSection32(Sec)->Flags;
957 }
958 
959 XCOFFObjectFile::XCOFFObjectFile(unsigned int Type, MemoryBufferRef Object)
960  : ObjectFile(Type, Object) {
962 }
963 
965  assert(is64Bit() && "64-bit interface called for non 64-bit file.");
966  const XCOFFSectionHeader64 *TablePtr = sectionHeaderTable64();
967  return ArrayRef<XCOFFSectionHeader64>(TablePtr,
968  TablePtr + getNumberOfSections());
969 }
970 
972  assert(!is64Bit() && "32-bit interface called for non 32-bit file.");
973  const XCOFFSectionHeader32 *TablePtr = sectionHeaderTable32();
974  return ArrayRef<XCOFFSectionHeader32>(TablePtr,
975  TablePtr + getNumberOfSections());
976 }
977 
978 // In an XCOFF32 file, when the field value is 65535, then an STYP_OVRFLO
979 // section header contains the actual count of relocation entries in the s_paddr
980 // field. STYP_OVRFLO headers contain the section index of their corresponding
981 // sections as their raw "NumberOfRelocations" field value.
982 template <typename T>
984  const XCOFFSectionHeader<T> &Sec) const {
985  const T &Section = static_cast<const T &>(Sec);
986  if (is64Bit())
987  return Section.NumberOfRelocations;
988 
989  uint16_t SectionIndex = &Section - sectionHeaderTable<T>() + 1;
990  if (Section.NumberOfRelocations < XCOFF::RelocOverflow)
991  return Section.NumberOfRelocations;
992  for (const auto &Sec : sections32()) {
993  if (Sec.Flags == XCOFF::STYP_OVRFLO &&
994  Sec.NumberOfRelocations == SectionIndex)
995  return Sec.PhysicalAddress;
996  }
998 }
999 
1000 template <typename Shdr, typename Reloc>
1002  uintptr_t RelocAddr = getWithOffset(reinterpret_cast<uintptr_t>(FileHeader),
1003  Sec.FileOffsetToRelocationInfo);
1004  auto NumRelocEntriesOrErr = getNumberOfRelocationEntries(Sec);
1005  if (Error E = NumRelocEntriesOrErr.takeError())
1006  return std::move(E);
1007 
1008  uint32_t NumRelocEntries = NumRelocEntriesOrErr.get();
1009  static_assert((sizeof(Reloc) == XCOFF::RelocationSerializationSize64 ||
1010  sizeof(Reloc) == XCOFF::RelocationSerializationSize32),
1011  "Relocation structure is incorrect");
1012  auto RelocationOrErr =
1013  getObject<Reloc>(Data, reinterpret_cast<void *>(RelocAddr),
1014  NumRelocEntries * sizeof(Reloc));
1015  if (!RelocationOrErr)
1016  return createError(
1017  toString(RelocationOrErr.takeError()) + ": relocations with offset 0x" +
1018  Twine::utohexstr(Sec.FileOffsetToRelocationInfo) + " and size 0x" +
1019  Twine::utohexstr(NumRelocEntries * sizeof(Reloc)) +
1020  " go past the end of the file");
1021 
1022  const Reloc *StartReloc = RelocationOrErr.get();
1023 
1024  return ArrayRef<Reloc>(StartReloc, StartReloc + NumRelocEntries);
1025 }
1026 
1027 template <typename ExceptEnt>
1029  assert((is64Bit() && sizeof(ExceptEnt) == sizeof(ExceptionSectionEntry64)) ||
1030  (!is64Bit() && sizeof(ExceptEnt) == sizeof(ExceptionSectionEntry32)));
1031 
1032  Expected<uintptr_t> ExceptionSectOrErr =
1033  getSectionFileOffsetToRawData(XCOFF::STYP_EXCEPT);
1034  if (!ExceptionSectOrErr)
1035  return ExceptionSectOrErr.takeError();
1036 
1037  DataRefImpl DRI = getSectionByType(XCOFF::STYP_EXCEPT);
1038  if (DRI.p == 0)
1039  return ArrayRef<ExceptEnt>();
1040 
1041  ExceptEnt *ExceptEntStart =
1042  reinterpret_cast<ExceptEnt *>(*ExceptionSectOrErr);
1043  return ArrayRef<ExceptEnt>(
1044  ExceptEntStart, ExceptEntStart + getSectionSize(DRI) / sizeof(ExceptEnt));
1045 }
1046 
1051 
1053 XCOFFObjectFile::parseStringTable(const XCOFFObjectFile *Obj, uint64_t Offset) {
1054  // If there is a string table, then the buffer must contain at least 4 bytes
1055  // for the string table's size. Not having a string table is not an error.
1056  if (Error E = Binary::checkOffset(
1057  Obj->Data, reinterpret_cast<uintptr_t>(Obj->base() + Offset), 4)) {
1059  return XCOFFStringTable{0, nullptr};
1060  }
1061 
1062  // Read the size out of the buffer.
1063  uint32_t Size = support::endian::read32be(Obj->base() + Offset);
1064 
1065  // If the size is less then 4, then the string table is just a size and no
1066  // string data.
1067  if (Size <= 4)
1068  return XCOFFStringTable{4, nullptr};
1069 
1070  auto StringTableOrErr =
1071  getObject<char>(Obj->Data, Obj->base() + Offset, Size);
1072  if (!StringTableOrErr)
1073  return createError(toString(StringTableOrErr.takeError()) +
1074  ": string table with offset 0x" +
1075  Twine::utohexstr(Offset) + " and size 0x" +
1076  Twine::utohexstr(Size) +
1077  " goes past the end of the file");
1078 
1079  const char *StringTablePtr = StringTableOrErr.get();
1080  if (StringTablePtr[Size - 1] != '\0')
1082 
1083  return XCOFFStringTable{Size, StringTablePtr};
1084 }
1085 
1086 // This function returns the import file table. Each entry in the import file
1087 // table consists of: "path_name\0base_name\0archive_member_name\0".
1089  Expected<uintptr_t> LoaderSectionAddrOrError =
1090  getSectionFileOffsetToRawData(XCOFF::STYP_LOADER);
1091  if (!LoaderSectionAddrOrError)
1092  return LoaderSectionAddrOrError.takeError();
1093 
1094  uintptr_t LoaderSectionAddr = LoaderSectionAddrOrError.get();
1095  if (!LoaderSectionAddr)
1096  return StringRef();
1097 
1098  uint64_t OffsetToImportFileTable = 0;
1099  uint64_t LengthOfImportFileTable = 0;
1100  if (is64Bit()) {
1101  const LoaderSectionHeader64 *LoaderSec64 =
1102  viewAs<LoaderSectionHeader64>(LoaderSectionAddr);
1103  OffsetToImportFileTable = LoaderSec64->OffsetToImpid;
1104  LengthOfImportFileTable = LoaderSec64->LengthOfImpidStrTbl;
1105  } else {
1106  const LoaderSectionHeader32 *LoaderSec32 =
1107  viewAs<LoaderSectionHeader32>(LoaderSectionAddr);
1108  OffsetToImportFileTable = LoaderSec32->OffsetToImpid;
1109  LengthOfImportFileTable = LoaderSec32->LengthOfImpidStrTbl;
1110  }
1111 
1112  auto ImportTableOrErr = getObject<char>(
1113  Data,
1114  reinterpret_cast<void *>(LoaderSectionAddr + OffsetToImportFileTable),
1115  LengthOfImportFileTable);
1116  if (!ImportTableOrErr)
1117  return createError(
1118  toString(ImportTableOrErr.takeError()) +
1119  ": import file table with offset 0x" +
1120  Twine::utohexstr(LoaderSectionAddr + OffsetToImportFileTable) +
1121  " and size 0x" + Twine::utohexstr(LengthOfImportFileTable) +
1122  " goes past the end of the file");
1123 
1124  const char *ImportTablePtr = ImportTableOrErr.get();
1125  if (ImportTablePtr[LengthOfImportFileTable - 1] != '\0')
1126  return createError(
1127  ": import file name table with offset 0x" +
1128  Twine::utohexstr(LoaderSectionAddr + OffsetToImportFileTable) +
1129  " and size 0x" + Twine::utohexstr(LengthOfImportFileTable) +
1130  " must end with a null terminator");
1131 
1132  return StringRef(ImportTablePtr, LengthOfImportFileTable);
1133 }
1134 
1136 XCOFFObjectFile::create(unsigned Type, MemoryBufferRef MBR) {
1137  // Can't use std::make_unique because of the private constructor.
1138  std::unique_ptr<XCOFFObjectFile> Obj;
1139  Obj.reset(new XCOFFObjectFile(Type, MBR));
1140 
1141  uint64_t CurOffset = 0;
1142  const auto *Base = Obj->base();
1143  MemoryBufferRef Data = Obj->Data;
1144 
1145  // Parse file header.
1146  auto FileHeaderOrErr =
1147  getObject<void>(Data, Base + CurOffset, Obj->getFileHeaderSize());
1148  if (Error E = FileHeaderOrErr.takeError())
1149  return std::move(E);
1150  Obj->FileHeader = FileHeaderOrErr.get();
1151 
1152  CurOffset += Obj->getFileHeaderSize();
1153 
1154  if (Obj->getOptionalHeaderSize()) {
1155  auto AuxiliaryHeaderOrErr =
1156  getObject<void>(Data, Base + CurOffset, Obj->getOptionalHeaderSize());
1157  if (Error E = AuxiliaryHeaderOrErr.takeError())
1158  return std::move(E);
1159  Obj->AuxiliaryHeader = AuxiliaryHeaderOrErr.get();
1160  }
1161 
1162  CurOffset += Obj->getOptionalHeaderSize();
1163 
1164  // Parse the section header table if it is present.
1165  if (Obj->getNumberOfSections()) {
1166  uint64_t SectionHeadersSize =
1167  Obj->getNumberOfSections() * Obj->getSectionHeaderSize();
1168  auto SecHeadersOrErr =
1169  getObject<void>(Data, Base + CurOffset, SectionHeadersSize);
1170  if (!SecHeadersOrErr)
1171  return createError(toString(SecHeadersOrErr.takeError()) +
1172  ": section headers with offset 0x" +
1173  Twine::utohexstr(CurOffset) + " and size 0x" +
1174  Twine::utohexstr(SectionHeadersSize) +
1175  " go past the end of the file");
1176 
1177  Obj->SectionHeaderTable = SecHeadersOrErr.get();
1178  }
1179 
1180  const uint32_t NumberOfSymbolTableEntries =
1181  Obj->getNumberOfSymbolTableEntries();
1182 
1183  // If there is no symbol table we are done parsing the memory buffer.
1184  if (NumberOfSymbolTableEntries == 0)
1185  return std::move(Obj);
1186 
1187  // Parse symbol table.
1188  CurOffset = Obj->is64Bit() ? Obj->getSymbolTableOffset64()
1189  : Obj->getSymbolTableOffset32();
1190  const uint64_t SymbolTableSize =
1191  static_cast<uint64_t>(XCOFF::SymbolTableEntrySize) *
1192  NumberOfSymbolTableEntries;
1193  auto SymTableOrErr =
1194  getObject<void *>(Data, Base + CurOffset, SymbolTableSize);
1195  if (!SymTableOrErr)
1196  return createError(
1197  toString(SymTableOrErr.takeError()) + ": symbol table with offset 0x" +
1198  Twine::utohexstr(CurOffset) + " and size 0x" +
1199  Twine::utohexstr(SymbolTableSize) + " goes past the end of the file");
1200 
1201  Obj->SymbolTblPtr = SymTableOrErr.get();
1202  CurOffset += SymbolTableSize;
1203 
1204  // Parse String table.
1205  Expected<XCOFFStringTable> StringTableOrErr =
1206  parseStringTable(Obj.get(), CurOffset);
1207  if (Error E = StringTableOrErr.takeError())
1208  return std::move(E);
1209  Obj->StringTable = StringTableOrErr.get();
1210 
1211  return std::move(Obj);
1212 }
1213 
1214 Expected<std::unique_ptr<ObjectFile>>
1216  unsigned FileType) {
1217  return XCOFFObjectFile::create(FileType, MemBufRef);
1218 }
1219 
1221  if (!isCsectSymbol())
1222  return false;
1223 
1224  if (getSymbolType() & FunctionSym)
1225  return true;
1226 
1228  if (!ExpCsectAuxEnt) {
1229  // If we could not get the CSECT auxiliary entry, then treat this symbol as
1230  // if it isn't a function. Consume the error and return `false` to move on.
1231  consumeError(ExpCsectAuxEnt.takeError());
1232  return false;
1233  }
1234 
1235  const XCOFFCsectAuxRef CsectAuxRef = ExpCsectAuxEnt.get();
1236 
1237  // A function definition should be a label definition.
1238  // FIXME: This is not necessarily the case when -ffunction-sections is
1239  // enabled.
1240  if (!CsectAuxRef.isLabel())
1241  return false;
1242 
1243  if (CsectAuxRef.getStorageMappingClass() != XCOFF::XMC_PR)
1244  return false;
1245 
1246  const int16_t SectNum = getSectionNumber();
1247  Expected<DataRefImpl> SI = OwningObjectPtr->getSectionByNum(SectNum);
1248  if (!SI) {
1249  // If we could not get the section, then this symbol should not be
1250  // a function. So consume the error and return `false` to move on.
1251  consumeError(SI.takeError());
1252  return false;
1253  }
1254 
1255  return (OwningObjectPtr->getSectionFlags(SI.get()) & XCOFF::STYP_TEXT);
1256 }
1257 
1260  return (SC == XCOFF::C_EXT || SC == XCOFF::C_WEAKEXT ||
1261  SC == XCOFF::C_HIDEXT);
1262 }
1263 
1265  assert(isCsectSymbol() &&
1266  "Calling csect symbol interface with a non-csect symbol.");
1267 
1268  uint8_t NumberOfAuxEntries = getNumberOfAuxEntries();
1269 
1270  Expected<StringRef> NameOrErr = getName();
1271  if (auto Err = NameOrErr.takeError())
1272  return std::move(Err);
1273 
1274  uint32_t SymbolIdx = OwningObjectPtr->getSymbolIndex(getEntryAddress());
1275  if (!NumberOfAuxEntries) {
1276  return createError("csect symbol \"" + *NameOrErr + "\" with index " +
1277  Twine(SymbolIdx) + " contains no auxiliary entry");
1278  }
1279 
1280  if (!OwningObjectPtr->is64Bit()) {
1281  // In XCOFF32, the csect auxilliary entry is always the last auxiliary
1282  // entry for the symbol.
1284  getEntryAddress(), NumberOfAuxEntries);
1285  return XCOFFCsectAuxRef(viewAs<XCOFFCsectAuxEnt32>(AuxAddr));
1286  }
1287 
1288  // XCOFF64 uses SymbolAuxType to identify the auxiliary entry type.
1289  // We need to iterate through all the auxiliary entries to find it.
1290  for (uint8_t Index = NumberOfAuxEntries; Index > 0; --Index) {
1292  getEntryAddress(), Index);
1293  if (*OwningObjectPtr->getSymbolAuxType(AuxAddr) ==
1295 #ifndef NDEBUG
1296  OwningObjectPtr->checkSymbolEntryPointer(AuxAddr);
1297 #endif
1298  return XCOFFCsectAuxRef(viewAs<XCOFFCsectAuxEnt64>(AuxAddr));
1299  }
1300  }
1301 
1302  return createError(
1303  "a csect auxiliary entry has not been found for symbol \"" + *NameOrErr +
1304  "\" with index " + Twine(SymbolIdx));
1305 }
1306 
1308  // A storage class value with the high-order bit on indicates that the name is
1309  // a symbolic debugger stabstring.
1310  if (getStorageClass() & 0x80)
1311  return StringRef("Unimplemented Debug Name");
1312 
1313  if (Entry32) {
1316 
1317  return OwningObjectPtr->getStringTableEntry(Entry32->NameInStrTbl.Offset);
1318  }
1319 
1320  return OwningObjectPtr->getStringTableEntry(Entry64->Offset);
1321 }
1322 
1323 // Explictly instantiate template classes.
1326 
1329 
1333  llvm::object::XCOFFSectionHeader64 const &) const;
1337  llvm::object::XCOFFSectionHeader32 const &) const;
1338 
1340  if (Bytes.size() < 4)
1341  return false;
1342 
1343  return support::endian::read32be(Bytes.data()) == 0;
1344 }
1345 
1346 #define GETVALUEWITHMASK(X) (Data & (TracebackTable::X))
1347 #define GETVALUEWITHMASKSHIFT(X, S) \
1348  ((Data & (TracebackTable::X)) >> (TracebackTable::S))
1349 
1351  Error Err = Error::success();
1352  TBVectorExt TBTVecExt(TBvectorStrRef, Err);
1353  if (Err)
1354  return std::move(Err);
1355  return TBTVecExt;
1356 }
1357 
1358 TBVectorExt::TBVectorExt(StringRef TBvectorStrRef, Error &Err) {
1359  const uint8_t *Ptr = reinterpret_cast<const uint8_t *>(TBvectorStrRef.data());
1361  uint32_t VecParmsTypeValue = support::endian::read32be(Ptr + 2);
1362  unsigned ParmsNum =
1363  GETVALUEWITHMASKSHIFT(NumberOfVectorParmsMask, NumberOfVectorParmsShift);
1364 
1365  ErrorAsOutParameter EAO(&Err);
1366  Expected<SmallString<32>> VecParmsTypeOrError =
1367  parseVectorParmsType(VecParmsTypeValue, ParmsNum);
1368  if (!VecParmsTypeOrError)
1369  Err = VecParmsTypeOrError.takeError();
1370  else
1371  VecParmsInfo = VecParmsTypeOrError.get();
1372 }
1373 
1375  return GETVALUEWITHMASKSHIFT(NumberOfVRSavedMask, NumberOfVRSavedShift);
1376 }
1377 
1379  return GETVALUEWITHMASK(IsVRSavedOnStackMask);
1380 }
1381 
1383  return GETVALUEWITHMASK(HasVarArgsMask);
1384 }
1385 
1387  return GETVALUEWITHMASKSHIFT(NumberOfVectorParmsMask,
1388  NumberOfVectorParmsShift);
1389 }
1390 
1392  return GETVALUEWITHMASK(HasVMXInstructionMask);
1393 }
1394 #undef GETVALUEWITHMASK
1395 #undef GETVALUEWITHMASKSHIFT
1396 
1398  uint64_t &Size) {
1399  Error Err = Error::success();
1400  XCOFFTracebackTable TBT(Ptr, Size, Err);
1401  if (Err)
1402  return std::move(Err);
1403  return TBT;
1404 }
1405 
1406 XCOFFTracebackTable::XCOFFTracebackTable(const uint8_t *Ptr, uint64_t &Size,
1407  Error &Err)
1408  : TBPtr(Ptr) {
1409  ErrorAsOutParameter EAO(&Err);
1410  DataExtractor DE(ArrayRef<uint8_t>(Ptr, Size), /*IsLittleEndian=*/false,
1411  /*AddressSize=*/0);
1412  DataExtractor::Cursor Cur(/*Offset=*/0);
1413 
1414  // Skip 8 bytes of mandatory fields.
1415  DE.getU64(Cur);
1416 
1417  unsigned FixedParmsNum = getNumberOfFixedParms();
1418  unsigned FloatingParmsNum = getNumberOfFPParms();
1419  uint32_t ParamsTypeValue = 0;
1420 
1421  // Begin to parse optional fields.
1422  if (Cur && (FixedParmsNum + FloatingParmsNum) > 0)
1423  ParamsTypeValue = DE.getU32(Cur);
1424 
1425  if (Cur && hasTraceBackTableOffset())
1426  TraceBackTableOffset = DE.getU32(Cur);
1427 
1428  if (Cur && isInterruptHandler())
1429  HandlerMask = DE.getU32(Cur);
1430 
1431  if (Cur && hasControlledStorage()) {
1432  NumOfCtlAnchors = DE.getU32(Cur);
1433  if (Cur && NumOfCtlAnchors) {
1435  Disp.reserve(*NumOfCtlAnchors);
1436  for (uint32_t I = 0; I < NumOfCtlAnchors && Cur; ++I)
1437  Disp.push_back(DE.getU32(Cur));
1438  if (Cur)
1439  ControlledStorageInfoDisp = std::move(Disp);
1440  }
1441  }
1442 
1443  if (Cur && isFuncNamePresent()) {
1444  uint16_t FunctionNameLen = DE.getU16(Cur);
1445  if (Cur)
1446  FunctionName = DE.getBytes(Cur, FunctionNameLen);
1447  }
1448 
1449  if (Cur && isAllocaUsed())
1450  AllocaRegister = DE.getU8(Cur);
1451 
1452  unsigned VectorParmsNum = 0;
1453  if (Cur && hasVectorInfo()) {
1454  StringRef VectorExtRef = DE.getBytes(Cur, 6);
1455  if (Cur) {
1456  Expected<TBVectorExt> TBVecExtOrErr = TBVectorExt::create(VectorExtRef);
1457  if (!TBVecExtOrErr) {
1458  Err = TBVecExtOrErr.takeError();
1459  return;
1460  }
1461  VecExt = TBVecExtOrErr.get();
1462  VectorParmsNum = VecExt->getNumberOfVectorParms();
1463  }
1464  }
1465 
1466  // As long as there is no fixed-point or floating-point parameter, this
1467  // field remains not present even when hasVectorInfo gives true and
1468  // indicates the presence of vector parameters.
1469  if (Cur && (FixedParmsNum + FloatingParmsNum) > 0) {
1470  Expected<SmallString<32>> ParmsTypeOrError =
1471  hasVectorInfo()
1472  ? parseParmsTypeWithVecInfo(ParamsTypeValue, FixedParmsNum,
1473  FloatingParmsNum, VectorParmsNum)
1474  : parseParmsType(ParamsTypeValue, FixedParmsNum, FloatingParmsNum);
1475 
1476  if (!ParmsTypeOrError) {
1477  Err = ParmsTypeOrError.takeError();
1478  return;
1479  }
1480  ParmsType = ParmsTypeOrError.get();
1481  }
1482 
1483  if (Cur && hasExtensionTable())
1484  ExtensionTable = DE.getU8(Cur);
1485 
1486  if (!Cur)
1487  Err = Cur.takeError();
1488 
1489  Size = Cur.tell();
1490 }
1491 
1492 #define GETBITWITHMASK(P, X) \
1493  (support::endian::read32be(TBPtr + (P)) & (TracebackTable::X))
1494 #define GETBITWITHMASKSHIFT(P, X, S) \
1495  ((support::endian::read32be(TBPtr + (P)) & (TracebackTable::X)) >> \
1496  (TracebackTable::S))
1497 
1499  return GETBITWITHMASKSHIFT(0, VersionMask, VersionShift);
1500 }
1501 
1503  return GETBITWITHMASKSHIFT(0, LanguageIdMask, LanguageIdShift);
1504 }
1505 
1507  return GETBITWITHMASK(0, IsGlobaLinkageMask);
1508 }
1509 
1511  return GETBITWITHMASK(0, IsOutOfLineEpilogOrPrologueMask);
1512 }
1513 
1515  return GETBITWITHMASK(0, HasTraceBackTableOffsetMask);
1516 }
1517 
1519  return GETBITWITHMASK(0, IsInternalProcedureMask);
1520 }
1521 
1523  return GETBITWITHMASK(0, HasControlledStorageMask);
1524 }
1525 
1527  return GETBITWITHMASK(0, IsTOClessMask);
1528 }
1529 
1531  return GETBITWITHMASK(0, IsFloatingPointPresentMask);
1532 }
1533 
1535  return GETBITWITHMASK(0, IsFloatingPointOperationLogOrAbortEnabledMask);
1536 }
1537 
1539  return GETBITWITHMASK(0, IsInterruptHandlerMask);
1540 }
1541 
1543  return GETBITWITHMASK(0, IsFunctionNamePresentMask);
1544 }
1545 
1547  return GETBITWITHMASK(0, IsAllocaUsedMask);
1548 }
1549 
1551  return GETBITWITHMASKSHIFT(0, OnConditionDirectiveMask,
1552  OnConditionDirectiveShift);
1553 }
1554 
1556  return GETBITWITHMASK(0, IsCRSavedMask);
1557 }
1558 
1560  return GETBITWITHMASK(0, IsLRSavedMask);
1561 }
1562 
1564  return GETBITWITHMASK(4, IsBackChainStoredMask);
1565 }
1566 
1568  return GETBITWITHMASK(4, IsFixupMask);
1569 }
1570 
1572  return GETBITWITHMASKSHIFT(4, FPRSavedMask, FPRSavedShift);
1573 }
1574 
1576  return GETBITWITHMASK(4, HasExtensionTableMask);
1577 }
1578 
1580  return GETBITWITHMASK(4, HasVectorInfoMask);
1581 }
1582 
1584  return GETBITWITHMASKSHIFT(4, GPRSavedMask, GPRSavedShift);
1585 }
1586 
1588  return GETBITWITHMASKSHIFT(4, NumberOfFixedParmsMask,
1589  NumberOfFixedParmsShift);
1590 }
1591 
1593  return GETBITWITHMASKSHIFT(4, NumberOfFloatingPointParmsMask,
1594  NumberOfFloatingPointParmsShift);
1595 }
1596 
1598  return GETBITWITHMASK(4, HasParmsOnStackMask);
1599 }
1600 
1601 #undef GETBITWITHMASK
1602 #undef GETBITWITHMASKSHIFT
1603 } // namespace object
1604 } // namespace llvm
llvm::Check::Size
@ Size
Definition: FileCheck.h:77
llvm::StringSwitch::Case
StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:69
llvm::object::XCOFFTracebackTable::isTOCless
bool isTOCless() const
Definition: XCOFFObjectFile.cpp:1526
llvm::object::XCOFFTracebackTable::isInterruptHandler
bool isInterruptHandler() const
Definition: XCOFFObjectFile.cpp:1538
getName
static StringRef getName(Value *V)
Definition: ProvenanceAnalysisEvaluator.cpp:20
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::object::ExceptionSectionEntry
Definition: XCOFFObjectFile.h:259
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:171
llvm::XCOFF::STYP_EXCEPT
@ STYP_EXCEPT
Definition: XCOFF.h:127
llvm::object::XCOFFTracebackTable::hasParmsOnStack
bool hasParmsOnStack() const
Definition: XCOFFObjectFile.cpp:1597
llvm::object::XCOFFSymbolRef::getXCOFFCsectAuxRef
Expected< XCOFFCsectAuxRef > getXCOFFCsectAuxRef() const
Definition: XCOFFObjectFile.cpp:1264
llvm::object::TBVectorExt::hasVarArgs
bool hasVarArgs() const
Definition: XCOFFObjectFile.cpp:1382
llvm::object::XCOFFSymbolRef::getName
Expected< StringRef > getName() const
Definition: XCOFFObjectFile.cpp:1307
llvm::object::XCOFFObjectFile::getSymbolIndex
uint32_t getSymbolIndex(uintptr_t SymEntPtr) const
Definition: XCOFFObjectFile.cpp:899
llvm::XCOFF::RelocationSerializationSize64
constexpr size_t RelocationSerializationSize64
Definition: XCOFF.h:39
llvm::object::XCOFFFileHeader32
Definition: XCOFFObjectFile.h:26
is64Bit
static bool is64Bit(const char *name)
Definition: X86Disassembler.cpp:1018
llvm::XCOFF::STYP_BSS
@ STYP_BSS
Definition: XCOFF.h:126
llvm::XCOFF::STYP_TYPCHK
@ STYP_TYPCHK
Definition: XCOFF.h:133
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1199
llvm::object::XCOFFRelocation::VirtualAddress
AddressType VirtualAddress
Definition: XCOFFObjectFile.h:486
llvm::XCOFF::C_FILE
@ C_FILE
Definition: XCOFF.h:159
llvm::object::XCOFFTracebackTable::isFloatingPointPresent
bool isFloatingPointPresent() const
Definition: XCOFFObjectFile.cpp:1530
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:329
llvm::object::XCOFFTracebackTable::getVersion
uint8_t getVersion() const
Definition: XCOFFObjectFile.cpp:1498
llvm::XCOFF::XMC_PR
@ XMC_PR
Program Code.
Definition: XCOFF.h:92
llvm::object::XCOFFTracebackTable::isBackChainStored
bool isBackChainStored() const
Definition: XCOFFObjectFile.cpp:1563
llvm::object::LoaderSectionHeader64::OffsetToImpid
support::big64_t OffsetToImpid
Definition: XCOFFObjectFile.h:220
llvm::object::XCOFFSectionHeader
Definition: XCOFFObjectFile.h:152
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:756
llvm::object::XCOFFTracebackTable::isOutOfLineEpilogOrPrologue
bool isOutOfLineEpilogOrPrologue() const
Definition: XCOFFObjectFile.cpp:1510
llvm::XCOFF::NEW_XCOFF_INTERPRET
@ NEW_XCOFF_INTERPRET
Definition: XCOFF.h:62
llvm::object::XCOFFAuxiliaryHeader64
Definition: XCOFFObjectFile.h:119
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:506
llvm::object::Binary::Data
MemoryBufferRef Data
Definition: Binary.h:37
llvm::object::XCOFFFileAuxEnt::NameInStrTblType::Magic
support::big32_t Magic
Definition: XCOFFObjectFile.h:399
llvm::Triple::ppc
@ ppc
Definition: Triple.h:69
llvm::object::TBVectorExt::hasVMXInstruction
bool hasVMXInstruction() const
Definition: XCOFFObjectFile.cpp:1391
T
#define T
Definition: Mips16ISelLowering.cpp:341
GETBITWITHMASKSHIFT
#define GETBITWITHMASKSHIFT(P, X, S)
Definition: XCOFFObjectFile.cpp:1494
llvm::object::XCOFFFileAuxEnt::Name
char Name[XCOFF::NameSize+XCOFF::FileNamePadSize]
Definition: XCOFFObjectFile.h:404
llvm::RawInstrProf::getMagic
uint64_t getMagic()
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:119
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
llvm::support::endian::read32be
uint32_t read32be(const void *P)
Definition: Endian.h:384
llvm::XCOFF::STYP_LOADER
@ STYP_LOADER
Definition: XCOFF.h:131
llvm::object::XCOFFSymbolRef::getNumberOfAuxEntries
uint8_t getNumberOfAuxEntries() const
Definition: XCOFFObjectFile.h:797
llvm::object::XCOFFFileHeader64
Definition: XCOFFObjectFile.h:40
llvm::object::LoaderSectionHeader64::LengthOfImpidStrTbl
support::ubig32_t LengthOfImpidStrTbl
Definition: XCOFFObjectFile.h:217
llvm::object::XCOFFCsectAuxRef::getSymbolType
uint8_t getSymbolType() const
Definition: XCOFFObjectFile.h:365
llvm::XCOFF::STYP_PAD
@ STYP_PAD
Definition: XCOFF.h:122
llvm::consumeError
void consumeError(Error Err)
Consume a Error without doing anything.
Definition: Error.h:1042
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
llvm::object::XCOFFCsectAuxRef::getSectionOrLength
uint64_t getSectionOrLength() const
Definition: XCOFFObjectFile.h:328
llvm::object::XCOFFSymbolRef::isFunction
bool isFunction() const
Definition: XCOFFObjectFile.cpp:1220
llvm::XCOFF::STYP_DWARF
@ STYP_DWARF
Definition: XCOFF.h:123
llvm::ArrayRef::data
const T * data() const
Definition: ArrayRef.h:161
llvm::object::XCOFFCsectAuxRef
Definition: XCOFFObjectFile.h:314
llvm::object::XCOFFObjectFile::getImportFileTable
Expected< StringRef > getImportFileTable() const
Definition: XCOFFObjectFile.cpp:1088
llvm::object::XCOFFSymbolRef
Definition: XCOFFObjectFile.h:751
llvm::object::XCOFFSectionHeader32::VirtualAddress
support::ubig32_t VirtualAddress
Definition: XCOFFObjectFile.h:174
llvm::object::XCOFFObjectFile::getSectionByNum
Expected< DataRefImpl > getSectionByNum(int16_t Num) const
Definition: XCOFFObjectFile.cpp:777
getSectionFlags
static uint32_t getSectionFlags(const MachOObjectFile &O, DataRefImpl Sec)
Definition: MachOObjectFile.cpp:180
llvm::object::XCOFFTracebackTable::isFuncNamePresent
bool isFuncNamePresent() const
Definition: XCOFFObjectFile.cpp:1542
llvm::object::XCOFFTracebackTable::getNumOfGPRsSaved
uint8_t getNumOfGPRsSaved() const
Definition: XCOFFObjectFile.cpp:1583
llvm::XCOFF::N_ABS
@ N_ABS
Definition: XCOFF.h:45
SubtargetFeature.h
llvm::object::XCOFFFileAuxEnt::NameInStrTblType::Offset
support::ubig32_t Offset
Definition: XCOFFObjectFile.h:400
llvm::object::XCOFFObjectFile::getSectionSize
uint64_t getSectionSize(DataRefImpl Sec) const override
Definition: XCOFFObjectFile.cpp:388
llvm::Triple::ArchType
ArchType
Definition: Triple.h:46
llvm::PPCISD::SC
@ SC
CHAIN = SC CHAIN, Imm128 - System call.
Definition: PPCISelLowering.h:420
llvm::ModRefInfo::Ref
@ Ref
The access may reference the value stored in memory.
ptrdiff_t
GETVALUEWITHMASK
#define GETVALUEWITHMASK(X)
Definition: XCOFFObjectFile.cpp:1346
llvm::object::XCOFFObjectFile::getStringTableEntry
Expected< StringRef > getStringTableEntry(uint32_t Offset) const
Definition: XCOFFObjectFile.cpp:222
llvm::object::BasicSymbolRef::getRawDataRefImpl
DataRefImpl getRawDataRefImpl() const
Definition: SymbolicFile.h:208
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::object::TBVectorExt::getNumberOfVectorParms
uint8_t getNumberOfVectorParms() const
Definition: XCOFFObjectFile.cpp:1386
llvm::object::XCOFFObjectFile::getAdvancedSymbolEntryAddress
static uintptr_t getAdvancedSymbolEntryAddress(uintptr_t CurrentAddress, uint32_t Distance)
Definition: XCOFFObjectFile.cpp:121
llvm::object::XCOFFTracebackTable::isFixup
bool isFixup() const
Definition: XCOFFObjectFile.cpp:1567
llvm::errorCodeToError
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Definition: Error.cpp:92
SI
@ SI
Definition: SIInstrInfo.cpp:7966
llvm::SubtargetFeatures
Manages the enabling and disabling of subtarget specific features.
Definition: SubtargetFeature.h:180
XCOFFObjectFile.h
llvm::object::viewAs
static const T * viewAs(uintptr_t in)
Definition: XCOFFObjectFile.cpp:46
llvm::dwarf::Index
Index
Definition: Dwarf.h:490
llvm::createError
static Error createError(const Twine &Err)
Definition: APFloat.cpp:261
llvm::object::XCOFFSectionHeader64::SectionSize
support::ubig64_t SectionSize
Definition: XCOFFObjectFile.h:188
llvm::Triple::ppc64
@ ppc64
Definition: Triple.h:71
llvm::XCOFF::SymbolTableEntrySize
constexpr size_t SymbolTableEntrySize
Definition: XCOFF.h:37
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:145
llvm::ErrorAsOutParameter
Helper for Errors used as out-parameters.
Definition: Error.h:1096
llvm::XCOFF::VISIBILITY_MASK
constexpr uint16_t VISIBILITY_MASK
Definition: XCOFF.h:246
llvm::object::object_error::parse_failed
@ parse_failed
llvm::StringRef::data
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:131
llvm::object::XCOFFTracebackTable::isGlobalLinkage
bool isGlobalLinkage() const
Definition: XCOFFObjectFile.cpp:1506
llvm::object::DataRefImpl::p
uintptr_t p
Definition: SymbolicFile.h:41
llvm::object::LoaderSectionSymbolEntry32::NameOffsetInStrTbl::IsNameInStrTbl
support::big32_t IsNameInStrTbl
Definition: XCOFFObjectFile.h:230
llvm::object::XCOFFObjectFile::getSectionFlags
int32_t getSectionFlags(DataRefImpl Sec) const
Definition: XCOFFObjectFile.cpp:955
Info
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
llvm::XCOFF::XTY_SD
@ XTY_SD
Csect definition for initialized storage.
Definition: XCOFF.h:229
llvm::XCOFF::N_DEBUG
@ N_DEBUG
Definition: XCOFF.h:45
llvm::object::XCOFFObjectFile::relocations
Expected< ArrayRef< Reloc > > relocations(const Shdr &Sec) const
Definition: XCOFFObjectFile.cpp:1001
llvm::object::XCOFFRelocation::Type
XCOFF::RelocationType Type
Definition: XCOFFObjectFile.h:492
llvm::object::LoaderSectionHeader32
Definition: XCOFFObjectFile.h:198
llvm::object::XCOFFCsectAuxRef::isLabel
bool isLabel() const
Definition: XCOFFObjectFile.h:369
llvm::SmallString< 32 >
llvm::XCOFF::C_EXT
@ C_EXT
Definition: XCOFF.h:185
llvm::object::XCOFFTracebackTable::isLRSaved
bool isLRSaved() const
Definition: XCOFFObjectFile.cpp:1559
llvm::MachO::FileType
FileType
Defines the file type this file represents.
Definition: InterfaceFile.h:53
llvm::object::XCOFFObjectFile::checkSymbolEntryPointer
void checkSymbolEntryPointer(uintptr_t SymbolEntPtr) const
Definition: XCOFFObjectFile.cpp:884
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:1555
llvm::object::XCOFFCsectAuxRef::getStorageMappingClass
XCOFF::StorageMappingClass getStorageMappingClass() const
Definition: XCOFFObjectFile.h:351
llvm::object::XCOFFSymbolEntry32::NameInStrTblType::Offset
support::ubig32_t Offset
Definition: XCOFFObjectFile.h:717
llvm::XCOFF::STYP_TDATA
@ STYP_TDATA
Definition: XCOFF.h:129
llvm::XCOFF::StorageClass
StorageClass
Definition: XCOFF.h:157
llvm::SmallString::c_str
const char * c_str()
Definition: SmallString.h:263
llvm::object::TBVectorExt::create
static Expected< TBVectorExt > create(StringRef TBvectorStrRef)
Definition: XCOFFObjectFile.cpp:1350
llvm::object::LoaderSectionHeader64
Definition: XCOFFObjectFile.h:213
object
bar al al movzbl eax ret Missed when stored in a memory object
Definition: README.txt:1411
llvm::XCOFF::STYP_INFO
@ STYP_INFO
Definition: XCOFF.h:128
llvm::XCOFF::SYM_V_EXPORTED
@ SYM_V_EXPORTED
Definition: XCOFF.h:243
llvm::Twine::utohexstr
static Twine utohexstr(const uint64_t &Val)
Definition: Twine.h:404
llvm::object::XCOFFSymbolEntry64::Offset
support::ubig32_t Offset
Definition: XCOFFObjectFile.h:739
llvm::object::XCOFFTracebackTable::getNumberOfFPParms
uint8_t getNumberOfFPParms() const
Definition: XCOFFObjectFile.cpp:1592
llvm::object::XCOFFSymbolRef::NAME_IN_STR_TBL_MAGIC
@ NAME_IN_STR_TBL_MAGIC
Definition: XCOFFObjectFile.h:753
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:83
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:113
getSymbolType
static std::unique_ptr< PDBSymbol > getSymbolType(const PDBSymbol &Symbol)
Definition: UDTLayout.cpp:36
llvm::object::LoaderSectionSymbolEntry32::NameOffsetInStrTbl
Definition: XCOFFObjectFile.h:229
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:134
llvm::XCOFF::XTY_CM
@ XTY_CM
Common csect definition. For uninitialized storage.
Definition: XCOFF.h:232
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:79
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
llvm::Twine::toVector
void toVector(SmallVectorImpl< char > &Out) const
Append the concatenated string into the given SmallString or SmallVector.
Definition: Twine.cpp:32
llvm::COFF::SectionSize
@ SectionSize
Definition: COFF.h:60
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::object::XCOFFObjectFile::getNumberOfRelocationEntries
Expected< uint32_t > getNumberOfRelocationEntries(const XCOFFSectionHeader< T > &Sec) const
Definition: XCOFFObjectFile.cpp:983
llvm::object::XCOFFTracebackTable::hasTraceBackTableOffset
bool hasTraceBackTableOffset() const
Definition: XCOFFObjectFile.cpp:1514
llvm::XCOFF::C_HIDEXT
@ C_HIDEXT
Definition: XCOFF.h:193
llvm::object::TBVectorExt
Definition: XCOFFObjectFile.h:817
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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:69
llvm::object::XCOFFSymbolRef::getSectionNumber
int16_t getSectionNumber() const
Definition: XCOFFObjectFile.h:779
Ptr
@ Ptr
Definition: TargetLibraryInfo.cpp:60
llvm::object::ObjectFile::base
const uint8_t * base() const
Definition: ObjectFile.h:234
llvm::object::XCOFFStringTable
Definition: XCOFFObjectFile.h:288
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:1215
getType
static M68kRelType getType(unsigned Kind, MCSymbolRefExpr::VariantKind &Modifier, bool &IsPCRel)
Definition: M68kELFObjectWriter.cpp:48
llvm::XCOFF::parseParmsType
Expected< SmallString< 32 > > parseParmsType(uint32_t Value, unsigned FixedParmsNum, unsigned FloatingParmsNum)
Definition: XCOFF.cpp:110
llvm::ArrayRef< uint8_t >
llvm::object::XCOFFObjectFile::getExceptionEntries
Expected< ArrayRef< ExceptEnt > > getExceptionEntries() const
Definition: XCOFFObjectFile.cpp:1028
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:50
llvm::object::XCOFFSymbolRef::getStorageClass
XCOFF::StorageClass getStorageClass() const
Definition: XCOFFObjectFile.h:795
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:1397
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::object::XCOFFTracebackTable::hasControlledStorage
bool hasControlledStorage() const
Definition: XCOFFObjectFile.cpp:1522
llvm::Expected::get
reference get()
Returns a reference to the stored T value.
Definition: Error.h:566
llvm::XCOFF::C_WEAKEXT
@ C_WEAKEXT
Definition: XCOFF.h:186
llvm::object::XCOFFRelocation::SymbolIndex
support::ubig32_t SymbolIndex
Definition: XCOFFObjectFile.h:487
uint32_t
llvm::object::getLoaderSecSymNameInStrTbl
Expected< StringRef > getLoaderSecSymNameInStrTbl(const T *LoaderSecHeader, uint64_t Offset)
Definition: XCOFFObjectFile.cpp:93
llvm::object::XCOFFObjectFile::sections32
ArrayRef< XCOFFSectionHeader32 > sections32() const
Definition: XCOFFObjectFile.cpp:971
llvm::XCOFF::SectionTypeFlags
SectionTypeFlags
Definition: XCOFF.h:121
llvm::object::XCOFFAuxiliaryHeader32
Definition: XCOFFObjectFile.h:72
llvm::object::DataRefImpl
Definition: SymbolicFile.h:35
llvm::object::LoaderSectionHeader32::OffsetToImpid
support::big32_t OffsetToImpid
Definition: XCOFFObjectFile.h:204
llvm::XCOFF::SymbolAuxType
SymbolAuxType
Definition: XCOFF.h:328
llvm::object::XCOFFFileAuxEnt::NameInStrTbl
NameInStrTblType NameInStrTbl
Definition: XCOFFObjectFile.h:405
llvm::object::TBVectorExt::getNumberOfVRSaved
uint8_t getNumberOfVRSaved() const
Definition: XCOFFObjectFile.cpp:1374
llvm::object::XCOFFObjectFile::getSymbolAuxType
const XCOFF::SymbolAuxType * getSymbolAuxType(uintptr_t AuxEntryAddress) const
Definition: XCOFFObjectFile.cpp:127
llvm::XCOFF::SYM_V_HIDDEN
@ SYM_V_HIDDEN
Definition: XCOFF.h:241
llvm::XCOFF::N_UNDEF
@ N_UNDEF
Definition: XCOFF.h:45
llvm::object::XCOFFObjectFile::sections64
ArrayRef< XCOFFSectionHeader64 > sections64() const
Definition: XCOFFObjectFile.cpp:964
llvm::object::SymbolAuxTypeOffset
static const size_t SymbolAuxTypeOffset
Definition: XCOFFObjectFile.cpp:28
GETBITWITHMASK
#define GETBITWITHMASK(P, X)
Definition: XCOFFObjectFile.cpp:1492
llvm::object::XCOFFObjectFile::getNumberOfSections
uint16_t getNumberOfSections() const
Definition: XCOFFObjectFile.cpp:834
llvm::object::XCOFFTracebackTable::isAllocaUsed
bool isAllocaUsed() const
Definition: XCOFFObjectFile.cpp:1546
llvm::AMDGPU::HSAMD::Kernel::Key::SymbolName
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
Definition: AMDGPUMetadata.h:386
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
llvm::createStringError
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition: Error.h:1238
llvm::object::Binary::ID_XCOFF64
@ ID_XCOFF64
Definition: Binary.h:60
llvm::object::XCOFFSectionHeader32::SectionSize
support::ubig32_t SectionSize
Definition: XCOFFObjectFile.h:175
uint16_t
getFlags
static uint32_t getFlags(const Symbol *Sym)
Definition: TapiFile.cpp:27
llvm::toString
const char * toString(DWARFSectionKind Kind)
Definition: DWARFUnitIndex.h:67
llvm::XCOFF::STYP_DEBUG
@ STYP_DEBUG
Definition: XCOFF.h:132
llvm::object::XCOFFTracebackTable::getNumberOfFixedParms
uint8_t getNumberOfFixedParms() const
Definition: XCOFFObjectFile.cpp:1587
llvm::object::XCOFFTracebackTable::hasExtensionTable
bool hasExtensionTable() const
Definition: XCOFFObjectFile.cpp:1575
llvm::SectionName
Definition: DWARFSection.h:21
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
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:1518
DataExtractor.h
llvm::object::XCOFFTracebackTable::getNumOfFPRsSaved
uint8_t getNumOfFPRsSaved() const
Definition: XCOFFObjectFile.cpp:1571
llvm::XCOFF::AUX_CSECT
@ AUX_CSECT
Identifies a csect auxiliary entry.
Definition: XCOFF.h:333
ECASE
#define ECASE(Value, String)
StringSwitch.h
isDebugSection
static bool isDebugSection(const SectionBase &Sec)
Definition: ELFObjcopy.cpp:54
llvm::object::XCOFFRelocation32
Definition: XCOFFObjectFile.h:505
llvm::XCOFF::getRelocationTypeString
StringRef getRelocationTypeString(XCOFF::RelocationType Type)
Definition: XCOFF.cpp:53
llvm::object::XCOFFSectionHeader64::VirtualAddress
support::ubig64_t VirtualAddress
Definition: XCOFFObjectFile.h:187
llvm::object::TBVectorExt::isVRSavedOnStack
bool isVRSavedOnStack() const
Definition: XCOFFObjectFile.cpp:1378
llvm::makeArrayRef
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:475
getFeatures
static FeatureBitset getFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS, ArrayRef< SubtargetSubTypeKV > ProcDesc, ArrayRef< SubtargetFeatureKV > ProcFeatures)
Definition: MCSubtargetInfo.cpp:151
llvm::object::LoaderSectionSymbolEntry32::NameOffsetInStrTbl::Offset
support::ubig32_t Offset
Definition: XCOFFObjectFile.h:231
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:596
llvm::object::XCOFFSectionHeader64
Definition: XCOFFObjectFile.h:184
llvm::object::XCOFFSymbolEntry32::SymbolName
char SymbolName[XCOFF::NameSize]
Definition: XCOFFObjectFile.h:721
llvm::DataExtractor
Definition: DataExtractor.h:41
llvm::object::XCOFFTracebackTable::getOnConditionDirective
uint8_t getOnConditionDirective() const
Definition: XCOFFObjectFile.cpp:1550
llvm::XCOFF::STYP_DATA
@ STYP_DATA
Definition: XCOFF.h:125
getSymbolSectionID
static unsigned getSymbolSectionID(const ObjectFile &O, SymbolRef Sym)
Definition: SymbolSize.cpp:39
GETVALUEWITHMASKSHIFT
#define GETVALUEWITHMASKSHIFT(X, S)
Definition: XCOFFObjectFile.cpp:1347
llvm::COFF::isReservedSectionNumber
bool isReservedSectionNumber(int32_t SectionNumber)
Definition: COFF.h:792
llvm::XCOFF::STYP_TEXT
@ STYP_TEXT
Definition: XCOFF.h:124
llvm::object::XCOFFTracebackTable::isFloatingPointOperationLogOrAbortEnabled
bool isFloatingPointOperationLogOrAbortEnabled() const
Definition: XCOFFObjectFile.cpp:1534
llvm::object::XCOFFSymbolRef::isCsectSymbol
bool isCsectSymbol() const
Definition: XCOFFObjectFile.cpp:1258
llvm::object::XCOFFObjectFile
Definition: XCOFFObjectFile.h:510
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:164
llvm::object::XCOFFTracebackTable
This class provides methods to extract traceback table data from a buffer.
Definition: XCOFFObjectFile.h:836
llvm::object::Binary::checkOffset
static Error checkOffset(MemoryBufferRef M, uintptr_t Addr, const uint64_t Size)
Definition: Binary.h:170
llvm::SmallVectorImpl< char >
llvm::object::XCOFFSymbolRef::getSymbolType
uint16_t getSymbolType() const
Definition: XCOFFObjectFile.h:781
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::Default
R Default(T Value)
Definition: StringSwitch.h:182
llvm::object::createError
Error createError(const Twine &Err)
Definition: Error.h:84
llvm::StringSwitch
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:44
llvm::object::XCOFFSymbolRef::getEntryAddress
uintptr_t getEntryAddress() const
Definition: XCOFFObjectFile.h:801
llvm::XCOFF::RelocationSerializationSize32
constexpr size_t RelocationSerializationSize32
Definition: XCOFF.h:38
llvm::XCOFF::STYP_TBSS
@ STYP_TBSS
Definition: XCOFF.h:130
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:3135
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition: SmallVector.h:667
llvm::object::XCOFFSymbolEntry32::NameInStrTbl
NameInStrTblType NameInStrTbl
Definition: XCOFFObjectFile.h:722
llvm::StringRef::begin
iterator begin() const
Definition: StringRef.h:111
llvm::object::XCOFFFileAuxEnt
Definition: XCOFFObjectFile.h:397
llvm::object::Binary::ID_XCOFF32
@ ID_XCOFF32
Definition: Binary.h:59
llvm::XCOFF::RelocOverflow
constexpr uint16_t RelocOverflow
Definition: XCOFF.h:42
llvm::object::basic_symbol_iterator
content_iterator< BasicSymbolRef > basic_symbol_iterator
Definition: SymbolicFile.h:143
llvm::object::XCOFFRelocation
Definition: XCOFFObjectFile.h:470
llvm::object::doesXCOFFTracebackTableBegin
bool doesXCOFFTracebackTableBegin(ArrayRef< uint8_t > Bytes)
Definition: XCOFFObjectFile.cpp:1339
llvm::sampleprof::Base
@ Base
Definition: Discriminator.h:58
llvm::object::XCOFFTracebackTable::hasVectorInfo
bool hasVectorInfo() const
Definition: XCOFFObjectFile.cpp:1579
Shdr
Elf_Shdr Shdr
Definition: ELFObjHandler.cpp:78
llvm::object::LoaderSectionHeader32::LengthOfImpidStrTbl
support::ubig32_t LengthOfImpidStrTbl
Definition: XCOFFObjectFile.h:202
llvm::object::XCOFFSymbolEntry32::NameInStrTblType::Magic
support::big32_t Magic
Definition: XCOFFObjectFile.h:716
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:1502