Skip to contentSkip to conversation

i386 compiler args are wrong

PATCH New Vladimir 'φ-coder/phcoder' Serbinenko 2 participants 2 messages Apr 7, 2013 – Apr 15, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i386 compiler args are wrong

-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.

Makefile +1 -1
index db7561c..6c3a8d5 100644
@@ -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
arch/x86/config.mk +2 -2
index 168dc24..4dfe7e8 100644
@@ -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
arch/x86/lib/zimage.c +3 -2
index 4e9e1f7..629994c 100644
@@ -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"
 	);
 }
examples/standalone/Makefile +1 -1
index baaa2fb..2fb50f5 100644
@@ -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>

#1 lore raw

PATCH 1/1 i386 compiler args are wrong

Hi Vladimir, Tom,

Quoted 3 lines · Vladimir '?-coder/phcoder' Serbinenko

-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.

Quoted 42 lines
Makefile +1 -1
index db7561c..6c3a8d5 100644
@@ -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
arch/x86/config.mk +2 -2
index 168dc24..4dfe7e8 100644
@@ -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
arch/x86/lib/zimage.c +0 -0
index 4e9e1f7..629994c 100644
@@ -299,11 +299,12 @@ void boot_zimage(void *setup_base, void *load_address)
         */

arch/x86/lib/zimage.c void boot_zimage(void *setup_base, void *load_address) · line 307

Quoted 10 lines
arch/x86/lib/zimage.c +3 -2
        __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.

Quoted 8 lines
arch/x86/lib/zimage.c +0 -0
        :  "%ebp"
        );
 }
examples/standalone/Makefile +0 -0
index baaa2fb..2fb50f5 100644

examples/standalone/Makefile ELF := $(addprefix $(obj),$(ELF)) · line 73

Quoted 7 lines
examples/standalone/Makefile +1 -1
@@ -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