Index: lib/Object/ArchiveWriter.cpp =================================================================== --- lib/Object/ArchiveWriter.cpp +++ lib/Object/ArchiveWriter.cpp @@ -35,6 +35,9 @@ using namespace llvm; +static cl::opt 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; } 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