00db10
From 7dfe8a35215a019f552f117d907eca294225c121 Mon Sep 17 00:00:00 2001
00db10
From: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
00db10
Date: Wed, 12 Jun 2013 10:21:22 -0500
00db10
Subject: [PATCH 35/42] Fix unsafe compiler optimization
00db10
00db10
GCC 4.8 enables -ftree-loop-distribute-patterns at -O3 by default and
00db10
this optimization may transform loops into memset/memmove calls. Without
00db10
proper handling this may generate unexpected PLT calls on GLIBC.
00db10
This patch fixes by create memset/memmove alias to internal GLIBC
00db10
__GI_memset/__GI_memmove symbols.
00db10
(cherry picked from commit 6a97b62a5b4f18aea849d6f4d8de58d1469d2521)
00db10
---
00db10
 sysdeps/generic/symbol-hacks.h     | 7 ++++++-
00db10
 sysdeps/wordsize-32/symbol-hacks.h | 2 ++
00db10
 3 files changed, 16 insertions(+), 1 deletion(-)
00db10
00db10
diff --git glibc-2.17-c758a686/sysdeps/generic/symbol-hacks.h glibc-2.17-c758a686/sysdeps/generic/symbol-hacks.h
00db10
index bc7b4c4..9eaf014 100644
00db10
--- glibc-2.17-c758a686/sysdeps/generic/symbol-hacks.h
00db10
+++ glibc-2.17-c758a686/sysdeps/generic/symbol-hacks.h
00db10
@@ -1 +1,6 @@
00db10
-/* Fortunately nothing to do.  */
00db10
+/* Some compiler optimizations may transform loops into memset/memmove
00db10
+   calls and without proper declaration it may generate PLT calls.  */
00db10
+#if !defined __ASSEMBLER__ && !defined NOT_IN_libc && defined SHARED
00db10
+asm ("memmove = __GI_memmove");
00db10
+asm ("memset = __GI_memset");
00db10
+#endif
00db10
diff --git glibc-2.17-c758a686/sysdeps/wordsize-32/symbol-hacks.h glibc-2.17-c758a686/sysdeps/wordsize-32/symbol-hacks.h
00db10
index 52a14fc..ad5b231 100644
00db10
--- glibc-2.17-c758a686/sysdeps/wordsize-32/symbol-hacks.h
00db10
+++ glibc-2.17-c758a686/sysdeps/wordsize-32/symbol-hacks.h
00db10
@@ -16,6 +16,8 @@
00db10
    License along with the GNU C Library; if not, see
00db10
    <http://www.gnu.org/licenses/>.  */
00db10
 
00db10
+#include_next "symbol-hacks.h"
00db10
+
00db10
 /* A very dirty trick: gcc emits references to __divdi3, __udivdi3,
00db10
    __moddi3, and __umoddi3.  These functions are exported and
00db10
    therefore we get PLTs.  Unnecessarily so.  Changing gcc is a big
00db10
-- 
00db10
1.7.11.7
00db10