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