Lines Matching defs:MachO
20 #include "llvm/BinaryFormat/MachO.h"
31 #include "llvm/Object/MachO.h"
305 MachO::mach_header H;
306 MachO::mach_header_64 H_64;
307 uint32_t Filetype = MachO::MH_OBJECT;
314 MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj);
318 NType |= MachO::N_EXT;
320 NType |= MachO::N_PEXT;
322 NType |= MachO::N_EXT | MachO::N_UNDF;
327 NType |= MachO::N_SECT;
336 NDesc |= MachO::N_WEAK_DEF;
339 if (MachO->is64Bit()) {
340 H_64 = MachO->MachOObjectFile::getHeader64();
344 MachO::nlist_64 STE_64 = MachO->getSymbol64TableEntry(SymDRI);
358 H = MachO->MachOObjectFile::getHeader();
362 MachO::nlist STE = MachO->getSymbolTableEntry(SymDRI);
383 if ((NType & MachO::N_TYPE) == MachO::N_INDR) {
388 if (MachO->getIndirectName(S.Sym.getRawDataRefImpl(), IndirectName))
400 if ((NType & MachO::N_TYPE) == MachO::N_INDR)
402 if (Obj.isIR() && (NType & MachO::N_TYPE) == MachO::N_TYPE)
407 switch (NType & MachO::N_TYPE) {
408 case MachO::N_UNDF:
411 if (MachO::GET_COMM_ALIGN(NDesc) != 0)
412 outs() << "(alignment 2^" << (int)MachO::GET_COMM_ALIGN(NDesc) << ") ";
414 if ((NType & MachO::N_TYPE) == MachO::N_PBUD)
418 if ((NDesc & MachO::REFERENCE_TYPE) ==
419 MachO::REFERENCE_FLAG_UNDEFINED_LAZY)
421 else if ((NDesc & MachO::REFERENCE_TYPE) ==
422 MachO::REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY)
424 else if ((NDesc & MachO::REFERENCE_TYPE) ==
425 MachO::REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY)
431 case MachO::N_ABS:
434 case MachO::N_INDR:
437 case MachO::N_SECT: {
454 MachO->getSymbolSection(S.Sym.getRawDataRefImpl());
461 if (Sec == MachO->section_end()) {
470 if (Expected<StringRef> NameOrErr = MachO->getSectionName(Ref))
472 StringRef SegmentName = MachO->getSectionFinalSegmentName(Ref);
481 if (NType & MachO::N_EXT) {
482 if (NDesc & MachO::REFERENCED_DYNAMICALLY)
484 if (NType & MachO::N_PEXT) {
485 if ((NDesc & MachO::N_WEAK_DEF) == MachO::N_WEAK_DEF)
490 if ((NDesc & MachO::N_WEAK_REF) == MachO::N_WEAK_REF ||
491 (NDesc & MachO::N_WEAK_DEF) == MachO::N_WEAK_DEF) {
492 if ((NDesc & (MachO::N_WEAK_REF | MachO::N_WEAK_DEF)) ==
493 (MachO::N_WEAK_REF | MachO::N_WEAK_DEF))
501 if (NType & MachO::N_PEXT)
507 if (Filetype == MachO::MH_OBJECT) {
508 if (NDesc & MachO::N_NO_DEAD_STRIP)
510 if ((NType & MachO::N_TYPE) != MachO::N_UNDF &&
511 NDesc & MachO::N_SYMBOL_RESOLVER)
513 if ((NType & MachO::N_TYPE) != MachO::N_UNDF && NDesc & MachO::N_ALT_ENTRY)
515 if ((NType & MachO::N_TYPE) != MachO::N_UNDF && NDesc & MachO::N_COLD_FUNC)
519 if ((NDesc & MachO::N_ARM_THUMB_DEF) == MachO::N_ARM_THUMB_DEF)
522 if ((NType & MachO::N_TYPE) == MachO::N_INDR) {
525 if (MachO) {
527 if (MachO->getIndirectName(S.Sym.getRawDataRefImpl(), IndirectName))
538 if ((Flags & MachO::MH_TWOLEVEL) == MachO::MH_TWOLEVEL &&
539 (((NType & MachO::N_TYPE) == MachO::N_UNDF && NValue == 0) ||
540 (NType & MachO::N_TYPE) == MachO::N_PBUD)) {
541 uint32_t LibraryOrdinal = MachO::GET_LIBRARY_ORDINAL(NDesc);
543 if (LibraryOrdinal == MachO::EXECUTABLE_ORDINAL)
545 else if (LibraryOrdinal == MachO::DYNAMIC_LOOKUP_ORDINAL)
549 if (!MachO ||
550 MachO->getLibraryShortNameByIndex(LibraryOrdinal - 1, LibraryName))
565 {MachO::N_GSYM, "GSYM"}, {MachO::N_FNAME, "FNAME"},
566 {MachO::N_FUN, "FUN"}, {MachO::N_STSYM, "STSYM"},
567 {MachO::N_LCSYM, "LCSYM"}, {MachO::N_BNSYM, "BNSYM"},
568 {MachO::N_PC, "PC"}, {MachO::N_AST, "AST"},
569 {MachO::N_OPT, "OPT"}, {MachO::N_RSYM, "RSYM"},
570 {MachO::N_SLINE, "SLINE"}, {MachO::N_ENSYM, "ENSYM"},
571 {MachO::N_SSYM, "SSYM"}, {MachO::N_SO, "SO"},
572 {MachO::N_OSO, "OSO"}, {MachO::N_LIB, "LIB"},
573 {MachO::N_LSYM, "LSYM"}, {MachO::N_BINCL, "BINCL"},
574 {MachO::N_SOL, "SOL"}, {MachO::N_PARAMS, "PARAM"},
575 {MachO::N_VERSION, "VERS"}, {MachO::N_OLEVEL, "OLEV"},
576 {MachO::N_PSYM, "PSYM"}, {MachO::N_EINCL, "EINCL"},
577 {MachO::N_ENTRY, "ENTRY"}, {MachO::N_LBRAC, "LBRAC"},
578 {MachO::N_EXCL, "EXCL"}, {MachO::N_RBRAC, "RBRAC"},
579 {MachO::N_BCOMM, "BCOMM"}, {MachO::N_ECOMM, "ECOMM"},
580 {MachO::N_ECOML, "ECOML"}, {MachO::N_LENG, "LENG"},
592 static void darwinPrintStab(MachOObjectFile *MachO, const NMSymbol &S) {
593 MachO::nlist_64 STE_64;
594 MachO::nlist STE;
599 if (MachO->is64Bit()) {
600 STE_64 = MachO->getSymbol64TableEntry(SymDRI);
605 STE = MachO->getSymbolTableEntry(SymDRI);
786 MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj);
793 (UndefinedOnly && MachO && OutputFormat != darwin)) &&
817 else if (MachO && S.TypeChar == 'I')
830 if ((OutputFormat == darwin || FormatMachOasHex) && (MachO || Obj.isIR())) {
835 << (MachO ? "0" : SymbolSizeStr);
836 } else if (OutputFormat == bsd || (OutputFormat == darwin && !MachO)) {
842 if (S.TypeChar == '-' && MachO)
843 darwinPrintStab(MachO, S);
845 if (S.TypeChar == 'I' && MachO) {
849 if (MachO->getIndirectName(S.Sym.getRawDataRefImpl(), IndirectName))
1021 if (NType & MachO::N_STAB)
1024 switch (NType & MachO::N_TYPE) {
1025 case MachO::N_ABS:
1027 case MachO::N_INDR:
1029 case MachO::N_SECT: {
1043 if (Obj.is64Bit() && Obj.getHeader64().filetype == MachO::MH_KEXT_BUNDLE &&
1166 else if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj))
1167 Ret = getSymbolNMTypeChar(*MachO, I);
1214 MachO::nlist_64 STE = Obj.getSymbol64TableEntry(Symb);
1215 return (STE.n_type & MachO::N_TYPE) == MachO::N_SECT ? STE.n_sect : 0;
1217 MachO::nlist STE = Obj.getSymbolTableEntry(Symb);
1218 return (STE.n_type & MachO::N_TYPE) == MachO::N_SECT ? STE.n_sect : 0;
1221 static void dumpSymbolsFromDLInfoMachO(MachOObjectFile &MachO,
1235 MachO::mach_header H;
1236 MachO::mach_header_64 H_64;
1238 if (MachO.is64Bit()) {
1239 H_64 = MachO.MachOObjectFile::getHeader64();
1242 H = MachO.MachOObjectFile::getHeader();
1246 for (const auto &Command : MachO.load_commands()) {
1247 if (Command.C.cmd == MachO::LC_SEGMENT) {
1248 MachO::segment_command Seg = MachO.getSegmentLoadCommand(Command);
1253 } else if (Command.C.cmd == MachO::LC_SEGMENT_64) {
1254 MachO::segment_command_64 Seg = MachO.getSegment64LoadCommand(Command);
1262 HFlags & MachO::MH_NLIST_OUTOFSYNC_WITH_DYLDINFO) {
1265 for (const llvm::object::ExportEntry &Entry : MachO.exports(Err)) {
1293 bool Abs = ((EFlags & MachO::EXPORT_SYMBOL_FLAGS_KIND_MASK) ==
1294 MachO::EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE);
1295 bool Resolver = (EFlags & MachO::EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER);
1296 ReExport = (EFlags & MachO::EXPORT_SYMBOL_FLAGS_REEXPORT);
1297 bool WeakDef = (EFlags & MachO::EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION);
1299 S.NDesc |= MachO::N_WEAK_DEF;
1301 S.NType = MachO::N_EXT | MachO::N_ABS;
1304 S.NType = MachO::N_EXT | MachO::N_INDR;
1307 S.NType = MachO::N_EXT | MachO::N_SECT;
1310 if ((S.Address & 1) != 0 && !MachO.is64Bit() &&
1311 H.cputype == MachO::CPU_TYPE_ARM) {
1313 S.NDesc |= MachO::N_ARM_THUMB_DEF;
1320 for (const SectionRef &Section : MachO.sections()) {
1329 MachO.getSectionFinalSegmentName(Section.getRawDataRefImpl());
1337 S.NDesc |= MachO::REFERENCED_DYNAMICALLY;
1384 U.NType = MachO::N_EXT | MachO::N_UNDF;
1389 MachO::SET_LIBRARY_ORDINAL(U.NDesc, Entry.other());
1403 error(std::move(Err), MachO.getFileName());
1423 for (const llvm::object::MachOBindEntry &Entry : MachO.bindTable(BErr)) {
1444 B.NType = MachO::N_EXT | MachO::N_UNDF;
1447 MachO::SET_LIBRARY_ORDINAL(B.NDesc, Entry.ordinal());
1456 error(std::move(BErr), MachO.getFileName());
1477 MachO.lazyBindTable(LErr)) {
1502 L.NType = MachO::N_EXT | MachO::N_UNDF;
1506 L.NDesc = MachO::REFERENCE_FLAG_UNDEFINED_LAZY;
1507 MachO::SET_LIBRARY_ORDINAL(L.NDesc, Entry.ordinal());
1515 error(std::move(LErr), MachO.getFileName());
1537 MachO.weakBindTable(WErr)) {
1541 Entry.flags() & MachO::BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION) {
1563 W.NType = MachO::N_EXT | MachO::N_UNDF;
1568 W.NDesc = MachO::N_WEAK_DEF;
1579 SymbolList[J].NDesc |= MachO::N_WEAK_DEF;
1583 error(std::move(WErr), MachO.getFileName());
1603 for (const auto &Command : MachO.load_commands()) {
1604 if (Command.C.cmd == MachO::LC_FUNCTION_STARTS) {
1607 MachO::linkedit_data_command LLC =
1608 MachO.getLinkeditDataLoadCommand(Command);
1610 MachO.ReadULEB128s(LLC.dataoff, FoundFns);
1611 } else if (Command.C.cmd == MachO::LC_MAIN) {
1612 MachO::entry_point_command LCmain = MachO.getEntryPointCommand(Command);
1636 F.NType = MachO::N_SECT;
1640 for (const SectionRef &Section : MachO.sections()) {
1647 MachO.getSectionFinalSegmentName(Section.getRawDataRefImpl());
1813 MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj);
1814 if (!SegSect.empty() && MachO) {
1815 Nsect = getNsectForSegSect(MachO);
1821 if (!(MachO && DyldInfoOnly)) {
1847 if (Nsect && Nsect != getNsectInMachO(*MachO, Sym))
1876 if (MachO) {
1898 if (MachO && !NoDyldInfo)
1899 dumpSymbolsFromDLInfoMachO(*MachO, SymbolList);
1960 if (Command.C.cmd != MachO::LC_FILESET_ENTRY)
1963 MachO::fileset_entry_command Entry =
2000 // Are we handling a MachO of type MH_FILESET?
2003 MachO::MH_FILESET) {
2021 auto *MachO = dyn_cast<MachOObjectFile>(O);
2023 if (!MachO || ArchAll || ArchFlags.empty())
2026 MachO::mach_header H;
2027 MachO::mach_header_64 H_64;
2030 if (MachO->is64Bit()) {
2031 H_64 = MachO->MachOObjectFile::getHeader64();
2035 H = MachO->MachOObjectFile::getHeader();