diff --git a/lld/test/ELF/Inputs/large-files1.o.bz2 b/lld/test/ELF/Inputs/large-files1.o.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@ t +## sed -e s/SYMBOL2/end1/g t > t2 +## sed -e s/SYMBOL3/data1/g t2 > t3 +## sed -e s/SYMBOL4/enddata1/g t3 > t1.s +## sed -e s/SYMBOL1/sym2/g %s > t +## sed -e s/SYMBOL2/end2/g t > t2 +## sed -e s/SYMBOL3/data2/g t2 > t3 +## sed -e s/SYMBOL4/enddata2/g t3 > t2.s +## llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu t1.s -o t1.o +## llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu t2.s -o t2.o +## bzip2 -c t1.o > %p/Inputs/large-files1.o.bz2 +## bzip2 -c t2.o > %p/Inputs/large-files2.o.bz2 + +# RUN: bzip2 -kdc %p/Inputs/large-files1.o.bz2 > t1.o +# RUN: bzip2 -kdc %p/Inputs/large-files2.o.bz2 > t2.o + +## Test a large output (>4GB) file can be created. +# RUN: ld.lld t1.o t2.o -o t.elf +# RUN: llvm-nm t.elf | FileCheck %s --check-prefixes=CHECK,DATA1 + +## Clean up immediately so that we are not using more disk space than we need at +## any one time. +# RUN: rm t.elf + +## Test a large input can be used with a section size >4GB and a section at +## offset >4GB. +# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o t3.o +# RUN: ld.lld t1.o t2.o -o t.ro -r +# RUN: ld.lld t.ro t3.o -o t.elf +# RUN: llvm-nm t.elf | FileCheck %s --check-prefixes=CHECK,MORE +# RUN: rm t.elf +# RUN: rm t1.o +# RUN: rm t2.o + +## Show that the link works when the large files are in an archive, for both +## thin and regular archives. +# RUN: llvm-ar rcsT t.a t.ro t3.o +# RUN: ld.lld t.a --undefined _start --undefined sym2 --undefined sym3 -m elf_x86_64 -o t.elf +# RUN: llvm-nm t.elf | FileCheck %s --check-prefixes=CHECK,MORE + +# RUN: rm t.elf +# RUN: rm t.a + +# RUN: llvm-ar rcs t.a t.ro t3.o +# RUN: rm t.ro +# RUN: ld.lld t.a --undefined _start --undefined sym2 --undefined sym3 -m elf_x86_64 -o t.elf +# RUN: llvm-nm t.elf | FileCheck %s --check-prefixes=CHECK,MORE + +## Clean up so that we do not have several GB of data leftover after this test +## finishes. +# RUN: cd .. +# RUN: rm -rf %t.dir + +# CHECK: 0000000000202000 {{.*}} _start +# CHECK-NEXT: 0000000100204000 {{.*}} data1 +# CHECK-NEXT: 0000000100208000 {{.*}} data2 +# MORE-NEXT: 000000010020c000 {{.*}} data3 +# CHECK-NEXT: 0000000080202000 {{.*}} end1 +# CHECK-NEXT: 0000000100202000 {{.*}} end2 +# MORE-NEXT: 0000000100202001 {{.*}} end3 +# CHECK-NEXT: 0000000100204001 {{.*}} enddata1 +# CHECK-NEXT: 0000000100208001 {{.*}} enddata2 +# MORE-NEXT: 000000010020c001 {{.*}} enddata3 +# CHECK-NEXT: 0000000080202000 {{.*}} sym2 +# MORE-NEXT: 0000000100202000 {{.*}} sym3 + +.align 0x1000 +.global sym3 +sym3: + nop +end3: + +.data +.align 0x4000 +data3: + .byte 0 +enddata3: diff --git a/llvm/lib/Object/Archive.cpp b/llvm/lib/Object/Archive.cpp --- a/llvm/lib/Object/Archive.cpp +++ b/llvm/lib/Object/Archive.cpp @@ -393,7 +393,7 @@ Expected Archive::Child::getSize() const { if (Parent->IsThin) { - Expected Size = Header.getSize(); + Expected Size = Header.getSize(); if (!Size) return Size.takeError(); return Size.get(); @@ -437,7 +437,7 @@ return isThinOrErr.takeError(); bool isThin = isThinOrErr.get(); if (!isThin) { - Expected Size = getSize(); + Expected Size = getSize(); if (!Size) return Size.takeError(); return StringRef(Data.data() + StartOfFile, Size.get());