mirror of https://gitee.com/openkylin/linux.git
powerpc: Add ability to build little endian kernels
This patch allows the kbuild system to successfully compile a kernel for the little endian PowerPC64 architecture. A subsequent patch will add the CONFIG_CPU_LITTLE_ENDIAN kernel config option which must be set to build such a kernel. If cross compiling, CROSS_COMPILE must point to a suitable toolchain (compiled for the powerpc64le-linux and powerpcle-linux targets). Signed-off-by: Ian Munsie <imunsie@au1.ibm.com> Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
This commit is contained in:
parent
7df697c815
commit
d72b080171
|
@ -65,11 +65,29 @@ endif
|
||||||
|
|
||||||
UTS_MACHINE := $(OLDARCH)
|
UTS_MACHINE := $(OLDARCH)
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
|
||||||
|
override CC += -mlittle-endian
|
||||||
|
override AS += -mlittle-endian
|
||||||
|
override LD += -EL
|
||||||
|
override CROSS32CC += -mlittle-endian
|
||||||
|
override CROSS32AS += -mlittle-endian
|
||||||
|
LDEMULATION := lppc
|
||||||
|
GNUTARGET := powerpcle
|
||||||
|
MULTIPLEWORD := -mno-multiple
|
||||||
|
else
|
||||||
|
override CC += -mbig-endian
|
||||||
|
override AS += -mbig-endian
|
||||||
|
override LD += -EB
|
||||||
|
LDEMULATION := ppc
|
||||||
|
GNUTARGET := powerpc
|
||||||
|
MULTIPLEWORD := -mmultiple
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(HAS_BIARCH),y)
|
ifeq ($(HAS_BIARCH),y)
|
||||||
override AS += -a$(CONFIG_WORD_SIZE)
|
override AS += -a$(CONFIG_WORD_SIZE)
|
||||||
override LD += -m elf$(CONFIG_WORD_SIZE)ppc
|
override LD += -m elf$(CONFIG_WORD_SIZE)$(LDEMULATION)
|
||||||
override CC += -m$(CONFIG_WORD_SIZE)
|
override CC += -m$(CONFIG_WORD_SIZE)
|
||||||
override AR := GNUTARGET=elf$(CONFIG_WORD_SIZE)-powerpc $(AR)
|
override AR := GNUTARGET=elf$(CONFIG_WORD_SIZE)-$(GNUTARGET) $(AR)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LDFLAGS_vmlinux-y := -Bstatic
|
LDFLAGS_vmlinux-y := -Bstatic
|
||||||
|
@ -95,7 +113,7 @@ endif
|
||||||
CFLAGS-$(CONFIG_PPC64) := -mtraceback=no -mcall-aixdesc
|
CFLAGS-$(CONFIG_PPC64) := -mtraceback=no -mcall-aixdesc
|
||||||
CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,-mminimal-toc)
|
CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,-mminimal-toc)
|
||||||
CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
|
CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
|
||||||
CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 -mmultiple
|
CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 $(MULTIPLEWORD)
|
||||||
|
|
||||||
ifeq ($(CONFIG_PPC_BOOK3S_64),y)
|
ifeq ($(CONFIG_PPC_BOOK3S_64),y)
|
||||||
CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,-mtune=power4)
|
CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,-mtune=power4)
|
||||||
|
|
|
@ -22,7 +22,8 @@ all: $(obj)/zImage
|
||||||
BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
|
BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
|
||||||
-fno-strict-aliasing -Os -msoft-float -pipe \
|
-fno-strict-aliasing -Os -msoft-float -pipe \
|
||||||
-fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
|
-fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
|
||||||
-isystem $(shell $(CROSS32CC) -print-file-name=include)
|
-isystem $(shell $(CROSS32CC) -print-file-name=include) \
|
||||||
|
-mbig-endian
|
||||||
BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
|
BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
|
||||||
|
|
||||||
ifdef CONFIG_DEBUG_INFO
|
ifdef CONFIG_DEBUG_INFO
|
||||||
|
|
|
@ -4,7 +4,11 @@
|
||||||
*/
|
*/
|
||||||
#include <asm/vdso.h>
|
#include <asm/vdso.h>
|
||||||
|
|
||||||
|
#ifdef __LITTLE_ENDIAN__
|
||||||
|
OUTPUT_FORMAT("elf32-powerpcle", "elf32-powerpcle", "elf32-powerpcle")
|
||||||
|
#else
|
||||||
OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc")
|
OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc")
|
||||||
|
#endif
|
||||||
OUTPUT_ARCH(powerpc:common)
|
OUTPUT_ARCH(powerpc:common)
|
||||||
ENTRY(_start)
|
ENTRY(_start)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,11 @@
|
||||||
*/
|
*/
|
||||||
#include <asm/vdso.h>
|
#include <asm/vdso.h>
|
||||||
|
|
||||||
|
#ifdef __LITTLE_ENDIAN__
|
||||||
|
OUTPUT_FORMAT("elf64-powerpcle", "elf64-powerpcle", "elf64-powerpcle")
|
||||||
|
#else
|
||||||
OUTPUT_FORMAT("elf64-powerpc", "elf64-powerpc", "elf64-powerpc")
|
OUTPUT_FORMAT("elf64-powerpc", "elf64-powerpc", "elf64-powerpc")
|
||||||
|
#endif
|
||||||
OUTPUT_ARCH(powerpc:common64)
|
OUTPUT_ARCH(powerpc:common64)
|
||||||
ENTRY(_start)
|
ENTRY(_start)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue