Makefile: Don't generate position independent code
PATCH 1/1 Makefile: Don't generate position independent code
Since gcc-8 the --enabled-default-pie starts producing code which assembler can't translate in case of U-Boot. The build fails with
{standard input}: Assembler messages:
{standard input}:21100: Error: junk at end of line, first unrecognized character is @' {standard input}:21120: Error: junk at end of line, first unrecognized character is @'
and so on.
This is usually the case for x86 platform because in many cases it uses host compiler from the Linux distributions, where PIE is enabled by default. Previously (gcc-7 and earlier) that was a potential issue due to absence of constructions like
.long end.5561 at gotoff-start.5558@gotoff
which are a cause of above error messages in gcc-8.
Fix all these by disabling PIE on Makefile level.
--- Makefile | 4 ++++ 1 file changed, 4 insertions(+)
Makefile +4 -0
@@ -375,6 +375,10 @@ KBUILD_CFLAGS := -Wall -Wstrict-prototypes \ KBUILD_CFLAGS += -fshort-wchar KBUILD_AFLAGS := -D__ASSEMBLY__ +# Don't generate position independent code +KBUILD_CFLAGS += $(call cc-option,-fno-PIE) +KBUILD_AFLAGS += $(call cc-option,-fno-PIE) + # Read UBOOTRELEASE from include/config/uboot.release (if it exists) UBOOTRELEASE = $(shell cat include/config/uboot.release 2> /dev/null) UBOOTVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
Signature · 1 line
2.18.0
PATCH 1/1 Makefile: Don't generate position independent code
Quoted 33 lines · Andy Shevchenko
Since gcc-8 the --enabled-default-pie starts producing code which assembler can't translate in case of U-Boot. The build fails with
{standard input}: Assembler messages:
{standard input}:21100: Error: junk at end of line, first unrecognized character is@' {standard input}:21120: Error: junk at end of line, first unrecognized character is@'and so on.
This is usually the case for x86 platform because in many cases it uses host compiler from the Linux distributions, where PIE is enabled by default. Previously (gcc-7 and earlier) that was a potential issue due to absence of constructions like
.long end.5561 at gotoff-start.5558@gotoff
which are a cause of above error messages in gcc-8.
Fix all these by disabling PIE on
Makefilelevel.Reported-by Heinrich Schuchardt <[email protected]>Suggested-by Mika Westerberg <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>--- Makefile | 4 ++++ 1 file changed, 4 insertions(+)Makefile +0
-0
Makefile KBUILD_CFLAGS := -Wall -Wstrict-prototypes \ · line 384
Quoted 10 lines
Makefile +4
-0@@ -375,6 +375,10 @@ KBUILD_CFLAGS := -Wall -Wstrict-prototypes \ KBUILD_CFLAGS += -fshort-wchar KBUILD_AFLAGS := -D__ASSEMBLY__ +# Don't generate position independent code +KBUILD_CFLAGS += $(call cc-option,-fno-PIE) +KBUILD_AFLAGS += $(call cc-option,-fno-PIE) + # Read UBOOTRELEASE from include/config/uboot.release (if it exists) UBOOTRELEASE = $(shell cat include/config/uboot.release 2> /dev/null) UBOOTVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
With the patch building with gcc-8.1 works on i386. But the interesting question is whether the EFI subsystem will be able to relocate the runtime code when the EFI service SetVirtualAddressMap() is called.
Did you boot Linux with the patch via bootefi and call any of the EFI runtime services from Linux?
As you are changing this for all architectures this needs to be tested on all (ARM, RISC-V, and x86) architectures supporting the EFI subsystem.
Best regards
Heinrich
PATCH 1/1 Makefile: Don't generate position independent code
Quoted 5 lines · Heinrich Schuchardt
Quoted 1 line · Andy Shevchenko
Fix all these by disabling PIE on
Makefilelevel.With the patch building with gcc-8.1 works on i386.
Does it mean you are actually run it and it works?
Quoted 3 lines
But the interesting
question is whether the EFI subsystem will be able to relocate the runtime code when the EFI serviceSetVirtualAddressMap()is called.
EFI code should have different CFLAGS I suppose.
Quoted 2 lines
Did you boot Linux with the patch via bootefi and call any of the EFI runtime services from Linux?
Nope, I have no platform with UEFI to test.
Quoted 3 lines
As you are changing this for all architectures this needs to be tested on all (ARM, RISC-V, and x86) architectures supporting the EFI subsystem.
Agree. Unfortunately I have almost none of them to play with. I leave this to others who able to confirm the patch works.
My understanding we need this anyway and if there are some problems, we need to fix them on individual basis.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
PATCH 1/1 Makefile: Don't generate position independent code
Quoted 7 lines · Andy Shevchenko
Quoted 5 lines · Heinrich Schuchardt
Quoted 1 line · Andy Shevchenko
Fix all these by disabling PIE on
Makefilelevel.With the patch building with gcc-8.1 works on i386.
Quoted 7 lines
Does it mean you are actually run it and it works?
Quoted 3 lines
But the interesting
question is whether the EFI subsystem will be able to relocate the runtime code when the EFI serviceSetVirtualAddressMap()is called.EFI code should have different CFLAGS I suppose.
This really depends on the architecture:
On RISC-V EFI specific flags are not defined.
On ARMCFLAGS_NON_EFI := -fno-pic -ffixed-r9 -ffunction-sections -fdata-sections CFLAGS_EFI := -fpic -fshort-wchar
On x86
ifeq ($(IS_32BIT),y)CFLAGS_NON_EFI := -mregparm=3
endifCFLAGS_EFI := -fpic -fshort-wchar
Do you know how -fpic and -fno-PIE work together when both are passed to gcc?
CFLAGS_EFI is only used to compile standalone EFI executables like helloworld.efi not the EFI runtime. See lib/efi_loader/Makefile.
Best regards
Hienrich
Quoted 16 lines
Quoted 3 lines
Did you boot Linux with the patch via bootefi and call any of the EFI runtime services from Linux?
Nope, I have no platform with UEFI to test.
Quoted 3 lines
As you are changing this for all architectures this needs to be tested on all (ARM, RISC-V, and x86) architectures supporting the EFI subsystem.
Agree. Unfortunately I have almost none of them to play with. I leave this to others who able to confirm the patch works.
My understanding we need this anyway and if there are some problems, we need to fix them on individual basis.
PATCH 1/1 Makefile: Don't generate position independent code
Quoted 7 lines · Heinrich Schuchardt
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Heinrich Schuchardt
Quoted 1 line · Andy Shevchenko
Fix all these by disabling PIE on
Makefilelevel.With the patch building with gcc-8.1 works on i386.
Does it mean you are actually run it and it works?
Can you confirm that binary you got is working for you?
Quoted 22 lines
Quoted 6 lines
Quoted 4 lines
But the interesting
question is whether the EFI subsystem will be able to relocate the runtime code when the EFI serviceSetVirtualAddressMap()is called.EFI code should have different CFLAGS I suppose.
This really depends on the architecture:
On RISC-V EFI specific flags are not defined.
On ARM
CFLAGS_NON_EFI:= -fno-pic -ffixed-r9 -ffunction-sections -fdata- sectionsCFLAGS_EFI:= -fpic -fshort-wcharOn x86
ifeq ($(IS_32BIT),y)CFLAGS_NON_EFI:= -mregparm=3
endifCFLAGS_EFI:= -fpic -fshort-wchar
Quoted 3 lines
Do you know how -fpic and -fno-PIE work together when both are passed to
gcc?
In all three cases where CONFIG_EFI is used there is no KBUILD_*FLAGS are in use. The special flags are for EFI apps as it supposed to be.
Quoted 2 lines
CFLAGS_EFIis only used to compile standalone EFI executables like helloworld.efi not the EFI runtime. Seelib/efi_loader/Makefile.
Yes, I see no contradiction here.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
PATCH 1/1 Makefile: Don't generate position independent code
Quoted 10 lines · Andy Shevchenko
Quoted 7 lines · Heinrich Schuchardt
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Heinrich Schuchardt
Quoted 1 line · Andy Shevchenko
Fix all these by disabling PIE on
Makefilelevel.With the patch building with gcc-8.1 works on i386.
Does it mean you are actually run it and it works?
Can you confirm that binary you got is working for you?
I can start qemu-x86_defconfig and run bootefi selftest with your patch.
odroid-c2_defconfig can boot both with either booti or bootefi with your patch.
Best regards
Heinrich
PATCH 1/1 Makefile: Don't generate position independent code
Quoted 8 lines · Heinrich Schuchardt
Quoted 7 lines · Andy Shevchenko
Quoted 6 lines · Heinrich Schuchardt
Quoted 5 lines · Andy Shevchenko
Quoted 3 lines · Heinrich Schuchardt
Quoted 1 line · Andy Shevchenko
Fix all these by disabling PIE on
Makefilelevel.With the patch building with gcc-8.1 works on i386.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Does it mean you are actually run it and it works?
Can you confirm that binary you got is working for you?
I can start qemu-x86_defconfig and run bootefi selftest with your patch.
odroid-c2_defconfig can boot both with either booti or bootefi with your patch.
Thanks for testing!
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 1/1 Makefile: Don't generate position independent code
Quoted 11 lines · Andy Shevchenko
Quoted 10 lines · Heinrich Schuchardt
Quoted 9 lines · Andy Shevchenko
Quoted 7 lines · Heinrich Schuchardt
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Heinrich Schuchardt
Quoted 1 line · Andy Shevchenko
Fix all these by disabling PIE on
Makefilelevel.With the patch building with gcc-8.1 works on i386.
Does it mean you are actually run it and it works?
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Can you confirm that binary you got is working for you?
I can start qemu-x86_defconfig and run bootefi selftest with your patch.
odroid-c2_defconfig can boot both with either booti or bootefi with your patch.
Thanks for testing!
Bin, can we get this applied? For now (*) it's a bit of burden to run make CC=gcc-7 each time I would like U-Boot to be built.
(*) It seems Debian (-like) distros, one of which we are using as an OS on build machines, switched to gcc-8 by default and this is a problem for native compilation.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 1/1 Makefile: Don't generate position independent code
Hi Andy,
Quoted 17 lines · Andy Shevchenko
Quoted 15 lines · Andy Shevchenko
Quoted 14 lines · Heinrich Schuchardt
Quoted 10 lines · Andy Shevchenko
Quoted 7 lines · Heinrich Schuchardt
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Heinrich Schuchardt
Quoted 1 line · Andy Shevchenko
Fix all these by disabling PIE on
Makefilelevel.With the patch building with gcc-8.1 works on i386.
Does it mean you are actually run it and it works?
Can you confirm that binary you got is working for you?
I can start qemu-x86_defconfig and run bootefi selftest with your patch.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
odroid-c2_defconfig can boot both with either booti or bootefi with your patch.
Thanks for testing!
Bin, can we get this applied? For now (*) it's a bit of burden to run make CC=gcc-7 each time I would like U-Boot to be built.
This was not assigned to me in patchwork. But yes, I can take this one via the x86 tree.
Heinrich,
I assume I can add your "Tested-by" tag since from patchwork I don't see this patch has any tags associated. Let me know if this is OK.
Quoted 5 lines
(*) It seems Debian (-like) distros, one of which we are using as an OS on build machines, switched to gcc-8 by default and this is a problem for native compilation.
--
Regards,
Bin
PATCH 1/1 Makefile: Don't generate position independent code
Quoted 30 lines · Bin Meng
Hi Andy,
Quoted 17 lines · Andy Shevchenko
Quoted 15 lines · Andy Shevchenko
Quoted 14 lines · Heinrich Schuchardt
Quoted 10 lines · Andy Shevchenko
Quoted 7 lines · Heinrich Schuchardt
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Heinrich Schuchardt
Quoted 1 line · Andy Shevchenko
Fix all these by disabling PIE on
Makefilelevel.With the patch building with gcc-8.1 works on i386.
Does it mean you are actually run it and it works?
Can you confirm that binary you got is working for you?
I can start qemu-x86_defconfig and run bootefi selftest with your patch.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
odroid-c2_defconfig can boot both with either booti or bootefi with your patch.
Thanks for testing!
Bin, can we get this applied? For now (*) it's a bit of burden to run make CC=gcc-7 each time I would like U-Boot to be built.
Quoted 7 lines
This was not assigned to me in patchwork. But yes, I can take this one via the x86 tree.
Heinrich,
I assume I can add your "Tested-by" tag since from patchwork I don't see this patch has any tags associated. Let me know if this is OK.
You can add the tag. But, please, observe that I did not test on the following architectures: RISC-V, ARM 32bit. I did not test loading of Linux on x86.
Best regards
Heinrich
Quoted 10 lines
Quoted 6 lines
(*) It seems Debian (-like) distros, one of which we are using as an OS on build machines, switched to gcc-8 by default and this is a problem for native compilation.
--
Regards,
Bin
PATCH 1/1 Makefile: Don't generate position independent code
Quoted 2 lines · Heinrich Schuchardt
I did not test loading of
Linux on x86.
For the record I did test this.
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
PATCH 1/1 Makefile: Don't generate position independent code
Quoted 7 lines · Andy Shevchenko
Quoted 2 lines · Heinrich Schuchardt
I did not test loading of
Linux on x86.For the record I did test this.
On QEMU x86 boards (except efi-x86_app_defconfig which is currently broken)
applied to u-boot-x86, thanks!
PATCH 1/1 Makefile: Don't generate position independent code
Hi,
Quoted 7 lines · Bin Meng
Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · Heinrich Schuchardt
I did not test loading of
Linux on x86.
Quoted 7 lines
Quoted 2 lines
For the record I did test this.
Tested-by Bin Meng <[email protected]>On QEMU x86 boards (except efi-x86_app_defconfig which is currently broken)
applied to u-boot-x86, thanks!
This appears to break build sandbox on Ubuntu 18.04 at least (gcc-7.3).
Can we revert it, or do something else stop it from happening with sandbox?
At present all testing is broken for me.
Regards,
Simon
PATCH 1/1 Makefile: Don't generate position independent code
Quoted 13 lines · Simon Glass
Hi,
Quoted 10 lines · Bin Meng
Quoted 7 lines · Andy Shevchenko
Quoted 2 lines · Heinrich Schuchardt
I did not test loading of
Linux on x86.For the record I did test this.
Quoted 6 lines
Quoted 4 lines
Tested-by Bin Meng <[email protected]>On QEMU x86 boards (except efi-x86_app_defconfig which is currently broken)
applied to u-boot-x86, thanks!
This appears to break build sandbox on Ubuntu 18.04 at least (gcc-7.3).
Sandbox is not a real bootloader for sure :-)
Does the below cure?
arch/sandbox/config.mk +1 -0
@@ -3,6 +3,7 @@ PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE PLATFORM_CPPFLAGS += -DCONFIG_ARCH_MAP_SYSMEM +PLATFORM_CPPFLAGS += -fPIC PLATFORM_LIBS += -lrt LDFLAGS_FINAL += --gc-sections
Quoted 3 lines
Can we revert it, or do something else stop it from happening with sandbox?
At present all testing is broken for me.
Signature · 2 lines
With Best Regards, Andy Shevchenko