Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1430201554-11359-1-git-send-email-armccurdy@gmail.com>
Date: Mon, 27 Apr 2015 23:12:34 -0700
From: Andre McCurdy <armccurdy@...il.com>
To: musl@...ts.openwall.com
Cc: Andre McCurdy <armccurdy@...il.com>
Subject: [PATCH] force LTO to be disabled when compiling dlstart.lo

When LTO is enabled, the _dlstart_c symbol seems to get removed before
the crt_arch.h assembler fragment which references it has been linked.

Disabling LTO for dlstart.lo is a less intrusive workaround than making
_dlstart_c globally visible.

Signed-off-by: Andre McCurdy <armccurdy@...il.com>
---
 Makefile  | 4 ++++
 configure | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/Makefile b/Makefile
index 6559295..48580fc 100644
--- a/Makefile
+++ b/Makefile
@@ -89,6 +89,10 @@ src/ldso/dlstart.lo src/ldso/dynlink.lo: src/internal/dynlink.h arch/$(ARCH)/rel
 
 crt/crt1.o crt/Scrt1.o src/ldso/dlstart.lo: $(wildcard arch/$(ARCH)/crt_arch.h)
 
+# Disable LTO as a workaround for the _dlstart_c symbol being removed
+# before the crt_arch.h assembler fragment which references it is linked.
+src/ldso/dlstart.lo: CFLAGS += $(CFLAGS_NOLTO)
+
 crt/Scrt1.o: CFLAGS += -fPIC
 
 OPTIMIZE_SRCS = $(wildcard $(OPTIMIZE_GLOBS:%=src/%))
diff --git a/configure b/configure
index 143dc92..69c6dab 100755
--- a/configure
+++ b/configure
@@ -112,6 +112,7 @@ fi
 CFLAGS_C99FSE=
 CFLAGS_AUTO=
 CFLAGS_MEMOPS=
+CFLAGS_NOLTO=
 CFLAGS_NOSSP=
 LDFLAGS_AUTO=
 OPTIMIZE_GLOBS=
@@ -296,6 +297,12 @@ CFLAGS_C99FSE="$CFLAGS_C99FSE -D__may_alias__="
 fi
 
 #
+# Check for options to disable LTO. If not found, this is not an
+# error; we assume the toolchain does not support LTO.
+#
+tryflag CFLAGS_NOLTO -fno-lto
+
+#
 # Check for options to disable stack protector, which needs to be
 # disabled for a few early-bootstrap translation units. If not found,
 # this is not an error; we assume the toolchain does not do ssp.
@@ -564,6 +571,7 @@ CC = $CC
 CFLAGS = $CFLAGS_AUTO $CFLAGS
 CFLAGS_C99FSE = $CFLAGS_C99FSE
 CFLAGS_MEMOPS = $CFLAGS_MEMOPS
+CFLAGS_NOLTO = $CFLAGS_NOLTO
 CFLAGS_NOSSP = $CFLAGS_NOSSP
 CPPFLAGS = $CPPFLAGS
 LDFLAGS = $LDFLAGS_AUTO $LDFLAGS
-- 
1.9.1

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.