This is the mail archive of the 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]

Re: gcc-4.8 + tree-loop-distribute-patterns breaks glibc-2.18

On 05/23/2013 04:32 PM, Roland McGrath wrote:
> I think I described the inadequacy and horridness of this approach already.
> We need a real solution.
I do agree with your objections and I believe the following patch is a better
approach. It uses a global definition that sets any memset/memmove symbol generated
by the compiler to internal one.

Although it fixes the checkplt testcase it does not address possible recursive calls
when building generic string algorithms. I only saw such issue on GCC trunk (so it
might be an compiler issue) and it is related to another issue. I'll bring the issue
if I see it when GCC 4.9 is released.

It fixes the check-localplt issue with GCC 4.8 + O3 I'm seeing on PPC32 and PPC64.
Tested on PPC32, PPC64, and x86_64.

Any comments?


2013-05-24  Adhemerval Zanella  <>

	* sysdeps/generic/symbol-hacks.h: Add workaround for memset/memmove calls
	generated by the compiler on loop optimizations.
	* sysdeps/wordsize-32/symbol-hacks.h: Include next symbol-hacks.h for
	general definitions.


diff --git a/sysdeps/generic/symbol-hacks.h b/sysdeps/generic/symbol-hacks.h
index bc7b4c4..9eaf014 100644
--- a/sysdeps/generic/symbol-hacks.h
+++ b/sysdeps/generic/symbol-hacks.h
@@ -1 +1,6 @@
-/* Fortunately nothing to do.  */
+/* Some compiler optimizations may transform loops into memset/memmove
+   calls and without proper declaration it may generate PLT calls.  */
+#if !defined __ASSEMBLER__ && !defined NOT_IN_libc && defined SHARED
+asm ("memmove = __GI_memmove");
+asm ("memset = __GI_memset");
diff --git a/sysdeps/wordsize-32/symbol-hacks.h b/sysdeps/wordsize-32/symbol-hacks.h
index 52ac5c1..202a807 100644
--- a/sysdeps/wordsize-32/symbol-hacks.h
+++ b/sysdeps/wordsize-32/symbol-hacks.h
@@ -16,6 +16,8 @@
    License along with the GNU C Library; if not, see
    <>.  */
+#include_next "symbol-hacks.h"
 /* A very dirty trick: gcc emits references to __divdi3, __udivdi3,
    __moddi3, and __umoddi3.  These functions are exported and
    therefore we get PLTs.  Unnecessarily so.  Changing gcc is a big

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