[PATCH] D108328: [lld/test/ELF] Test fetch from archive to resolve undefined symbols in shared libs

Pirama Arumuga Nainar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 18 13:55:01 PDT 2021


pirama created this revision.
pirama added reviewers: MaskRay, srhines.
Herald added a subscriber: emaste.
pirama requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Add missing test coverage uncovered in review of D108006 <https://reviews.llvm.org/D108006>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108328

Files:
  lld/test/ELF/undef-in-shared-from-lazy.s


Index: lld/test/ELF/undef-in-shared-from-lazy.s
===================================================================
--- /dev/null
+++ 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, at 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108328.367319.patch
Type: text/x-patch
Size: 1311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210818/28f09ba3/attachment.bin>


More information about the llvm-commits mailing list