Fix the Archive::Child::getRawSize() method used by llvm-objdump’s -archive-headers...
authorKevin Enderby <enderby@apple.com>
Fri, 16 Jan 2015 22:10:36 +0000 (22:10 +0000)
committerKevin Enderby <enderby@apple.com>
Fri, 16 Jan 2015 22:10:36 +0000 (22:10 +0000)
and tweak its use in llvm-objdump.  Add back the test case for the -archive-headers option.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226332 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Object/Archive.h
lib/Object/Archive.cpp
test/tools/llvm-objdump/X86/macho-archive-headers.test [new file with mode: 0644]
tools/llvm-objdump/MachODump.cpp

index 71906d16770164dbe74c5a438092d78fc0ccc4b5..e3b7a2a1fcaf6ff83a17fa8ab7cf5fd62dfa1508 100644 (file)
@@ -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 {
index f14b29e1622d1b51a194ef9bd2a2ae1835075b89..c8d510f03ded63733d0a70620b8c66120a8b9e4c 100644 (file)
@@ -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 (file)
index 0000000..3d9043e
--- /dev/null
@@ -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
index 51140c29cede279b8986abfe047cfbca3a687bc3..412055afd287681b59e579a3868e92fb63deeb09 100644 (file)
@@ -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();