diff --git a/llvm/test/tools/llvm-objdump/MachO/build-version.yaml b/llvm/test/tools/llvm-objdump/MachO/build-version.yaml --- a/llvm/test/tools/llvm-objdump/MachO/build-version.yaml +++ b/llvm/test/tools/llvm-objdump/MachO/build-version.yaml @@ -1,4 +1,6 @@ # RUN: yaml2obj %s | llvm-objdump --macho --private-headers - | FileCheck %s +# RUN: yaml2obj %s | llvm-otool -lv - | FileCheck %s +# RUN: yaml2obj %s | llvm-otool -l - | FileCheck --check-prefix=SHORT %s --- !mach-o FileHeader: @@ -55,3 +57,13 @@ CHECK-NEXT: ntools 1 CHECK-NEXT: tool clang CHECK-NEXT: version 0.0 + +SHORT: Load command 1 +SHORT-NEXT: cmd LC_BUILD_VERSION +SHORT-NEXT: cmdsize 32 +SHORT-NEXT: platform 2 +SHORT-NEXT: sdk 9.0 +SHORT-NEXT: minos 8.0 +SHORT-NEXT: ntools 1 +SHORT-NEXT: tool 1 +SHORT-NEXT: version 0.0 diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -9163,14 +9163,20 @@ outs() << " size " << Nt.size << "\n"; } -static void PrintBuildToolVersion(MachO::build_tool_version bv) { - outs() << " tool " << MachOObjectFile::getBuildTool(bv.tool) << "\n"; +static void PrintBuildToolVersion(MachO::build_tool_version bv, bool verbose) { + outs() << " tool "; + if (verbose) + outs() << MachOObjectFile::getBuildTool(bv.tool); + else + outs() << bv.tool; + outs() << "\n"; outs() << " version " << MachOObjectFile::getVersionString(bv.version) << "\n"; } static void PrintBuildVersionLoadCommand(const MachOObjectFile *obj, - MachO::build_version_command bd) { + MachO::build_version_command bd, + bool verbose) { outs() << " cmd LC_BUILD_VERSION\n"; outs() << " cmdsize " << bd.cmdsize; if (bd.cmdsize != @@ -9179,8 +9185,12 @@ outs() << " Incorrect size\n"; else outs() << "\n"; - outs() << " platform " << MachOObjectFile::getBuildPlatform(bd.platform) - << "\n"; + outs() << " platform "; + if (verbose) + outs() << MachOObjectFile::getBuildPlatform(bd.platform); + else + outs() << bd.platform; + outs() << "\n"; if (bd.sdk) outs() << " sdk " << MachOObjectFile::getVersionString(bd.sdk) << "\n"; @@ -9191,7 +9201,7 @@ outs() << " ntools " << bd.ntools << "\n"; for (unsigned i = 0; i < bd.ntools; ++i) { MachO::build_tool_version bv = obj->getBuildToolVersion(i); - PrintBuildToolVersion(bv); + PrintBuildToolVersion(bv, verbose); } } @@ -10168,7 +10178,7 @@ } else if (Command.C.cmd == MachO::LC_BUILD_VERSION) { MachO::build_version_command Bv = Obj->getBuildVersionLoadCommand(Command); - PrintBuildVersionLoadCommand(Obj, Bv); + PrintBuildVersionLoadCommand(Obj, Bv, verbose); } else if (Command.C.cmd == MachO::LC_SOURCE_VERSION) { MachO::source_version_command Sd = Obj->getSourceVersionCommand(Command); PrintSourceVersionCommand(Sd);