From mboxrd@z Thu Jan 1 00:00:00 1970 From: Will Deacon Subject: Re: [PATCH] kvmtool: Makefile: disable PIE build for bios and pre_init Date: Wed, 26 Oct 2016 18:32:40 +0100 Message-ID: <20161026173240.GF15216@arm.com> References: <20161024105853.20083-1-riku.voipio@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: riku.voipio@linaro.org Return-path: Received: from foss.arm.com ([217.140.101.70]:48032 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752642AbcJZRcm (ORCPT ); Wed, 26 Oct 2016 13:32:42 -0400 Content-Disposition: inline In-Reply-To: <20161024105853.20083-1-riku.voipio@linaro.org> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Oct 24, 2016 at 01:58:53PM +0300, riku.voipio@linaro.org wrote: > From: Riku Voipio > > Latest Debian and Ubuntu GCC default to PIE code. Disable > PIE for bios and pre_init. Since the flag -no-pie is not > available on older GCC's, make use of flag only if the > option is available. > > Signed-off-by: Riku Voipio > --- > see: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=837545 > --- > Makefile | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/Makefile b/Makefile > index 1f0196f..0d8b66d 100644 > --- a/Makefile > +++ b/Makefile > @@ -284,7 +284,7 @@ ifeq ($(call try-build,$(SOURCE_STATIC),$(CFLAGS),$(LDFLAGS) -static),y) > GUEST_INIT := guest/init > GUEST_OBJS = guest/guest_init.o > ifeq ($(ARCH_PRE_INIT),) > - GUEST_INIT_FLAGS += -static > + GUEST_INIT_FLAGS += -static $(PIE_FLAGS) > else > CFLAGS += -DCONFIG_GUEST_PRE_INIT > GUEST_INIT_FLAGS += -DCONFIG_GUEST_PRE_INIT > @@ -307,6 +307,10 @@ ifeq (y,$(ARCH_WANT_LIBFDT)) > endif > endif > > +ifeq ($(call try-build,$(SOURCE_HELLO),$(CFLAGS),-no-pie),y) > + PIE_FLAGS += -no-pie > +endif > + > ifneq ($(NOTFOUND),) > $(warning Skipping optional libraries: $(NOTFOUND)) > endif > @@ -388,7 +392,7 @@ $(PROGRAM_ALIAS): $(PROGRAM) > ifneq ($(ARCH_PRE_INIT),) > $(GUEST_PRE_INIT): $(ARCH_PRE_INIT) > $(E) " LINK " $@ > - $(Q) $(CC) -s -nostdlib $(ARCH_PRE_INIT) -o $@ > + $(Q) $(CC) -s $(PIE_FLAGS) -nostdlib $(ARCH_PRE_INIT) -o $@ > $(Q) $(LD) -r -b binary -o guest/guest_pre_init.o $(GUEST_PRE_INIT) > endif > > @@ -435,6 +439,8 @@ BIOS_CFLAGS += -march=i386 > BIOS_CFLAGS += -mregparm=3 > > BIOS_CFLAGS += -fno-stack-protector > +BIOS_CFLAGS += $(PIE-FLAGS) Shouldn't that be an underscore? Did you test this? Will