public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] i386 compiler args are wrong
@ 2013-04-07 15:39 Vladimir 'φ-coder/phcoder' Serbinenko
  2013-04-15 23:55 ` Simon Glass
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2013-04-07 15:39 UTC (permalink / raw)
  To: u-boot

-pie for ld can't be used w/o -fPIE to compiler. -m32 and -melf_i386
are needed to be able to use gcc-multilib/binutils-multilib.
-fPIE prevents from using some registers in constraints.

diff --git a/Makefile b/Makefile
index db7561c..6c3a8d5 100644
--- a/Makefile
+++ b/Makefile
@@ -365,7 +365,7 @@ else
 PLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc
 endif
 else
-PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
+PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CPPFLAGS) $(CFLAGS) -print-libgcc-file-name`) -lgcc
 endif
 PLATFORM_LIBS += $(PLATFORM_LIBGCC)
 export PLATFORM_LIBS
diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index 168dc24..4dfe7e8 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -25,7 +25,7 @@ CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
 
 PLATFORM_CPPFLAGS += -fno-strict-aliasing
 PLATFORM_CPPFLAGS += -Wstrict-prototypes
-PLATFORM_CPPFLAGS += -mregparm=3
+PLATFORM_CPPFLAGS += -mregparm=3 -m32 -fPIE
 PLATFORM_CPPFLAGS += -fomit-frame-pointer
 PF_CPPFLAGS_X86   := $(call cc-option, -ffreestanding) \
 		     $(call cc-option, -fno-toplevel-reorder, \
@@ -41,7 +41,7 @@ __HAVE_ARCH_GENERIC_BOARD := y
 
 PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
 
-PLATFORM_LDFLAGS += --emit-relocs -Bsymbolic -Bsymbolic-functions
+PLATFORM_LDFLAGS += --emit-relocs -Bsymbolic -Bsymbolic-functions -melf_i386
 
 LDFLAGS_FINAL += --gc-sections -pie
 LDFLAGS_FINAL += --wrap=__divdi3 --wrap=__udivdi3
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index 4e9e1f7..629994c 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -299,11 +299,12 @@ void boot_zimage(void *setup_base, void *load_address)
 	 */
 	__asm__ __volatile__ (
 	"movl $0, %%ebp\n"
+	"movl $0, %%ebx\n"
+	"movl $0, %%edi\n"
 	"cli\n"
 	"jmp *%[kernel_entry]\n"
 	:: [kernel_entry]"a"(load_address),
-	   [boot_params] "S"(setup_base),
-	   "b"(0), "D"(0)
+	   [boot_params] "S"(setup_base)
 	:  "%ebp"
 	);
 }
diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
index baaa2fb..2fb50f5 100644
--- a/examples/standalone/Makefile
+++ b/examples/standalone/Makefile
@@ -68,7 +68,7 @@ ELF	:= $(addprefix $(obj),$(ELF))
 BIN	:= $(addprefix $(obj),$(BIN))
 SREC	:= $(addprefix $(obj),$(SREC))
 
-gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
+gcclibdir := $(shell dirname `$(CC) $(CPPFLAGS) -print-libgcc-file-name`)
 
 CPPFLAGS += -I..
 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 294 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130407/612ad3f1/attachment.pgp>

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

* [U-Boot] [PATCH] i386 compiler args are wrong
  2013-04-07 15:39 [U-Boot] [PATCH] i386 compiler args are wrong Vladimir 'φ-coder/phcoder' Serbinenko
@ 2013-04-15 23:55 ` Simon Glass
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Glass @ 2013-04-15 23:55 UTC (permalink / raw)
  To: u-boot

Hi Vladimir, Tom,

On Sun, Apr 7, 2013 at 8:39 AM, Vladimir '?-coder/phcoder' Serbinenko
<phcoder@gmail.com> wrote:
> -pie for ld can't be used w/o -fPIE to compiler. -m32 and -melf_i386
> are needed to be able to use gcc-multilib/binutils-multilib.
> -fPIE prevents from using some registers in constraints.

This patch looks OK from an x86 perspective but it touches the main Makefile.

It is quite late for this release so I'm not sure whether to accept it
as a bug-fix. For now, I will leave it out of x86/master. Please let
me know what you want to do.

>
> diff --git a/Makefile b/Makefile
> index db7561c..6c3a8d5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -365,7 +365,7 @@ else
>  PLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc
>  endif
>  else
> -PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc
> +PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CPPFLAGS) $(CFLAGS) -print-libgcc-file-name`) -lgcc
>  endif
>  PLATFORM_LIBS += $(PLATFORM_LIBGCC)
>  export PLATFORM_LIBS
> diff --git a/arch/x86/config.mk b/arch/x86/config.mk
> index 168dc24..4dfe7e8 100644
> --- a/arch/x86/config.mk
> +++ b/arch/x86/config.mk
> @@ -25,7 +25,7 @@ CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
>
>  PLATFORM_CPPFLAGS += -fno-strict-aliasing
>  PLATFORM_CPPFLAGS += -Wstrict-prototypes
> -PLATFORM_CPPFLAGS += -mregparm=3
> +PLATFORM_CPPFLAGS += -mregparm=3 -m32 -fPIE
>  PLATFORM_CPPFLAGS += -fomit-frame-pointer
>  PF_CPPFLAGS_X86   := $(call cc-option, -ffreestanding) \
>                      $(call cc-option, -fno-toplevel-reorder, \
> @@ -41,7 +41,7 @@ __HAVE_ARCH_GENERIC_BOARD := y
>
>  PLATFORM_RELFLAGS += -ffunction-sections -fvisibility=hidden
>
> -PLATFORM_LDFLAGS += --emit-relocs -Bsymbolic -Bsymbolic-functions
> +PLATFORM_LDFLAGS += --emit-relocs -Bsymbolic -Bsymbolic-functions -melf_i386
>
>  LDFLAGS_FINAL += --gc-sections -pie
>  LDFLAGS_FINAL += --wrap=__divdi3 --wrap=__udivdi3
> diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
> index 4e9e1f7..629994c 100644
> --- a/arch/x86/lib/zimage.c
> +++ b/arch/x86/lib/zimage.c
> @@ -299,11 +299,12 @@ void boot_zimage(void *setup_base, void *load_address)
>          */
>         __asm__ __volatile__ (
>         "movl $0, %%ebp\n"
> +       "movl $0, %%ebx\n"
> +       "movl $0, %%edi\n"
>         "cli\n"
>         "jmp *%[kernel_entry]\n"
>         :: [kernel_entry]"a"(load_address),
> -          [boot_params] "S"(setup_base),
> -          "b"(0), "D"(0)
> +          [boot_params] "S"(setup_base)

What is this part of the patch for? It doesn't seem to be referenced
in your commit message.

>         :  "%ebp"
>         );
>  }
> diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
> index baaa2fb..2fb50f5 100644
> --- a/examples/standalone/Makefile
> +++ b/examples/standalone/Makefile
> @@ -68,7 +68,7 @@ ELF   := $(addprefix $(obj),$(ELF))
>  BIN    := $(addprefix $(obj),$(BIN))
>  SREC   := $(addprefix $(obj),$(SREC))
>
> -gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
> +gcclibdir := $(shell dirname `$(CC) $(CPPFLAGS) -print-libgcc-file-name`)
>
>  CPPFLAGS += -I..

Regards,
Simon

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

end of thread, other threads:[~2013-04-15 23:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-07 15:39 [U-Boot] [PATCH] i386 compiler args are wrong Vladimir 'φ-coder/phcoder' Serbinenko
2013-04-15 23:55 ` Simon Glass

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox