[lld] 557299c - [ELF][test] Test relocations referencing weak symbol, which is defined relative to a section discarded by /DISCARD/

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 14 14:59:15 PDT 2023


Author: Fangrui Song
Date: 2023-10-14T14:59:10-07:00
New Revision: 557299c9b6464f27968904aad5429cfb1512434e

URL: https://github.com/llvm/llvm-project/commit/557299c9b6464f27968904aad5429cfb1512434e
DIFF: https://github.com/llvm/llvm-project/commit/557299c9b6464f27968904aad5429cfb1512434e.diff

LOG: [ELF][test] Test relocations referencing weak symbol, which is defined relative to a section discarded by /DISCARD/

Added: 
    

Modified: 
    lld/test/ELF/linkerscript/discard-section.s

Removed: 
    


################################################################################
diff  --git a/lld/test/ELF/linkerscript/discard-section.s b/lld/test/ELF/linkerscript/discard-section.s
index df73f715494f41d..9e021ac83f563a4 100644
--- a/lld/test/ELF/linkerscript/discard-section.s
+++ b/lld/test/ELF/linkerscript/discard-section.s
@@ -1,23 +1,36 @@
 # REQUIRES: x86
 ## Test relocations referencing symbols defined relative to sections discarded by /DISCARD/.
 
-# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
-# RUN: echo "SECTIONS { /DISCARD/ : { *(.aaa*) } }" > %t.lds
-# RUN: ld.lld -T %t.lds %t.o -z undefs -o /dev/null 2>&1 | count 0
-# RUN: ld.lld -T %t.lds %t.o -o /dev/null 2>&1 | count 0
-# RUN: ld.lld -r -T %t.lds %t.o -o /dev/null 2>&1 | count 0
+# RUN: rm -rf %t && split-file %s %t && cd %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 b.s -o b.o
+# RUN: ld.lld -T a.lds a.o b.o -z undefs -o /dev/null 2>&1 | count 0
+# RUN: ld.lld -T a.lds a.o b.o -o /dev/null 2>&1 | count 0
+# RUN: ld.lld -r -T a.lds a.o b.o -o /dev/null 2>&1 | count 0
 
+#--- a.s
 .globl _start
 _start:
 
 .section .aaa,"a"
-.globl global
-.weak weak
+.globl global, weakref1
+.weak weak, weakref2
 global:
 weak:
+weakref1:
+weakref2:
   .quad 0
 
-.section .zzz,"a"
+.section .bbb,"aw"
   .quad .aaa
+
+#--- b.s
+.weak weakref1, weakref2
+.section .data,"aw"
   .quad global
   .quad weak
+  .quad weakref1
+  .quad weakref2
+
+#--- a.lds
+SECTIONS { /DISCARD/ : { *(.aaa) } }


        


More information about the llvm-commits mailing list