[ELF][test] Improve i386-linkonce.s
authorFangrui Song <i@maskray.me>
Wed, 16 Mar 2022 01:47:52 +0000 (18:47 -0700)
committerFangrui Song <i@maskray.me>
Wed, 16 Mar 2022 01:47:52 +0000 (18:47 -0700)
Make it behave like the glibc<2.32 .gnu.linkonce usage that we want to work around.

lld/test/ELF/Inputs/i386-linkonce.s [deleted file]
lld/test/ELF/i386-linkonce.s

diff --git a/lld/test/ELF/Inputs/i386-linkonce.s b/lld/test/ELF/Inputs/i386-linkonce.s
deleted file mode 100644 (file)
index a45832c..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-.section .gnu.linkonce.t.__i686.get_pc_thunk.bx
-.global __i686.get_pc_thunk.bx
-__i686.get_pc_thunk.bx:
-    mov    (%esp),%ebx
-    ret
-
-.section .text
-.weak _strchr1
-_strchr1:
-    call __i686.get_pc_thunk.bx
-    ret
index 87379c9..919e633 100644 (file)
@@ -1,13 +1,34 @@
-// REQUIRES: x86
-// RUN: llvm-mc -filetype=obj -triple=i386-linux-gnu %s -o %t.o
-// RUN: llvm-mc -filetype=obj -triple=i386-linux-gnu %p/Inputs/i386-linkonce.s -o %t2.o
-// RUN: llvm-ar rcs %t2.a %t2.o
+# REQUIRES: x86
+# RUN: rm -rf %t && split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=i386 %t/a.s -o %t/a.o
+# RUN: llvm-mc -filetype=obj -triple=i386 %t/crti.s -o %t/crti.o
+# RUN: llvm-mc -filetype=obj -triple=i386 %t/elf-init.s -o %t/elf-init.o
 
-/// crti.o in i386 glibc<2.32 has .gnu.linkonce.t.__x86.get_pc_thunk.bx that is
-/// not fully supported. Test that we don't report
-/// "relocation refers to a symbol in a discarded section: __x86.get_pc_thunk.bx".
-// RUN: ld.lld %t.o %t2.a %t2.o -o /dev/null
+## crti.o in i386 glibc<2.32 has .gnu.linkonce.t.__x86.get_pc_thunk.bx that is
+## not fully supported. Test that we don't report
+## "relocation refers to a symbol in a discarded section: __x86.get_pc_thunk.bx".
+# RUN: ld.lld %t/a.o %t/crti.o %t/elf-init.o -o /dev/null
 
-    .globl _start
+#--- a.s
+.globl _start
 _start:
-    call _strchr1
+
+#--- crti.s
+.section .gnu.linkonce.t.__x86.get_pc_thunk.bx,"ax"
+.globl __x86.get_pc_thunk.bx
+.hidden __x86.get_pc_thunk.bx
+__x86.get_pc_thunk.bx:
+  movl (%esp),%ebx
+  ret
+
+#--- elf-init.s
+.globl __libc_csu_init
+__libc_csu_init:
+  call __x86.get_pc_thunk.bx
+
+.section .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
+.globl __x86.get_pc_thunk.bx
+.hidden __x86.get_pc_thunk.bx
+__x86.get_pc_thunk.bx:
+  movl (%esp),%ebx
+  ret