[lld] 48a0215 - [ELF][test] Improve i386-linkonce.s

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 15 18:47:58 PDT 2022


Author: Fangrui Song
Date: 2022-03-15T18:47:52-07:00
New Revision: 48a02152ab32220895d617cc78ad9e8d8423a272

URL: https://github.com/llvm/llvm-project/commit/48a02152ab32220895d617cc78ad9e8d8423a272
DIFF: https://github.com/llvm/llvm-project/commit/48a02152ab32220895d617cc78ad9e8d8423a272.diff

LOG: [ELF][test] Improve i386-linkonce.s

Make it behave like the glibc<2.32 .gnu.linkonce usage that we want to work around.

Added: 
    

Modified: 
    lld/test/ELF/i386-linkonce.s

Removed: 
    lld/test/ELF/Inputs/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
index a45832c7b0a06..0000000000000
--- a/lld/test/ELF/Inputs/i386-linkonce.s
+++ /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

diff  --git a/lld/test/ELF/i386-linkonce.s b/lld/test/ELF/i386-linkonce.s
index 87379c913179b..919e63383c15c 100644
--- a/lld/test/ELF/i386-linkonce.s
+++ b/lld/test/ELF/i386-linkonce.s
@@ -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", at 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


        


More information about the llvm-commits mailing list