This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: PR libc/12518: Provide GLIBC_2_2_5/GLIBC_2_14 memcpy


Hi,

This patch adds GLIBC_2_2_5/GLIBC_2_14 memcpy with GLIBC_2_2_5 version
aliased to memmove. Tested it on Linux/Intel Core i7 with old and new
memmcpy references:

[hjl@gnu-6 pr12518]$ readelf -s old | grep memcpy
     5: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcpy@GLIBC_2.2.5 (2)
    74: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcpy@@GLIBC_2.2.5
[hjl@gnu-6 pr12518]$ readelf -s dynamic | grep memcpy
     5: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcpy@GLIBC_2.14 (3)
    77: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcpy@@GLIBC_2.14
[hjl@gnu-6 pr12518]$ gdb old
GNU gdb (GDB) 7.2.50.20110312-cvs
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show
copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /export/home/hjl/bugs/libc/pr12518/old...done.
(gdb) b main
Breakpoint 1 at 0x400618: file foo.c, line 9.
(gdb) r
Starting program: /export/home/hjl/bugs/libc/pr12518/old 

Breakpoint 1, main () at foo.c:9
9	  memset (bar, 0, sizeof bar);
(gdb) next
10	  strcpy (bar, "hello");
(gdb) 
11	  memcpy (bar + 4, bar, 5);
(gdb) step
__memmove_ssse3_back () at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:60
60		mov	%rdi, %rax
(gdb) c
Continuing.
hellhello
[Inferior 1 (process 22430) exited normally]
(gdb) q
[hjl@gnu-6 pr12518]$ gdb dynamic 
GNU gdb (GDB) 7.2.50.20110312-cvs
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show
copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /export/home/hjl/bugs/libc/pr12518/dynamic...done.
(gdb) b main
Breakpoint 1 at 0x400638: file foo.c, line 9.
(gdb) r
Starting program: /export/home/hjl/bugs/libc/pr12518/dynamic 

Breakpoint 1, main () at foo.c:9
9	  memset (bar, 0, sizeof bar);
(gdb) next
10	  strcpy (bar, "hello");
(gdb) 
11	  memcpy (bar + 4, bar, 5);
(gdb) step
__memcpy_ssse3_back () at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:60
60		mov	%rdi, %rax
(gdb) c
Continuing.
hellhello
[Inferior 1 (process 22435) exited normally]
(gdb) q
[hjl@gnu-6 pr12518]$ 


2011-03-26  H.J. Lu  <hongjiu.lu@intel.com>

	PR libc/12518
	* Versions.def (libc): Add GLIBC_2.14.

	* sysdeps/x86_64/multiarch/Versions: Add memcpy to GLIBC_2.14.

	* sysdeps/x86_64/multiarch/memcpy.S: Include <shlib-compat.h>.
	(memcpy): Renamed to ...
	(__new_memcpy): This.
	(memcpy): Provide GLIBC_2_14 memcpy.

	* sysdeps/x86_64/multiarch/memmove.c: Include <shlib-compat.h>.
	(memcpy): Provide GLIBC_2_2_5 memcpy.

diff --git a/Versions.def b/Versions.def
index 0ccda50..e478fdd 100644
--- a/Versions.def
+++ b/Versions.def
@@ -30,6 +30,7 @@ libc {
   GLIBC_2.11
   GLIBC_2.12
   GLIBC_2.13
+  GLIBC_2.14
 %ifdef USE_IN_LIBIO
   HURD_CTHREADS_0.3
 %endif
diff --git a/sysdeps/x86_64/multiarch/Versions b/sysdeps/x86_64/multiarch/Versions
index 59b185a..eae47ae 100644
--- a/sysdeps/x86_64/multiarch/Versions
+++ b/sysdeps/x86_64/multiarch/Versions
@@ -2,4 +2,7 @@ libc {
   GLIBC_PRIVATE {
     __get_cpu_features;
   }
+  GLIBC_2.14 {
+    memcpy;
+  }
 }
diff --git a/sysdeps/x86_64/multiarch/memcpy.S b/sysdeps/x86_64/multiarch/memcpy.S
index 8e9fb19..ae9929b 100644
--- a/sysdeps/x86_64/multiarch/memcpy.S
+++ b/sysdeps/x86_64/multiarch/memcpy.S
@@ -19,6 +19,7 @@
    02111-1307 USA.  */
 
 #include <sysdep.h>
+#include <shlib-compat.h>
 #include <init-arch.h>
 
 /* Define multiple versions only for the definition in lib and for
@@ -26,8 +27,8 @@
    happened.  */
 #if defined SHARED && !defined NOT_IN_libc
 	.text
-ENTRY(memcpy)
-	.type	memcpy, @gnu_indirect_function
+ENTRY(__new_memcpy)
+	.type	__new_memcpy, @gnu_indirect_function
 	cmpl	$0, KIND_OFFSET+__cpu_features(%rip)
 	jne	1f
 	call	__init_cpu_features
@@ -39,7 +40,7 @@ ENTRY(memcpy)
 	jz	2f
 	leaq	__memcpy_ssse3_back(%rip), %rax
 2:	ret
-END(memcpy)
+END(__new_memcpy)
 
 # undef ENTRY
 # define ENTRY(name) \
@@ -68,6 +69,8 @@ END(memcpy)
    by the indirect call in the PLT.  */
 # define libc_hidden_builtin_def(name) \
 	.globl __GI_memcpy; __GI_memcpy = __memcpy_sse2
+
+versioned_symbol (libc, __new_memcpy, memcpy, GLIBC_2_14);
 #endif
 
 #include "../memcpy.S"
diff --git a/sysdeps/x86_64/multiarch/memmove.c b/sysdeps/x86_64/multiarch/memmove.c
index 3798627..5b6ddec 100644
--- a/sysdeps/x86_64/multiarch/memmove.c
+++ b/sysdeps/x86_64/multiarch/memmove.c
@@ -20,6 +20,7 @@
 #include <string.h>
 
 #ifndef NOT_IN_libc
+#include <shlib-compat.h>
 #include "init-arch.h"
 
 #define MEMMOVE __memmove_sse2
@@ -42,4 +43,8 @@ libc_ifunc (memmove,
 	    ? (HAS_FAST_COPY_BACKWARD
 	       ? __memmove_ssse3_back : __memmove_ssse3)
 	    : __memmove_sse2);
+
+#if SHLIB_COMPAT (libc, GLIBC_2_2_5, GLIBC_2_14)
+compat_symbol (libc, memmove, memcpy, GLIBC_2_2_5);
+#endif
 #endif


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]