#
# Red Hat BZ:
# https://bugzilla.redhat.com/show_bug.cgi?id=911307
#
# Sourceware BZ: None.
#
# Upstreamm submission: Not yet completed.
#
# ChangeLog
#
# 2013-02-27 Carlos O'Donell <carlos@redhat.com>
#
# * elf/Makefile (CFLAGS-.o): Add -fno-tree-loop-distribute-patterns.
# (CFLAGS-.os): Likewise.
# (CFLAGS-.op): Likewise.
# (CFLAGS-.ob): Likewise.
# (CFLAGS-.oS): Likewise.
# * string/Makefile (CFLAGS-.o): Likewise.
# (CFLAGS-.os): Likewise.
# (CFLAGS-.op): Likewise.
# (CFLAGS-.ob): Likewise.
# (CFLAGS-.oS): Likewise.
#
diff -urN glibc-2.17-c758a686/string/Makefile glibc-2.17-c758a686/string/Makefile
--- glibc-2.17-c758a686/string/Makefile 2013-02-27 18:07:34.618968703 -0500
+++ glibc-2.17-c758a686/string/Makefile 2013-02-27 18:08:16.075796160 -0500
@@ -78,6 +78,14 @@
CFLAGS-bug-strstr1.c = -fno-builtin
CFLAGS-bug-strcasestr1.c = -fno-builtin
+# Disable any optimization which might result in function calls to the very
+# same functions we are trying to compile, thus creating an infinite loop.
+CFLAGS-.o += -fno-tree-loop-distribute-patterns
+CFLAGS-.os += -fno-tree-loop-distribute-patterns
+CFLAGS-.op += -fno-tree-loop-distribute-patterns
+CFLAGS-.ob += -fno-tree-loop-distribute-patterns
+CFLAGS-.oS += -fno-tree-loop-distribute-patterns
+
ifeq ($(run-built-tests),yes)
tests: $(objpfx)tst-svc.out
$(objpfx)tst-svc.out: tst-svc.input $(objpfx)tst-svc
diff -urN glibc-2.17-c758a686/elf/Makefile glibc-2.17-c758a686/elf/Makefile
--- glibc-2.17-c758a686/elf/Makefile 2013-02-27 18:07:13.812055613 -0500
+++ glibc-2.17-c758a686/elf/Makefile 2013-02-27 18:08:16.075796160 -0500
@@ -432,6 +432,16 @@
CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\
-DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld)
+# Disable any optimization which might result in function calls during early
+# dynamic loader startup. We disable -ftree-loop-distribute-patterns which
+# might convert code into calls to functions like memcpy or memset when the PLT
+# is not yet setup.
+CFLAGS-.o += -fno-tree-loop-distribute-patterns
+CFLAGS-.os += -fno-tree-loop-distribute-patterns
+CFLAGS-.op += -fno-tree-loop-distribute-patterns
+CFLAGS-.ob += -fno-tree-loop-distribute-patterns
+CFLAGS-.oS += -fno-tree-loop-distribute-patterns
+
test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
generated += $(addsuffix .so,$(strip $(modules-names)))