diff --git a/test/tools/llvm-size/Inputs/darwin-m1.o b/test/tools/llvm-size/Inputs/darwin-m1.o new file mode 100644 index 00000000000..9672df524c7 Binary files /dev/null and b/test/tools/llvm-size/Inputs/darwin-m1.o differ diff --git a/test/tools/llvm-size/darwin-m.test b/test/tools/llvm-size/darwin-m.test index 23d636ba32b..ade1b724c69 100644 --- a/test/tools/llvm-size/darwin-m.test +++ b/test/tools/llvm-size/darwin-m.test @@ -1,7 +1,11 @@ RUN: llvm-size -m %p/Inputs/darwin-m.o | FileCheck --check-prefix="DARWIN" %s +RUN: llvm-size -m %p/Inputs/darwin-m.o %p/Inputs/darwin-m1.o | FileCheck --check-prefix="DARWIN2" %s DARWIN: Segment : 8 DARWIN-NEXT: Section (__TEXT, __text): 4 DARWIN-NEXT: Section (__DATA, __data): 4 DARWIN-NEXT: total 8 DARWIN-NEXT: total 8 + +DARWIN2: Inputs/darwin-m.o: +DARWIN2: Inputs/darwin-m1.o: diff --git a/tools/llvm-size/llvm-size.cpp b/tools/llvm-size/llvm-size.cpp index a11532a7c98..903e950bc73 100644 --- a/tools/llvm-size/llvm-size.cpp +++ b/tools/llvm-size/llvm-size.cpp @@ -817,11 +817,13 @@ static void printFileSectionSizes(StringRef file) { } else if (ObjectFile *o = dyn_cast(&Bin)) { if (!checkMachOAndArchFlags(o, file)) return; + MachOObjectFile *MachO = dyn_cast(o); if (OutputFormat == sysv) outs() << o->getFileName() << " :\n"; + else if (MachO && OutputFormat == darwin && MoreThanOneFile) + outs() << o->getFileName() << ":\n"; printObjectSectionSizes(o); if (OutputFormat == berkeley) { - MachOObjectFile *MachO = dyn_cast(o); if (!MachO || MoreThanOneFile) outs() << o->getFileName(); outs() << "\n";