static error_code getSymbolNMTypeChar(MachOObjectFile &Obj, symbol_iterator I, char &Res) { DataRefImpl Symb = I->getRawDataRefImpl(); uint8_t NType = getNType(Obj, Symb); char Char; switch (NType & MachO::N_TYPE) { case MachO::N_UNDF: Char = 'u'; break; case MachO::N_ABS: Char = 's'; break; case MachO::N_SECT: { section_iterator Sec = Obj.end_sections(); Obj.getSymbolSection(Symb, Sec); DataRefImpl Ref = Sec->getRawDataRefImpl(); StringRef SectionName; Obj.getSectionName(Ref, SectionName); StringRef SegmentName = Obj.getSectionFinalSegmentName(Ref); if (SegmentName == "__TEXT" && SectionName == "__text") Char = 't'; else Char = 's'; } break; default: Char = '?'; break; } if (NType & (MachO::N_EXT | MachO::N_PEXT)) Char = toupper(static_cast<unsigned char>(Char)); Res = Char; return object_error::success; }
MCMachOObjectDisassembler::MCMachOObjectDisassembler( const MachOObjectFile &MOOF, const MCDisassembler &Dis, const MCInstrAnalysis &MIA, uint64_t VMAddrSlide, uint64_t HeaderLoadAddress) : MCObjectDisassembler(MOOF, Dis, MIA), MOOF(MOOF), VMAddrSlide(VMAddrSlide), HeaderLoadAddress(HeaderLoadAddress) { error_code ec; for (section_iterator SI = MOOF.begin_sections(), SE = MOOF.end_sections(); SI != SE; SI.increment(ec)) { if (ec) break; StringRef Name; SI->getName(Name); // FIXME: We should use the S_ section type instead of the name. if (Name == "__mod_init_func") { DEBUG(dbgs() << "Found __mod_init_func section!\n"); SI->getContents(ModInitContents); } else if (Name == "__mod_exit_func") { DEBUG(dbgs() << "Found __mod_exit_func section!\n"); SI->getContents(ModExitContents); } } }