Lines Matching defs:MachO
20 #include "llvm/BinaryFormat/MachO.h"
31 #include "llvm/Object/MachO.h"
303 MachO::mach_header H;
304 MachO::mach_header_64 H_64;
305 uint32_t Filetype = MachO::MH_OBJECT;
312 MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj);
316 NType |= MachO::N_EXT;
318 NType |= MachO::N_PEXT;
320 NType |= MachO::N_EXT | MachO::N_UNDF;
325 NType |= MachO::N_SECT;
334 NDesc |= MachO::N_WEAK_DEF;
337 if (MachO->is64Bit()) {
338 H_64 = MachO->MachOObjectFile::getHeader64();
342 MachO::nlist_64 STE_64 = MachO->getSymbol64TableEntry(SymDRI);
356 H = MachO->MachOObjectFile::getHeader();
360 MachO::nlist STE = MachO->getSymbolTableEntry(SymDRI);
381 if ((NType & MachO::N_TYPE) == MachO::N_INDR) {
386 if (MachO->getIndirectName(S.Sym.getRawDataRefImpl(), IndirectName))
398 if ((NType & MachO::N_TYPE) == MachO::N_INDR)
400 if (Obj.isIR() && (NType & MachO::N_TYPE) == MachO::N_TYPE)
405 switch (NType & MachO::N_TYPE) {
406 case MachO::N_UNDF:
409 if (MachO::GET_COMM_ALIGN(NDesc) != 0)
410 outs() << "(alignment 2^" << (int)MachO::GET_COMM_ALIGN(NDesc) << ") ";
412 if ((NType & MachO::N_TYPE) == MachO::N_PBUD)
416 if ((NDesc & MachO::REFERENCE_TYPE) ==
417 MachO::REFERENCE_FLAG_UNDEFINED_LAZY)
419 else if ((NDesc & MachO::REFERENCE_TYPE) ==
420 MachO::REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY)
422 else if ((NDesc & MachO::REFERENCE_TYPE) ==
423 MachO::REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY)
429 case MachO::N_ABS:
432 case MachO::N_INDR:
435 case MachO::N_SECT: {
452 MachO->getSymbolSection(S.Sym.getRawDataRefImpl());
459 if (Sec == MachO->section_end()) {
468 if (Expected<StringRef> NameOrErr = MachO->getSectionName(Ref))
470 StringRef SegmentName = MachO->getSectionFinalSegmentName(Ref);
479 if (NType & MachO::N_EXT) {
480 if (NDesc & MachO::REFERENCED_DYNAMICALLY)
482 if (NType & MachO::N_PEXT) {
483 if ((NDesc & MachO::N_WEAK_DEF) == MachO::N_WEAK_DEF)
488 if ((NDesc & MachO::N_WEAK_REF) == MachO::N_WEAK_REF ||
489 (NDesc & MachO::N_WEAK_DEF) == MachO::N_WEAK_DEF) {
490 if ((NDesc & (MachO::N_WEAK_REF | MachO::N_WEAK_DEF)) ==
491 (MachO::N_WEAK_REF | MachO::N_WEAK_DEF))
499 if (NType & MachO::N_PEXT)
505 if (Filetype == MachO::MH_OBJECT) {
506 if (NDesc & MachO::N_NO_DEAD_STRIP)
508 if ((NType & MachO::N_TYPE) != MachO::N_UNDF &&
509 NDesc & MachO::N_SYMBOL_RESOLVER)
511 if ((NType & MachO::N_TYPE) != MachO::N_UNDF && NDesc & MachO::N_ALT_ENTRY)
513 if ((NType & MachO::N_TYPE) != MachO::N_UNDF && NDesc & MachO::N_COLD_FUNC)
517 if ((NDesc & MachO::N_ARM_THUMB_DEF) == MachO::N_ARM_THUMB_DEF)
520 if ((NType & MachO::N_TYPE) == MachO::N_INDR) {
523 if (MachO) {
525 if (MachO->getIndirectName(S.Sym.getRawDataRefImpl(), IndirectName))
536 if ((Flags & MachO::MH_TWOLEVEL) == MachO::MH_TWOLEVEL &&
537 (((NType & MachO::N_TYPE) == MachO::N_UNDF && NValue == 0) ||
538 (NType & MachO::N_TYPE) == MachO::N_PBUD)) {
539 uint32_t LibraryOrdinal = MachO::GET_LIBRARY_ORDINAL(NDesc);
541 if (LibraryOrdinal == MachO::EXECUTABLE_ORDINAL)
543 else if (LibraryOrdinal == MachO::DYNAMIC_LOOKUP_ORDINAL)
547 if (!MachO ||
548 MachO->getLibraryShortNameByIndex(LibraryOrdinal - 1, LibraryName))
563 {MachO::N_GSYM, "GSYM"}, {MachO::N_FNAME, "FNAME"},
564 {MachO::N_FUN, "FUN"}, {MachO::N_STSYM, "STSYM"},
565 {MachO::N_LCSYM, "LCSYM"}, {MachO::N_BNSYM, "BNSYM"},
566 {MachO::N_PC, "PC"}, {MachO::N_AST, "AST"},
567 {MachO::N_OPT, "OPT"}, {MachO::N_RSYM, "RSYM"},
568 {MachO::N_SLINE, "SLINE"}, {MachO::N_ENSYM, "ENSYM"},
569 {MachO::N_SSYM, "SSYM"}, {MachO::N_SO, "SO"},
570 {MachO::N_OSO, "OSO"}, {MachO::N_LIB, "LIB"},
571 {MachO::N_LSYM, "LSYM"}, {MachO::N_BINCL, "BINCL"},
572 {MachO::N_SOL, "SOL"}, {MachO::N_PARAMS, "PARAM"},
573 {MachO::N_VERSION, "VERS"}, {MachO::N_OLEVEL, "OLEV"},
574 {MachO::N_PSYM, "PSYM"}, {MachO::N_EINCL, "EINCL"},
575 {MachO::N_ENTRY, "ENTRY"}, {MachO::N_LBRAC, "LBRAC"},
576 {MachO::N_EXCL, "EXCL"}, {MachO::N_RBRAC, "RBRAC"},
577 {MachO::N_BCOMM, "BCOMM"}, {MachO::N_ECOMM, "ECOMM"},
578 {MachO::N_ECOML, "ECOML"}, {MachO::N_LENG, "LENG"},
590 static void darwinPrintStab(MachOObjectFile *MachO, const NMSymbol &S) {
591 MachO::nlist_64 STE_64;
592 MachO::nlist STE;
597 if (MachO->is64Bit()) {
598 STE_64 = MachO->getSymbol64TableEntry(SymDRI);
603 STE = MachO->getSymbolTableEntry(SymDRI);
784 MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj);
791 (UndefinedOnly && MachO && OutputFormat != darwin)) &&
815 else if (MachO && S.TypeChar == 'I')
828 if ((OutputFormat == darwin || FormatMachOasHex) && (MachO || Obj.isIR())) {
833 << (MachO ? "0" : SymbolSizeStr);
834 } else if (OutputFormat == bsd || (OutputFormat == darwin && !MachO)) {
840 if (S.TypeChar == '-' && MachO)
841 darwinPrintStab(MachO, S);
843 if (S.TypeChar == 'I' && MachO) {
847 if (MachO->getIndirectName(S.Sym.getRawDataRefImpl(), IndirectName))
1019 if (NType & MachO::N_STAB)
1022 switch (NType & MachO::N_TYPE) {
1023 case MachO::N_ABS:
1025 case MachO::N_INDR:
1027 case MachO::N_SECT: {
1041 if (Obj.is64Bit() && Obj.getHeader64().filetype == MachO::MH_KEXT_BUNDLE &&
1164 else if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj))
1165 Ret = getSymbolNMTypeChar(*MachO, I);
1212 MachO::nlist_64 STE = Obj.getSymbol64TableEntry(Symb);
1213 return (STE.n_type & MachO::N_TYPE) == MachO::N_SECT ? STE.n_sect : 0;
1215 MachO::nlist STE = Obj.getSymbolTableEntry(Symb);
1216 return (STE.n_type & MachO::N_TYPE) == MachO::N_SECT ? STE.n_sect : 0;
1219 static void dumpSymbolsFromDLInfoMachO(MachOObjectFile &MachO,
1233 MachO::mach_header H;
1234 MachO::mach_header_64 H_64;
1236 if (MachO.is64Bit()) {
1237 H_64 = MachO.MachOObjectFile::getHeader64();
1240 H = MachO.MachOObjectFile::getHeader();
1244 for (const auto &Command : MachO.load_commands()) {
1245 if (Command.C.cmd == MachO::LC_SEGMENT) {
1246 MachO::segment_command Seg = MachO.getSegmentLoadCommand(Command);
1251 } else if (Command.C.cmd == MachO::LC_SEGMENT_64) {
1252 MachO::segment_command_64 Seg = MachO.getSegment64LoadCommand(Command);
1260 HFlags & MachO::MH_NLIST_OUTOFSYNC_WITH_DYLDINFO) {
1263 for (const llvm::object::ExportEntry &Entry : MachO.exports(Err)) {
1291 bool Abs = ((EFlags & MachO::EXPORT_SYMBOL_FLAGS_KIND_MASK) ==
1292 MachO::EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE);
1293 bool Resolver = (EFlags & MachO::EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER);
1294 ReExport = (EFlags & MachO::EXPORT_SYMBOL_FLAGS_REEXPORT);
1295 bool WeakDef = (EFlags & MachO::EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION);
1297 S.NDesc |= MachO::N_WEAK_DEF;
1299 S.NType = MachO::N_EXT | MachO::N_ABS;
1302 S.NType = MachO::N_EXT | MachO::N_INDR;
1305 S.NType = MachO::N_EXT | MachO::N_SECT;
1308 if ((S.Address & 1) != 0 && !MachO.is64Bit() &&
1309 H.cputype == MachO::CPU_TYPE_ARM) {
1311 S.NDesc |= MachO::N_ARM_THUMB_DEF;
1318 for (const SectionRef &Section : MachO.sections()) {
1327 MachO.getSectionFinalSegmentName(Section.getRawDataRefImpl());
1335 S.NDesc |= MachO::REFERENCED_DYNAMICALLY;
1382 U.NType = MachO::N_EXT | MachO::N_UNDF;
1387 MachO::SET_LIBRARY_ORDINAL(U.NDesc, Entry.other());
1401 error(std::move(Err), MachO.getFileName());
1421 for (const llvm::object::MachOBindEntry &Entry : MachO.bindTable(BErr)) {
1442 B.NType = MachO::N_EXT | MachO::N_UNDF;
1445 MachO::SET_LIBRARY_ORDINAL(B.NDesc, Entry.ordinal());
1454 error(std::move(BErr), MachO.getFileName());
1475 MachO.lazyBindTable(LErr)) {
1500 L.NType = MachO::N_EXT | MachO::N_UNDF;
1504 L.NDesc = MachO::REFERENCE_FLAG_UNDEFINED_LAZY;
1505 MachO::SET_LIBRARY_ORDINAL(L.NDesc, Entry.ordinal());
1513 error(std::move(LErr), MachO.getFileName());
1535 MachO.weakBindTable(WErr)) {
1539 Entry.flags() & MachO::BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION) {
1561 W.NType = MachO::N_EXT | MachO::N_UNDF;
1566 W.NDesc = MachO::N_WEAK_DEF;
1577 SymbolList[J].NDesc |= MachO::N_WEAK_DEF;
1581 error(std::move(WErr), MachO.getFileName());
1601 for (const auto &Command : MachO.load_commands()) {
1602 if (Command.C.cmd == MachO::LC_FUNCTION_STARTS) {
1605 MachO::linkedit_data_command LLC =
1606 MachO.getLinkeditDataLoadCommand(Command);
1608 MachO.ReadULEB128s(LLC.dataoff, FoundFns);
1609 } else if (Command.C.cmd == MachO::LC_MAIN) {
1610 MachO::entry_point_command LCmain = MachO.getEntryPointCommand(Command);
1634 F.NType = MachO::N_SECT;
1638 for (const SectionRef &Section : MachO.sections()) {
1645 MachO.getSectionFinalSegmentName(Section.getRawDataRefImpl());
1811 MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj);
1812 if (!SegSect.empty() && MachO) {
1813 Nsect = getNsectForSegSect(MachO);
1819 if (!(MachO && DyldInfoOnly)) {
1845 if (Nsect && Nsect != getNsectInMachO(*MachO, Sym))
1874 if (MachO) {
1896 if (MachO && !NoDyldInfo)
1897 dumpSymbolsFromDLInfoMachO(*MachO, SymbolList);
1958 if (Command.C.cmd != MachO::LC_FILESET_ENTRY)
1961 MachO::fileset_entry_command Entry =
1998 // Are we handling a MachO of type MH_FILESET?
2001 MachO::MH_FILESET) {
2019 auto *MachO = dyn_cast<MachOObjectFile>(O);
2021 if (!MachO || ArchAll || ArchFlags.empty())
2024 MachO::mach_header H;
2025 MachO::mach_header_64 H_64;
2028 if (MachO->is64Bit()) {
2029 H_64 = MachO->MachOObjectFile::getHeader64();
2033 H = MachO->MachOObjectFile::getHeader();