From 94dcd1b6396ff7a084866fd749cfddd80a8afbe4 Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Mon, 6 Feb 2017 21:01:08 +0000 Subject: [PATCH] Fix a bug in llvm-obdump(1) with the -macho and -info-plist options which caused it to print more than the (__TEXT,__info_plist) if that section did not end with a null. rdar://27378808 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294236 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../llvm-objdump/X86/macho-info-plist-nofollow.test | 10 ++++++++++ tools/llvm-objdump/MachODump.cpp | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 test/tools/llvm-objdump/X86/macho-info-plist-nofollow.test diff --git a/test/tools/llvm-objdump/X86/macho-info-plist-nofollow.test b/test/tools/llvm-objdump/X86/macho-info-plist-nofollow.test new file mode 100644 index 00000000000..12ad166c5a2 --- /dev/null +++ b/test/tools/llvm-objdump/X86/macho-info-plist-nofollow.test @@ -0,0 +1,10 @@ +# RUN: llvm-mc < %s -triple x86_64-apple-darwin -filetype=obj | llvm-objdump -m -info-plist - | FileCheck %s + +.section __TEXT, __info_plist +.ascii "This is the (__TEXT,__info_plist) section\n" +.section __TEXT, __follow +.asciz "This is the (__TEXT,__follow) section\n" + +# CHECK: Contents of (__TEXT,__info_plist) section +# CHECK: This is the (__TEXT,__info_plist) section +# CHECK-NOT: This is the (__TEXT,__follow) section diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp index b70e8256625..df1b74400ab 100644 --- a/tools/llvm-objdump/MachODump.cpp +++ b/tools/llvm-objdump/MachODump.cpp @@ -1142,7 +1142,7 @@ static void DumpInfoPlistSectionContents(StringRef Filename, StringRef BytesStr; Section.getContents(BytesStr); const char *sect = reinterpret_cast(BytesStr.data()); - outs() << sect; + outs() << format("%.*s", BytesStr.size(), sect) << "\n"; return; } } -- 2.50.1