From 57cc8ad672b6b33231602e7ae78b468c69a3bc47 Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Fri, 16 Jan 2015 22:10:36 +0000 Subject: [PATCH] =?utf8?q?Fix=20the=20Archive::Child::getRawSize()=20metho?= =?utf8?q?d=20used=20by=20llvm-objdump=E2=80=99s=20-archive-headers=20opti?= =?utf8?q?on=20and=20tweak=20its=20use=20in=20llvm-objdump.=20=20Add=20bac?= =?utf8?q?k=20the=20test=20case=20for=20the=20-archive-headers=20option.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226332 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/Archive.h | 2 +- lib/Object/Archive.cpp | 2 +- test/tools/llvm-objdump/X86/macho-archive-headers.test | 10 ++++++++++ tools/llvm-objdump/MachODump.cpp | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 test/tools/llvm-objdump/X86/macho-archive-headers.test diff --git a/include/llvm/Object/Archive.h b/include/llvm/Object/Archive.h index 71906d16770..e3b7a2a1fca 100644 --- a/include/llvm/Object/Archive.h +++ b/include/llvm/Object/Archive.h @@ -91,7 +91,7 @@ public: } /// \return the size of the archive member without the header or padding. uint64_t getSize() const; - /// \return the size of the archive member with the header and padding. + /// \return the size in the archive header for this member. uint64_t getRawSize() const; StringRef getBuffer() const { diff --git a/lib/Object/Archive.cpp b/lib/Object/Archive.cpp index f14b29e1622..c8d510f03de 100644 --- a/lib/Object/Archive.cpp +++ b/lib/Object/Archive.cpp @@ -111,7 +111,7 @@ uint64_t Archive::Child::getSize() const { } uint64_t Archive::Child::getRawSize() const { - return Data.size(); + return getHeader()->getSize(); } Archive::Child Archive::Child::getNext() const { diff --git a/test/tools/llvm-objdump/X86/macho-archive-headers.test b/test/tools/llvm-objdump/X86/macho-archive-headers.test new file mode 100644 index 00000000000..3d9043e671a --- /dev/null +++ b/test/tools/llvm-objdump/X86/macho-archive-headers.test @@ -0,0 +1,10 @@ +RUN: llvm-objdump %p/Inputs/macho-universal-archive.x86_64.i386 -macho -archive-headers -arch all \ +RUN: | FileCheck %s + +# Note the date as printed by ctime(3) is time zone dependent and not checked. +CHECK: Archive : {{.*}}/macho-universal-archive.x86_64.i386 (architecture x86_64) +CHECK: -rw-r--r--124/11 44 {{.*}} __.SYMDEF SORTED +CHECK: -rw-r--r--124/0 860 {{.*}} hello.o +CHECK: Archive : {{.*}}/macho-universal-archive.x86_64.i386 (architecture i386) +CHECK: -rw-r--r--124/11 60 {{.*}} __.SYMDEF SORTED +CHECK: -rw-r--r--124/0 388 {{.*}} foo.o diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp index 51140c29ced..412055afd28 100644 --- a/tools/llvm-objdump/MachODump.cpp +++ b/tools/llvm-objdump/MachODump.cpp @@ -572,7 +572,7 @@ static void printArchiveChild(Archive::Child &C, bool verbose, outs() << format("%3d/", UID); unsigned GID = C.getGID(); outs() << format("%-3d ", GID); - uint64_t Size = C.getRawSize() - sizeof(object::ArchiveMemberHeader); + uint64_t Size = C.getRawSize(); outs() << format("%5d ", Size); StringRef RawLastModified = C.getRawLastModified(); -- 2.40.0