kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kvmtool: Makefile: disable PIE build for bios and pre_init
@ 2016-10-24 10:58 riku.voipio
  2016-10-26 17:32 ` Will Deacon
  0 siblings, 1 reply; 3+ messages in thread
From: riku.voipio @ 2016-10-24 10:58 UTC (permalink / raw)
  To: kvm; +Cc: will.deacon, Riku Voipio

From: Riku Voipio <riku.voipio@linaro.org>

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 <riku.voipio@linaro.org>
---
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)
+BIOS_CFLAGS += -fno-pic
 
 x86/bios.o: x86/bios/bios.bin x86/bios/bios-rom.h
 
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] kvmtool: Makefile: disable PIE build for bios and pre_init
  2016-10-24 10:58 [PATCH] kvmtool: Makefile: disable PIE build for bios and pre_init riku.voipio
@ 2016-10-26 17:32 ` Will Deacon
  2016-11-04 13:10   ` Riku Voipio
  0 siblings, 1 reply; 3+ messages in thread
From: Will Deacon @ 2016-10-26 17:32 UTC (permalink / raw)
  To: riku.voipio; +Cc: kvm

On Mon, Oct 24, 2016 at 01:58:53PM +0300, riku.voipio@linaro.org wrote:
> From: Riku Voipio <riku.voipio@linaro.org>
> 
> 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 <riku.voipio@linaro.org>
> ---
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kvmtool: Makefile: disable PIE build for bios and pre_init
  2016-10-26 17:32 ` Will Deacon
@ 2016-11-04 13:10   ` Riku Voipio
  0 siblings, 0 replies; 3+ messages in thread
From: Riku Voipio @ 2016-11-04 13:10 UTC (permalink / raw)
  To: Will Deacon; +Cc: kvm@vger.kernel.org

On 26 October 2016 at 20:32, Will Deacon <will.deacon@arm.com> wrote:
> On Mon, Oct 24, 2016 at 01:58:53PM +0300, riku.voipio@linaro.org wrote:
>> From: Riku Voipio <riku.voipio@linaro.org>
>>
>> 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 <riku.voipio@linaro.org>
>> ---
>> 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?

Welp, I did test. And since it worked, it implies that -no-pie is not
needed for BIOS_FLAGS... Updating in a moment.

Riku

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-04 13:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-24 10:58 [PATCH] kvmtool: Makefile: disable PIE build for bios and pre_init riku.voipio
2016-10-26 17:32 ` Will Deacon
2016-11-04 13:10   ` Riku Voipio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).