diff --git a/lld/test/ELF/undef-in-shared-from-lazy.s b/lld/test/ELF/undef-in-shared-from-lazy.s new file mode 100644 --- /dev/null +++ b/lld/test/ELF/undef-in-shared-from-lazy.s @@ -0,0 +1,27 @@ +// REQUIRES: x86 +// Build %t1.o with a trivial main function +// RUN: echo -e ".text\n.globl main\n.type main,@function\nmain:\nret" > %t1.s +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t1.s -o %t1.o + +// Build %t2.a which defines a global 'foo' +// RUN: echo -e ".global foo\nfoo:" > %t2.s +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t2.s -o %t2.o +// RUN: rm -f %t2.a +// RUN: llvm-ar rc %t2.a %t2.o + +// Build %t3.so that has a reference to 'foo' +// RUN: echo ".global foo" > %t3.s +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t3.s -o %t3.o +// RUN: ld.lld %t3.o -o %t3.so -shared + +// Test that 'foo' from %t2.a is fetched to define 'foo' needed by %t3.so. +// Test both cases where the archive is before or after the shared library in +// link order. + +// RUN: ld.lld --entry=main %t1.o %t2.a %t3.so -o %t +// RUN: llvm-readelf --dyn-symbols %t | FileCheck %s --check-prefix=CHECK-FETCH + +// RUN: ld.lld --entry=main %t1.o %t3.so %t2.a -o %t +// RUN: llvm-readelf --dyn-symbols %t | FileCheck %s --check-prefix=CHECK-FETCH + +// CHECK-FETCH: GLOBAL DEFAULT {{[0-9]+}} foo