Lines Matching +full:mach +full:- +full:o
1 //===-- llvm-size.cpp - Print the size of each object section ---*- C++ -*-===//
8 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
43 clEnumVal(darwin, "Darwin -m format"), clEnumValEnd),
50 clEnumValN(darwin, "m", "Darwin -m format"), clEnumValEnd),
67 ArchFlags("arch", cl::desc("architecture(s) from a Mach-O file to dump"),
73 Radix("-radix", cl::desc("Print size in radix. Only 8, 10, and 16 are valid"),
78 cl::values(clEnumValN(octal, "o", "Print size in octal"),
110 // "libx.a(foo.o)" after the ToolName before the error message. It sets
136 …the file name and which architecture slice it // is from, for example: "foo.o (for architecture i3…
178 if (!Obj->isELF()) in considerForSize()
194 for (auto &Sym : Obj->symbols()) in getCommonSize()
195 if (Obj->getSymbolFlags(Sym.getRawDataRefImpl()) & SymbolRef::SF_Common) in getCommonSize()
196 TotalCommons += Obj->getCommonSymbolSize(Sym.getRawDataRefImpl()); in getCommonSize()
200 /// Print the size of each Mach-O segment and section in @p MachO.
203 /// output as darwin's size(1) -m output.
212 uint32_t Filetype = MachO->getHeader().filetype; in printDarwinSectionSizes()
215 for (const auto &Load : MachO->load_commands()) { in printDarwinSectionSizes()
217 MachO::segment_command_64 Seg = MachO->getSegment64LoadCommand(Load); in printDarwinSectionSizes()
227 MachO::section_64 Sec = MachO->getSection64(Load, J); in printDarwinSectionSizes()
243 MachO::segment_command Seg = MachO->getSegmentLoadCommand(Load); in printDarwinSectionSizes()
254 MachO::section Sec = MachO->getSection(Load, J); in printDarwinSectionSizes()
275 /// Print the summary sizes of the standard Mach-O segments in @p MachO.
277 /// This is when used when @c OutputFormat is berkeley with a Mach-O file and
284 for (const auto &Load : MachO->load_commands()) { in printDarwinSegmentSizes()
286 MachO::segment_command_64 Seg = MachO->getSegment64LoadCommand(Load); in printDarwinSegmentSizes()
287 if (MachO->getHeader().filetype == MachO::MH_OBJECT) { in printDarwinSegmentSizes()
289 MachO::section_64 Sec = MachO->getSection64(Load, J); in printDarwinSegmentSizes()
312 MachO::segment_command Seg = MachO->getSegmentLoadCommand(Load); in printDarwinSegmentSizes()
313 if (MachO->getHeader().filetype == MachO::MH_OBJECT) { in printDarwinSegmentSizes()
315 MachO::section Sec = MachO->getSection(Load, J); in printDarwinSegmentSizes()
360 // size(1) -m output, else if OutputFormat is darwin and not a Mach-O object in printObjectSectionSizes()
366 // darwin's default berkeley format for Mach-O files. in printObjectSectionSizes()
375 for (const SectionRef &Section : Obj->sections()) { in printObjectSectionSizes()
396 fmt << "%-" << max_name_len << "s " in printObjectSectionSizes()
407 fmt << "%-" << max_name_len << "s " in printObjectSectionSizes()
412 for (const SectionRef &Section : Obj->sections()) { in printObjectSectionSizes()
434 fmt << "%-" << max_name_len << "s " in printObjectSectionSizes()
446 for (const SectionRef &Section : Obj->sections()) { in printObjectSectionSizes()
482 /// Checks to see if the @p o ObjectFile is a Mach-O file and if it is and there
484 /// Mach-O file is one of those architectures or all architectures was
487 static bool checkMachOAndArchFlags(ObjectFile *o, StringRef file) { in checkMachOAndArchFlags() argument
488 if (isa<MachOObjectFile>(o) && !ArchAll && ArchFlags.size() != 0) { in checkMachOAndArchFlags()
489 MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); in checkMachOAndArchFlags()
494 if (MachO->is64Bit()) { in checkMachOAndArchFlags()
495 H_64 = MachO->MachOObjectFile::getHeader64(); in checkMachOAndArchFlags()
498 H = MachO->MachOObjectFile::getHeader(); in checkMachOAndArchFlags()
531 for (auto &C : a->children(Err)) { in printFileSectionSizes()
535 error(std::move(E), a->getFileName(), C); in printFileSectionSizes()
538 if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) { in printFileSectionSizes() local
539 MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); in printFileSectionSizes()
540 if (!checkMachOAndArchFlags(o, file)) in printFileSectionSizes()
543 outs() << o->getFileName() << " (ex " << a->getFileName() << "):\n"; in printFileSectionSizes()
545 outs() << a->getFileName() << "(" << o->getFileName() << "):\n"; in printFileSectionSizes()
546 printObjectSectionSizes(o); in printFileSectionSizes()
549 outs() << a->getFileName() << "(" << o->getFileName() << ")\n"; in printFileSectionSizes()
551 outs() << o->getFileName() << " (ex " << a->getFileName() << ")\n"; in printFileSectionSizes()
556 error(std::move(Err), a->getFileName()); in printFileSectionSizes()
565 for (MachOUniversalBinary::object_iterator I = UB->begin_objects(), in printFileSectionSizes()
566 E = UB->end_objects(); in printFileSectionSizes()
568 if (ArchFlags[i] == I->getArchTypeName()) { in printFileSectionSizes()
570 Expected<std::unique_ptr<ObjectFile>> UO = I->getAsObjectFile(); in printFileSectionSizes()
572 if (ObjectFile *o = dyn_cast<ObjectFile>(&*UO.get())) { in printFileSectionSizes() local
573 MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); in printFileSectionSizes()
575 outs() << o->getFileName() << " :\n"; in printFileSectionSizes()
578 outs() << o->getFileName() << " (for architecture " in printFileSectionSizes()
579 << I->getArchTypeName() << "): \n"; in printFileSectionSizes()
581 printObjectSectionSizes(o); in printFileSectionSizes()
584 outs() << o->getFileName() << " (for architecture " in printFileSectionSizes()
585 << I->getArchTypeName() << ")"; in printFileSectionSizes()
592 StringRef(I->getArchTypeName()) : StringRef()); in printFileSectionSizes()
595 I->getAsArchive()) { in printFileSectionSizes()
600 for (auto &C : UA->children(Err)) { in printFileSectionSizes()
605 error(std::move(E), UA->getFileName(), C, in printFileSectionSizes()
607 StringRef(I->getArchTypeName()) : StringRef()); in printFileSectionSizes()
610 if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) { in printFileSectionSizes() local
611 MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); in printFileSectionSizes()
613 outs() << o->getFileName() << " (ex " << UA->getFileName() in printFileSectionSizes()
616 outs() << UA->getFileName() << "(" << o->getFileName() in printFileSectionSizes()
618 << " (for architecture " << I->getArchTypeName() in printFileSectionSizes()
620 printObjectSectionSizes(o); in printFileSectionSizes()
623 outs() << UA->getFileName() << "(" << o->getFileName() in printFileSectionSizes()
626 outs() << " (for architecture " << I->getArchTypeName() in printFileSectionSizes()
630 outs() << o->getFileName() << " (ex " << UA->getFileName() in printFileSectionSizes()
636 error(std::move(Err), UA->getFileName()); in printFileSectionSizes()
639 error("Mach-O universal file: " + file + " for architecture " + in printFileSectionSizes()
640 StringRef(I->getArchTypeName()) + in printFileSectionSizes()
641 " is not a Mach-O file or an archive file"); in printFileSectionSizes()
657 for (MachOUniversalBinary::object_iterator I = UB->begin_objects(), in printFileSectionSizes()
658 E = UB->end_objects(); in printFileSectionSizes()
660 if (HostArchName == I->getArchTypeName()) { in printFileSectionSizes()
661 Expected<std::unique_ptr<ObjectFile>> UO = I->getAsObjectFile(); in printFileSectionSizes()
663 if (ObjectFile *o = dyn_cast<ObjectFile>(&*UO.get())) { in printFileSectionSizes() local
664 MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); in printFileSectionSizes()
666 outs() << o->getFileName() << " :\n"; in printFileSectionSizes()
669 outs() << o->getFileName() << " (for architecture " in printFileSectionSizes()
670 << I->getArchTypeName() << "):\n"; in printFileSectionSizes()
672 printObjectSectionSizes(o); in printFileSectionSizes()
675 outs() << o->getFileName() << " (for architecture " in printFileSectionSizes()
676 << I->getArchTypeName() << ")"; in printFileSectionSizes()
684 I->getAsArchive()) { in printFileSectionSizes()
689 for (auto &C : UA->children(Err)) { in printFileSectionSizes()
694 error(std::move(E), UA->getFileName(), C); in printFileSectionSizes()
697 if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) { in printFileSectionSizes() local
698 MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); in printFileSectionSizes()
700 outs() << o->getFileName() << " (ex " << UA->getFileName() in printFileSectionSizes()
703 outs() << UA->getFileName() << "(" << o->getFileName() << ")" in printFileSectionSizes()
704 << " (for architecture " << I->getArchTypeName() in printFileSectionSizes()
706 printObjectSectionSizes(o); in printFileSectionSizes()
709 outs() << UA->getFileName() << "(" << o->getFileName() in printFileSectionSizes()
712 outs() << o->getFileName() << " (ex " << UA->getFileName() in printFileSectionSizes()
718 error(std::move(Err), UA->getFileName()); in printFileSectionSizes()
721 error("Mach-O universal file: " + file + " for architecture " + in printFileSectionSizes()
722 StringRef(I->getArchTypeName()) + in printFileSectionSizes()
723 " is not a Mach-O file or an archive file"); in printFileSectionSizes()
731 bool MoreThanOneArch = UB->getNumberOfObjects() > 1; in printFileSectionSizes()
732 for (MachOUniversalBinary::object_iterator I = UB->begin_objects(), in printFileSectionSizes()
733 E = UB->end_objects(); in printFileSectionSizes()
735 Expected<std::unique_ptr<ObjectFile>> UO = I->getAsObjectFile(); in printFileSectionSizes()
737 if (ObjectFile *o = dyn_cast<ObjectFile>(&*UO.get())) { in printFileSectionSizes() local
738 MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); in printFileSectionSizes()
740 outs() << o->getFileName() << " :\n"; in printFileSectionSizes()
743 outs() << o->getFileName() << " (for architecture " in printFileSectionSizes()
744 << I->getArchTypeName() << "):"; in printFileSectionSizes()
747 printObjectSectionSizes(o); in printFileSectionSizes()
750 outs() << o->getFileName() << " (for architecture " in printFileSectionSizes()
751 << I->getArchTypeName() << ")"; in printFileSectionSizes()
757 StringRef(I->getArchTypeName()) : StringRef()); in printFileSectionSizes()
760 I->getAsArchive()) { in printFileSectionSizes()
764 for (auto &C : UA->children(Err)) { in printFileSectionSizes()
769 error(std::move(E), UA->getFileName(), C, MoreThanOneArch ? in printFileSectionSizes()
770 StringRef(I->getArchTypeName()) : StringRef()); in printFileSectionSizes()
773 if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) { in printFileSectionSizes() local
774 MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); in printFileSectionSizes()
776 outs() << o->getFileName() << " (ex " << UA->getFileName() in printFileSectionSizes()
779 outs() << UA->getFileName() << "(" << o->getFileName() << ")" in printFileSectionSizes()
780 << " (for architecture " << I->getArchTypeName() << "):\n"; in printFileSectionSizes()
781 printObjectSectionSizes(o); in printFileSectionSizes()
784 outs() << UA->getFileName() << "(" << o->getFileName() << ")" in printFileSectionSizes()
785 << " (for architecture " << I->getArchTypeName() in printFileSectionSizes()
788 outs() << o->getFileName() << " (ex " << UA->getFileName() in printFileSectionSizes()
794 error(std::move(Err), UA->getFileName()); in printFileSectionSizes()
797 error("Mach-O universal file: " + file + " for architecture " + in printFileSectionSizes()
798 StringRef(I->getArchTypeName()) + in printFileSectionSizes()
799 " is not a Mach-O file or an archive file"); in printFileSectionSizes()
802 } else if (ObjectFile *o = dyn_cast<ObjectFile>(&Bin)) { in printFileSectionSizes() local
803 if (!checkMachOAndArchFlags(o, file)) in printFileSectionSizes()
806 outs() << o->getFileName() << " :\n"; in printFileSectionSizes()
807 printObjectSectionSizes(o); in printFileSectionSizes()
809 MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(o); in printFileSectionSizes()
811 outs() << o->getFileName(); in printFileSectionSizes()
842 outs() << ToolName << ": for the -arch option: Unknown architecture " in main()