[PATCH] D40632: Add flag to ArchiveWriter to test GNU64 format more efficiently

Jake Ehrlich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 14:37:21 PST 2017


jakehehrlich updated this revision to Diff 125024.
jakehehrlich retitled this revision from "Add flag to llvm-ar to test GNU64 format more efficently" to "Add flag to ArchiveWriter to test GNU64 format more efficiently".
jakehehrlich added a comment.

1. Removed the flag from llvm-ar. I didn't realize we could do that but it makes sense. Good idea.
2. Added a default value to the flag so that we don't need any code to handle that.


Repository:
  rL LLVM

https://reviews.llvm.org/D40632

Files:
  lib/Object/ArchiveWriter.cpp
  test/Object/archive-GNU64-write.test
  test/Object/archive-SYM64-write.test


Index: test/Object/archive-GNU64-write.test
===================================================================
--- test/Object/archive-GNU64-write.test
+++ test/Object/archive-GNU64-write.test
@@ -2,11 +2,12 @@
 # REQUIRES: system-linux
 
 # RUN: yaml2obj %s > %t
-# RUN: dd if=%t of=%t bs=1 count=0 seek=2200M
+# RUN: dd if=%t of=%t bs=1 count=0 seek=1M
 # RUN: rm -f %t.lib
 # RUN: cp %t %t2
-# RUN: llvm-ar cr %t.lib %t %t2 %p/Inputs/trivial-object-test.elf-x86-64
+# RUN: llvm-ar -sym64-power-of-two=19 cr %t.lib %t %t2 %p/Inputs/trivial-object-test.elf-x86-64
 # RUN: llvm-nm --print-armap %t.lib | FileCheck %s
+# RUN: grep SYM64 %t.lib
 
 # Delete temp files. They are too large.
 # RUN: rm -f %t %t2 %t.lib
@@ -28,9 +29,9 @@
 # CHECK:      Archive map
 # CHECK-NEXT: main in trivial-object-test.elf-x86-64
 
-# CHECK:    archive-SYM64-write.test.tmp:
+# CHECK:    archive-GNU64-write.test.tmp:
 
-# CHECK:    archive-SYM64-write.test.tmp2:
+# CHECK:    archive-GNU64-write.test.tmp2:
 
 # CHECK:    trivial-object-test.elf-x86-64:
 # CHECK-NEXT:                     U SomeOtherFunction
Index: lib/Object/ArchiveWriter.cpp
===================================================================
--- lib/Object/ArchiveWriter.cpp
+++ lib/Object/ArchiveWriter.cpp
@@ -35,6 +35,9 @@
 
 using namespace llvm;
 
+static cl::opt<int> Sym64PowerOfTwo("sym64-power-of-two", cl::Hidden,
+                                    cl::init(32));
+
 NewArchiveMember::NewArchiveMember(MemoryBufferRef BufRef)
     : Buf(MemoryBuffer::getMemBuffer(BufRef, false)),
       MemberName(BufRef.getBufferIdentifier()) {}
@@ -484,7 +487,7 @@
     // If LastOffset isn't going to fit in a 32-bit varible we need to switch
     // to 64-bit. Note that the file can be larger than 4GB as long as the last
     // member starts before the 4GB offset.
-    if (LastOffset >> 32 != 0)
+    if (LastOffset >= (1ULL << Sym64PowerOfTwo.getValue()))
       Kind = object::Archive::K_GNU64;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40632.125024.patch
Type: text/x-patch
Size: 1966 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171130/a103fc55/attachment.bin>


More information about the llvm-commits mailing list