[U-Boot] [PATCH] i386 compiler args are wrong

Simon Glass sjg at chromium.org
Tue Apr 16 01:55:33 CEST 2013


Hi Vladimir, Tom,

On Sun, Apr 7, 2013 at 8:39 AM, Vladimir 'φ-coder/phcoder' Serbinenko
<phcoder at 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


More information about the U-Boot mailing list