LLVM  15.0.0git
MachOReader.cpp
Go to the documentation of this file.
1 //===- MachOReader.cpp ------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "MachOReader.h"
10 #include "MachOObject.h"
12 #include "llvm/Object/MachO.h"
13 #include "llvm/Support/Errc.h"
14 #include <memory>
15 
16 using namespace llvm;
17 using namespace llvm::objcopy;
18 using namespace llvm::objcopy::macho;
19 
20 void MachOReader::readHeader(Object &O) const {
21  O.Header.Magic = MachOObj.getHeader().magic;
22  O.Header.CPUType = MachOObj.getHeader().cputype;
23  O.Header.CPUSubType = MachOObj.getHeader().cpusubtype;
24  O.Header.FileType = MachOObj.getHeader().filetype;
25  O.Header.NCmds = MachOObj.getHeader().ncmds;
26  O.Header.SizeOfCmds = MachOObj.getHeader().sizeofcmds;
27  O.Header.Flags = MachOObj.getHeader().flags;
28 }
29 
30 template <typename SectionType>
32  StringRef SegName(Sec.segname, strnlen(Sec.segname, sizeof(Sec.segname)));
33  StringRef SectName(Sec.sectname, strnlen(Sec.sectname, sizeof(Sec.sectname)));
34  Section S(SegName, SectName);
35  S.Index = Index;
36  S.Addr = Sec.addr;
37  S.Size = Sec.size;
38  S.OriginalOffset = Sec.offset;
39  S.Align = Sec.align;
40  S.RelOff = Sec.reloff;
41  S.NReloc = Sec.nreloc;
42  S.Flags = Sec.flags;
43  S.Reserved1 = Sec.reserved1;
44  S.Reserved2 = Sec.reserved2;
45  S.Reserved3 = 0;
46  return S;
47 }
48 
50  return constructSectionCommon(Sec, Index);
51 }
52 
55  S.Reserved3 = Sec.reserved3;
56  return S;
57 }
58 
59 template <typename SectionType, typename SegmentType>
62  const object::MachOObjectFile &MachOObj, uint32_t &NextSectionIndex) {
63  std::vector<std::unique_ptr<Section>> Sections;
64  for (auto Curr = reinterpret_cast<const SectionType *>(LoadCmd.Ptr +
65  sizeof(SegmentType)),
66  End = reinterpret_cast<const SectionType *>(LoadCmd.Ptr +
67  LoadCmd.C.cmdsize);
68  Curr < End; ++Curr) {
69  SectionType Sec;
70  memcpy((void *)&Sec, Curr, sizeof(SectionType));
71 
72  if (MachOObj.isLittleEndian() != sys::IsLittleEndianHost)
73  MachO::swapStruct(Sec);
74 
75  Sections.push_back(
76  std::make_unique<Section>(constructSection(Sec, NextSectionIndex)));
77 
78  Section &S = *Sections.back();
79 
81  MachOObj.getSection(NextSectionIndex++);
82  if (!SecRef)
83  return SecRef.takeError();
84 
86  MachOObj.getSectionContents(SecRef->getRawDataRefImpl());
87  if (!Data)
88  return Data.takeError();
89 
90  S.Content =
91  StringRef(reinterpret_cast<const char *>(Data->data()), Data->size());
92 
93  const uint32_t CPUType = MachOObj.getHeader().cputype;
94  S.Relocations.reserve(S.NReloc);
95  for (auto RI = MachOObj.section_rel_begin(SecRef->getRawDataRefImpl()),
96  RE = MachOObj.section_rel_end(SecRef->getRawDataRefImpl());
97  RI != RE; ++RI) {
99  R.Symbol = nullptr; // We'll fill this field later.
100  R.Info = MachOObj.getRelocation(RI->getRawDataRefImpl());
101  R.Scattered = MachOObj.isRelocationScattered(R.Info);
102  unsigned Type = MachOObj.getAnyRelocationType(R.Info);
103  // TODO Support CPU_TYPE_ARM.
104  R.IsAddend = !R.Scattered && (CPUType == MachO::CPU_TYPE_ARM64 &&
106  R.Extern = !R.Scattered && MachOObj.getPlainRelocationExternal(R.Info);
107  S.Relocations.push_back(R);
108  }
109 
110  assert(S.NReloc == S.Relocations.size() &&
111  "Incorrect number of relocations");
112  }
113  return std::move(Sections);
114 }
115 
116 Error MachOReader::readLoadCommands(Object &O) const {
117  // For MachO sections indices start from 1.
118  uint32_t NextSectionIndex = 1;
119  static constexpr char TextSegmentName[] = "__TEXT";
120  for (auto LoadCmd : MachOObj.load_commands()) {
121  LoadCommand LC;
122  switch (LoadCmd.C.cmd) {
123  case MachO::LC_CODE_SIGNATURE:
124  O.CodeSignatureCommandIndex = O.LoadCommands.size();
125  break;
126  case MachO::LC_SEGMENT:
127  // LoadCmd.Ptr might not be aligned temporarily as
128  // MachO::segment_command requires, but the segname char pointer do not
129  // have alignment restrictions.
130  if (StringRef(reinterpret_cast<const char *>(
131  LoadCmd.Ptr + offsetof(MachO::segment_command, segname))) ==
132  TextSegmentName)
133  O.TextSegmentCommandIndex = O.LoadCommands.size();
134 
135  if (Expected<std::vector<std::unique_ptr<Section>>> Sections =
136  extractSections<MachO::section, MachO::segment_command>(
137  LoadCmd, MachOObj, NextSectionIndex))
138  LC.Sections = std::move(*Sections);
139  else
140  return Sections.takeError();
141  break;
142  case MachO::LC_SEGMENT_64:
143  // LoadCmd.Ptr might not be aligned temporarily as
144  // MachO::segment_command_64 requires, but the segname char pointer do
145  // not have alignment restrictions.
146  if (StringRef(reinterpret_cast<const char *>(
147  LoadCmd.Ptr + offsetof(MachO::segment_command_64, segname))) ==
148  TextSegmentName)
149  O.TextSegmentCommandIndex = O.LoadCommands.size();
150 
151  if (Expected<std::vector<std::unique_ptr<Section>>> Sections =
152  extractSections<MachO::section_64, MachO::segment_command_64>(
153  LoadCmd, MachOObj, NextSectionIndex))
154  LC.Sections = std::move(*Sections);
155  else
156  return Sections.takeError();
157  break;
158  case MachO::LC_SYMTAB:
159  O.SymTabCommandIndex = O.LoadCommands.size();
160  break;
161  case MachO::LC_DYSYMTAB:
162  O.DySymTabCommandIndex = O.LoadCommands.size();
163  break;
164  case MachO::LC_DYLD_INFO:
165  case MachO::LC_DYLD_INFO_ONLY:
166  O.DyLdInfoCommandIndex = O.LoadCommands.size();
167  break;
168  case MachO::LC_DATA_IN_CODE:
169  O.DataInCodeCommandIndex = O.LoadCommands.size();
170  break;
171  case MachO::LC_LINKER_OPTIMIZATION_HINT:
172  O.LinkerOptimizationHintCommandIndex = O.LoadCommands.size();
173  break;
174  case MachO::LC_FUNCTION_STARTS:
175  O.FunctionStartsCommandIndex = O.LoadCommands.size();
176  break;
177  case MachO::LC_DYLD_EXPORTS_TRIE:
178  O.ExportsTrieCommandIndex = O.LoadCommands.size();
179  break;
180  case MachO::LC_DYLD_CHAINED_FIXUPS:
181  O.ChainedFixupsCommandIndex = O.LoadCommands.size();
182  break;
183  }
184 #define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \
185  case MachO::LCName: \
186  memcpy((void *)&(LC.MachOLoadCommand.LCStruct##_data), LoadCmd.Ptr, \
187  sizeof(MachO::LCStruct)); \
188  if (MachOObj.isLittleEndian() != sys::IsLittleEndianHost) \
189  MachO::swapStruct(LC.MachOLoadCommand.LCStruct##_data); \
190  if (LoadCmd.C.cmdsize > sizeof(MachO::LCStruct)) \
191  LC.Payload = ArrayRef<uint8_t>( \
192  reinterpret_cast<uint8_t *>(const_cast<char *>(LoadCmd.Ptr)) + \
193  sizeof(MachO::LCStruct), \
194  LoadCmd.C.cmdsize - sizeof(MachO::LCStruct)); \
195  break;
196 
197  switch (LoadCmd.C.cmd) {
198  default:
199  memcpy((void *)&(LC.MachOLoadCommand.load_command_data), LoadCmd.Ptr,
200  sizeof(MachO::load_command));
201  if (MachOObj.isLittleEndian() != sys::IsLittleEndianHost)
202  MachO::swapStruct(LC.MachOLoadCommand.load_command_data);
203  if (LoadCmd.C.cmdsize > sizeof(MachO::load_command))
205  reinterpret_cast<uint8_t *>(const_cast<char *>(LoadCmd.Ptr)) +
206  sizeof(MachO::load_command),
207  LoadCmd.C.cmdsize - sizeof(MachO::load_command));
208  break;
209 #include "llvm/BinaryFormat/MachO.def"
210  }
211  O.LoadCommands.push_back(std::move(LC));
212  }
213  return Error::success();
214 }
215 
216 template <typename nlist_t>
217 SymbolEntry constructSymbolEntry(StringRef StrTable, const nlist_t &nlist) {
218  assert(nlist.n_strx < StrTable.size() &&
219  "n_strx exceeds the size of the string table");
220  SymbolEntry SE;
221  SE.Name = StringRef(StrTable.data() + nlist.n_strx).str();
222  SE.n_type = nlist.n_type;
223  SE.n_sect = nlist.n_sect;
224  SE.n_desc = nlist.n_desc;
225  SE.n_value = nlist.n_value;
226  return SE;
227 }
228 
229 void MachOReader::readSymbolTable(Object &O) const {
230  StringRef StrTable = MachOObj.getStringTableData();
231  for (auto Symbol : MachOObj.symbols()) {
232  SymbolEntry SE =
233  (MachOObj.is64Bit()
234  ? constructSymbolEntry(StrTable, MachOObj.getSymbol64TableEntry(
235  Symbol.getRawDataRefImpl()))
236  : constructSymbolEntry(StrTable, MachOObj.getSymbolTableEntry(
237  Symbol.getRawDataRefImpl())));
238 
239  O.SymTable.Symbols.push_back(std::make_unique<SymbolEntry>(SE));
240  }
241 }
242 
243 void MachOReader::setSymbolInRelocationInfo(Object &O) const {
244  std::vector<const Section *> Sections;
245  for (auto &LC : O.LoadCommands)
246  for (std::unique_ptr<Section> &Sec : LC.Sections)
247  Sections.push_back(Sec.get());
248 
249  for (LoadCommand &LC : O.LoadCommands)
250  for (std::unique_ptr<Section> &Sec : LC.Sections)
251  for (auto &Reloc : Sec->Relocations)
252  if (!Reloc.Scattered && !Reloc.IsAddend) {
253  const uint32_t SymbolNum =
254  Reloc.getPlainRelocationSymbolNum(MachOObj.isLittleEndian());
255  if (Reloc.Extern) {
256  Reloc.Symbol = O.SymTable.getSymbolByIndex(SymbolNum);
257  } else {
258  // FIXME: Refactor error handling in MachOReader and report an error
259  // if we encounter an invalid relocation.
260  assert(SymbolNum >= 1 && SymbolNum <= Sections.size() &&
261  "Invalid section index.");
262  Reloc.Sec = Sections[SymbolNum - 1];
263  }
264  }
265 }
266 
267 void MachOReader::readRebaseInfo(Object &O) const {
268  O.Rebases.Opcodes = MachOObj.getDyldInfoRebaseOpcodes();
269 }
270 
271 void MachOReader::readBindInfo(Object &O) const {
272  O.Binds.Opcodes = MachOObj.getDyldInfoBindOpcodes();
273 }
274 
275 void MachOReader::readWeakBindInfo(Object &O) const {
276  O.WeakBinds.Opcodes = MachOObj.getDyldInfoWeakBindOpcodes();
277 }
278 
279 void MachOReader::readLazyBindInfo(Object &O) const {
280  O.LazyBinds.Opcodes = MachOObj.getDyldInfoLazyBindOpcodes();
281 }
282 
283 void MachOReader::readExportInfo(Object &O) const {
284  O.Exports.Trie = MachOObj.getDyldInfoExportsTrie();
285 }
286 
287 void MachOReader::readLinkData(Object &O, Optional<size_t> LCIndex,
288  LinkData &LD) const {
289  if (!LCIndex)
290  return;
291  const MachO::linkedit_data_command &LC =
292  O.LoadCommands[*LCIndex].MachOLoadCommand.linkedit_data_command_data;
293  LD.Data =
294  arrayRefFromStringRef(MachOObj.getData().substr(LC.dataoff, LC.datasize));
295 }
296 
297 void MachOReader::readDataInCodeData(Object &O) const {
298  return readLinkData(O, O.DataInCodeCommandIndex, O.DataInCode);
299 }
300 
301 void MachOReader::readLinkerOptimizationHint(Object &O) const {
302  return readLinkData(O, O.LinkerOptimizationHintCommandIndex,
303  O.LinkerOptimizationHint);
304 }
305 
306 void MachOReader::readFunctionStartsData(Object &O) const {
307  return readLinkData(O, O.FunctionStartsCommandIndex, O.FunctionStarts);
308 }
309 
310 void MachOReader::readExportsTrie(Object &O) const {
311  return readLinkData(O, O.ExportsTrieCommandIndex, O.ExportsTrie);
312 }
313 
314 void MachOReader::readChainedFixups(Object &O) const {
315  return readLinkData(O, O.ChainedFixupsCommandIndex, O.ChainedFixups);
316 }
317 
318 void MachOReader::readIndirectSymbolTable(Object &O) const {
319  MachO::dysymtab_command DySymTab = MachOObj.getDysymtabLoadCommand();
320  constexpr uint32_t AbsOrLocalMask =
322  for (uint32_t i = 0; i < DySymTab.nindirectsyms; ++i) {
323  uint32_t Index = MachOObj.getIndirectSymbolTableEntry(DySymTab, i);
324  if ((Index & AbsOrLocalMask) != 0)
325  O.IndirectSymTable.Symbols.emplace_back(Index, None);
326  else
327  O.IndirectSymTable.Symbols.emplace_back(
328  Index, O.SymTable.getSymbolByIndex(Index));
329  }
330 }
331 
332 void MachOReader::readSwiftVersion(Object &O) const {
333  struct ObjCImageInfo {
335  uint32_t Flags;
336  } ImageInfo;
337 
338  for (const LoadCommand &LC : O.LoadCommands)
339  for (const std::unique_ptr<Section> &Sec : LC.Sections)
340  if (Sec->Sectname == "__objc_imageinfo" &&
341  (Sec->Segname == "__DATA" || Sec->Segname == "__DATA_CONST" ||
342  Sec->Segname == "__DATA_DIRTY") &&
343  Sec->Content.size() >= sizeof(ObjCImageInfo)) {
344  memcpy(&ImageInfo, Sec->Content.data(), sizeof(ObjCImageInfo));
345  if (MachOObj.isLittleEndian() != sys::IsLittleEndianHost) {
346  sys::swapByteOrder(ImageInfo.Version);
347  sys::swapByteOrder(ImageInfo.Flags);
348  }
349  O.SwiftVersion = (ImageInfo.Flags >> 8) & 0xff;
350  return;
351  }
352 }
353 
355  auto Obj = std::make_unique<Object>();
356  readHeader(*Obj);
357  if (Error E = readLoadCommands(*Obj))
358  return std::move(E);
359  readSymbolTable(*Obj);
360  setSymbolInRelocationInfo(*Obj);
361  readRebaseInfo(*Obj);
362  readBindInfo(*Obj);
363  readWeakBindInfo(*Obj);
364  readLazyBindInfo(*Obj);
365  readExportInfo(*Obj);
366  readDataInCodeData(*Obj);
367  readLinkerOptimizationHint(*Obj);
368  readFunctionStartsData(*Obj);
369  readExportsTrie(*Obj);
370  readChainedFixups(*Obj);
371  readIndirectSymbolTable(*Obj);
372  readSwiftVersion(*Obj);
373  return std::move(Obj);
374 }
i
i
Definition: README.txt:29
llvm::object::MachOObjectFile::getPlainRelocationExternal
bool getPlainRelocationExternal(const MachO::any_relocation_info &RE) const
Definition: MachOObjectFile.cpp:4365
llvm::MachO::section
Definition: MachO.h:565
llvm::object::MachOObjectFile::getStringTableData
StringRef getStringTableData() const
Definition: MachOObjectFile.cpp:4871
llvm::MachO::mach_header::magic
uint32_t magic
Definition: MachO.h:512
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::sys::swapByteOrder
void swapByteOrder(T &Value)
Definition: SwapByteOrder.h:158
llvm::MachO::mach_header::ncmds
uint32_t ncmds
Definition: MachO.h:516
llvm::ARM_MB::LD
@ LD
Definition: ARMBaseInfo.h:72
llvm::object::Binary::isLittleEndian
bool isLittleEndian() const
Definition: Binary.h:152
offsetof
#define offsetof(TYPE, MEMBER)
Definition: AMDHSAKernelDescriptor.h:23
llvm::MachO::mach_header::cpusubtype
uint32_t cpusubtype
Definition: MachO.h:514
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:329
llvm::MachO::ARM64_RELOC_ADDEND
@ ARM64_RELOC_ADDEND
Definition: MachO.h:470
llvm::object::MachOObjectFile::LoadCommandInfo
Definition: MachO.h:383
Errc.h
llvm::objcopy::macho::RelocationInfo
Definition: MachOObject.h:176
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
constructSymbolEntry
SymbolEntry constructSymbolEntry(StringRef StrTable, const nlist_t &nlist)
Definition: MachOReader.cpp:217
llvm::MachO::CPUType
CPUType
Definition: MachO.h:1441
llvm::Optional< size_t >
llvm::MachO::dysymtab_command::nindirectsyms
uint32_t nindirectsyms
Definition: MachO.h:720
llvm::objcopy::macho
Definition: MachOObjcopy.h:26
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::objcopy::macho::SymbolEntry::n_type
uint8_t n_type
Definition: MachOObject.h:114
llvm::object::MachOObjectFile::getSection
Expected< SectionRef > getSection(unsigned SectionIndex) const
Definition: MachOObjectFile.cpp:2000
llvm::object::ObjectFile::symbols
symbol_iterator_range symbols() const
Definition: ObjectFile.h:319
MachO.h
llvm::object::MachOObjectFile::getIndirectSymbolTableEntry
uint32_t getIndirectSymbolTableEntry(const MachO::dysymtab_command &DLC, unsigned Index) const
Definition: MachOObjectFile.cpp:4625
llvm::object::MachOObjectFile::getSectionContents
ArrayRef< uint8_t > getSectionContents(uint32_t Offset, uint64_t Size) const
Definition: MachOObjectFile.cpp:1964
llvm::StringRef::substr
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:615
llvm::MachO::mach_header::flags
uint32_t flags
Definition: MachO.h:518
llvm::object::MachOObjectFile::getDysymtabLoadCommand
MachO::dysymtab_command getDysymtabLoadCommand() const
Definition: MachOObjectFile.cpp:4654
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::object::MachOObjectFile::LoadCommandInfo::C
MachO::load_command C
Definition: MachO.h:385
llvm::objcopy::macho::LoadCommand
Definition: MachOObject.h:84
llvm::objcopy::macho::LinkData
Definition: MachOObject.h:298
llvm::objcopy::macho::Object
Definition: MachOObject.h:302
llvm::object::MachOObjectFile::getDyldInfoLazyBindOpcodes
ArrayRef< uint8_t > getDyldInfoLazyBindOpcodes() const
Definition: MachOObjectFile.cpp:4754
llvm::object::MachOObjectFile::getRelocation
MachO::any_relocation_info getRelocation(DataRefImpl Rel) const
Definition: MachOObjectFile.cpp:4584
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
llvm::objcopy::macho::SymbolEntry::Name
std::string Name
Definition: MachOObject.h:111
llvm::MachO::linkedit_data_command
Definition: MachO.h:800
llvm::objcopy::macho::SymbolEntry::n_sect
uint8_t n_sect
Definition: MachOObject.h:115
llvm::MachO::INDIRECT_SYMBOL_ABS
@ INDIRECT_SYMBOL_ABS
Definition: MachO.h:217
llvm::IndexedInstrProf::Version
const uint64_t Version
Definition: InstrProf.h:1027
llvm::StringRef::str
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:249
llvm::objcopy::macho::SymbolEntry::n_desc
uint16_t n_desc
Definition: MachOObject.h:116
llvm::object::MachOObjectFile
Definition: MachO.h:381
constructSection
Section constructSection(const MachO::section &Sec, uint32_t Index)
Definition: MachOReader.cpp:49
llvm::object::MachOObjectFile::getDyldInfoWeakBindOpcodes
ArrayRef< uint8_t > getDyldInfoWeakBindOpcodes() const
Definition: MachOObjectFile.cpp:4740
llvm::objcopy::macho::LoadCommand::Sections
std::vector< std::unique_ptr< Section > > Sections
Definition: MachOObject.h:99
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:240
llvm::object::MachOObjectFile::is64Bit
bool is64Bit() const
Definition: MachOObjectFile.cpp:4876
llvm::MachO::linkedit_data_command::datasize
uint32_t datasize
Definition: MachO.h:804
llvm::object::MachOObjectFile::getSymbol64TableEntry
MachO::nlist_64 getSymbol64TableEntry(DataRefImpl DRI) const
Definition: MachOObjectFile.cpp:4458
llvm::object::MachOObjectFile::LoadCommandInfo::Ptr
const char * Ptr
Definition: MachO.h:384
llvm::objcopy::macho::MachOReader::create
Expected< std::unique_ptr< Object > > create() const override
Definition: MachOReader.cpp:354
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::objcopy::macho::LoadCommand::MachOLoadCommand
MachO::macho_load_command MachOLoadCommand
Definition: MachOObject.h:88
extractSections
static Expected< std::vector< std::unique_ptr< Section > > > extractSections(const object::MachOObjectFile::LoadCommandInfo &LoadCmd, const object::MachOObjectFile &MachOObj, uint32_t &NextSectionIndex)
Definition: MachOReader.cpp:60
llvm::MachO::CPU_TYPE_ARM64
@ CPU_TYPE_ARM64
Definition: MachO.h:1449
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
memcpy
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
llvm::MachO::segment_command
Definition: MachO.h:537
llvm::object::MachOObjectFile::getDyldInfoRebaseOpcodes
ArrayRef< uint8_t > getDyldInfoRebaseOpcodes() const
Definition: MachOObjectFile.cpp:4712
llvm::objcopy::macho::SymbolEntry
Definition: MachOObject.h:110
llvm::object::MachOObjectFile::getDyldInfoBindOpcodes
ArrayRef< uint8_t > getDyldInfoBindOpcodes() const
Definition: MachOObjectFile.cpp:4726
llvm::MachO::load_command
Definition: MachO.h:532
MachOReader.h
llvm::ArrayRef< uint8_t >
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::MachO::mach_header::sizeofcmds
uint32_t sizeofcmds
Definition: MachO.h:517
constructSectionCommon
static Section constructSectionCommon(const SectionType &Sec, uint32_t Index)
Definition: MachOReader.cpp:31
llvm::objcopy::macho::SymbolEntry::n_value
uint64_t n_value
Definition: MachOObject.h:117
uint32_t
llvm::MachO::segment_command_64
Definition: MachO.h:551
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::MachO::section_64::reserved3
uint32_t reserved3
Definition: MachO.h:591
llvm::objcopy::macho::LoadCommand::Payload
std::vector< uint8_t > Payload
Definition: MachOObject.h:93
llvm::object::MachOObjectFile::isRelocationScattered
bool isRelocationScattered(const MachO::any_relocation_info &RE) const
Definition: MachOObjectFile.cpp:4351
MachOObject.h
llvm::MachO::dysymtab_command
Definition: MachO.h:704
llvm::StringRef::size
constexpr LLVM_NODISCARD size_t size() const
size - Get the string size.
Definition: StringRef.h:157
llvm::object::MachOObjectFile::getAnyRelocationType
unsigned getAnyRelocationType(const MachO::any_relocation_info &RE) const
Definition: MachOObjectFile.cpp:4409
llvm::MachO::section_64
Definition: MachO.h:579
llvm::object::MachOObjectFile::load_commands
iterator_range< load_command_iterator > load_commands() const
Definition: MachOObjectFile.cpp:4324
llvm::MachO::load_command::cmdsize
uint32_t cmdsize
Definition: MachO.h:534
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::MachO::INDIRECT_SYMBOL_LOCAL
@ INDIRECT_SYMBOL_LOCAL
Definition: MachO.h:216
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition: ARMBuildAttributes.h:83
llvm::object::MachOObjectFile::getDyldInfoExportsTrie
ArrayRef< uint8_t > getDyldInfoExportsTrie() const
Definition: MachOObjectFile.cpp:4834
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:597
llvm::object::MachOObjectFile::section_rel_begin
relocation_iterator section_rel_begin(DataRefImpl Sec) const override
llvm::objcopy::macho::Section
Definition: MachOObject.h:39
llvm::sys::IsLittleEndianHost
static const bool IsLittleEndianHost
Definition: SwapByteOrder.h:101
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::MachO::mach_header::filetype
uint32_t filetype
Definition: MachO.h:515
llvm::object::Binary::getData
StringRef getData() const
Definition: Binary.cpp:39
MachO.h
llvm::object::MachOObjectFile::getHeader
const MachO::mach_header & getHeader() const
Definition: MachOObjectFile.cpp:4616
llvm::MachO::linkedit_data_command::dataoff
uint32_t dataoff
Definition: MachO.h:803
llvm::MachO::swapStruct
void swapStruct(fat_header &mh)
Definition: MachO.h:1028
llvm::objcopy
Definition: COFFConfig.h:15
llvm::MachO::mach_header::cputype
uint32_t cputype
Definition: MachO.h:513
llvm::object::MachOObjectFile::section_rel_end
relocation_iterator section_rel_end(DataRefImpl Sec) const override
llvm::MachO::SectionType
SectionType
These are the section type and attributes fields.
Definition: MachO.h:120