[lld] 3343d00 - [ELF][test] Demonstrate --no-allow-shlib-undefined behavior with a hidden relocatable object file definition

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 19 10:58:58 PDT 2023


Author: Fangrui Song
Date: 2023-10-19T10:58:52-07:00
New Revision: 3343d000a3511a4ea6fbd73bad86a3bbef8117e4

URL: https://github.com/llvm/llvm-project/commit/3343d000a3511a4ea6fbd73bad86a3bbef8117e4
DIFF: https://github.com/llvm/llvm-project/commit/3343d000a3511a4ea6fbd73bad86a3bbef8117e4.diff

LOG: [ELF][test] Demonstrate --no-allow-shlib-undefined behavior with a hidden relocatable object file definition

1981b1b6b92f7579a30c9ed32dbdf3bc749c1b40 improved the check.

Added: 
    

Modified: 
    lld/test/ELF/allow-shlib-undefined.s

Removed: 
    


################################################################################
diff  --git a/lld/test/ELF/allow-shlib-undefined.s b/lld/test/ELF/allow-shlib-undefined.s
index 515fa618e7beec6..03f047b02d75d52 100644
--- a/lld/test/ELF/allow-shlib-undefined.s
+++ b/lld/test/ELF/allow-shlib-undefined.s
@@ -37,6 +37,17 @@
 # RUN: not ld.lld %t.o %t.so %t2.so -o /dev/null 2>&1 | \
 # RUN:   FileCheck %s --check-prefixes=CHECK,CHECK2
 
+## Test some cases where relocatable object files provide a hidden definition.
+# RUN: echo '.globl _unresolved; _unresolved:' | llvm-mc -filetype=obj -triple=x86_64 -o %tdef.o
+# RUN: echo '.globl _unresolved; .hidden _unresolved; _unresolved:' | llvm-mc -filetype=obj -triple=x86_64 -o %tdef-hidden.o
+# RUN: ld.lld %t.o %t.so %tdef-hidden.o -o /dev/null 2>&1 | count 0
+
+## The section containing the definition is discarded, and we report an error.
+# RUN: not ld.lld --gc-sections %t.o %t.so %tdef-hidden.o -o /dev/null 2>&1 | FileCheck %s
+## The definition %tdef.so is ignored.
+# RUN: ld.lld -shared -soname=tdef.so %tdef.o -o %tdef.so
+# RUN: not ld.lld --gc-sections %t.o %t.so %tdef.so %tdef-hidden.o -o /dev/null 2>&1 | FileCheck %s
+
 .globl _start
 _start:
   callq _shared at PLT


        


More information about the llvm-commits mailing list