diff options
| author | Ian Munsie <imunsie@au1.ibm.com> | 2013-09-22 22:05:11 -0400 |
|---|---|---|
| committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-10-11 01:48:56 -0400 |
| commit | d72b08017161ab385d4ae080ea415c9eb7ceef83 (patch) | |
| tree | c20ece2f9d78bf9e7d01824aec499713053c7120 /arch/powerpc | |
| parent | 7df697c81587114ad4847598dd2d6061b73f1a12 (diff) | |
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>
Diffstat (limited to 'arch/powerpc')
| -rw-r--r-- | arch/powerpc/Makefile | 24 | ||||
| -rw-r--r-- | arch/powerpc/boot/Makefile | 3 | ||||
| -rw-r--r-- | arch/powerpc/kernel/vdso32/vdso32.lds.S | 4 | ||||
| -rw-r--r-- | arch/powerpc/kernel/vdso64/vdso64.lds.S | 4 |
4 files changed, 31 insertions, 4 deletions
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index debfa2b1c1de..d3c91bf923b7 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile | |||
| @@ -65,11 +65,29 @@ endif | |||
| 65 | 65 | ||
| 66 | UTS_MACHINE := $(OLDARCH) | 66 | UTS_MACHINE := $(OLDARCH) |
| 67 | 67 | ||
| 68 | ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y) | ||
| 69 | override CC += -mlittle-endian | ||
| 70 | override AS += -mlittle-endian | ||
| 71 | override LD += -EL | ||
| 72 | override CROSS32CC += -mlittle-endian | ||
| 73 | override CROSS32AS += -mlittle-endian | ||
| 74 | LDEMULATION := lppc | ||
| 75 | GNUTARGET := powerpcle | ||
| 76 | MULTIPLEWORD := -mno-multiple | ||
| 77 | else | ||
| 78 | override CC += -mbig-endian | ||
| 79 | override AS += -mbig-endian | ||
| 80 | override LD += -EB | ||
| 81 | LDEMULATION := ppc | ||
| 82 | GNUTARGET := powerpc | ||
| 83 | MULTIPLEWORD := -mmultiple | ||
| 84 | endif | ||
| 85 | |||
| 68 | ifeq ($(HAS_BIARCH),y) | 86 | ifeq ($(HAS_BIARCH),y) |
| 69 | override AS += -a$(CONFIG_WORD_SIZE) | 87 | override AS += -a$(CONFIG_WORD_SIZE) |
| 70 | override LD += -m elf$(CONFIG_WORD_SIZE)ppc | 88 | override LD += -m elf$(CONFIG_WORD_SIZE)$(LDEMULATION) |
| 71 | override CC += -m$(CONFIG_WORD_SIZE) | 89 | override CC += -m$(CONFIG_WORD_SIZE) |
| 72 | override AR := GNUTARGET=elf$(CONFIG_WORD_SIZE)-powerpc $(AR) | 90 | override AR := GNUTARGET=elf$(CONFIG_WORD_SIZE)-$(GNUTARGET) $(AR) |
| 73 | endif | 91 | endif |
| 74 | 92 | ||
| 75 | LDFLAGS_vmlinux-y := -Bstatic | 93 | LDFLAGS_vmlinux-y := -Bstatic |
| @@ -95,7 +113,7 @@ endif | |||
| 95 | CFLAGS-$(CONFIG_PPC64) := -mtraceback=no -mcall-aixdesc | 113 | CFLAGS-$(CONFIG_PPC64) := -mtraceback=no -mcall-aixdesc |
| 96 | CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,-mminimal-toc) | 114 | CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,-mminimal-toc) |
| 97 | CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions) | 115 | CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions) |
| 98 | CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 -mmultiple | 116 | CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 $(MULTIPLEWORD) |
| 99 | 117 | ||
| 100 | ifeq ($(CONFIG_PPC_BOOK3S_64),y) | 118 | ifeq ($(CONFIG_PPC_BOOK3S_64),y) |
| 101 | CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,-mtune=power4) | 119 | CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,-mtune=power4) |
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile index 15ca2255f438..ca7f08cc4afd 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile | |||
| @@ -22,7 +22,8 @@ all: $(obj)/zImage | |||
| 22 | BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ | 22 | BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ |
| 23 | -fno-strict-aliasing -Os -msoft-float -pipe \ | 23 | -fno-strict-aliasing -Os -msoft-float -pipe \ |
| 24 | -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \ | 24 | -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \ |
| 25 | -isystem $(shell $(CROSS32CC) -print-file-name=include) | 25 | -isystem $(shell $(CROSS32CC) -print-file-name=include) \ |
| 26 | -mbig-endian | ||
| 26 | BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc | 27 | BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc |
| 27 | 28 | ||
| 28 | ifdef CONFIG_DEBUG_INFO | 29 | ifdef CONFIG_DEBUG_INFO |
diff --git a/arch/powerpc/kernel/vdso32/vdso32.lds.S b/arch/powerpc/kernel/vdso32/vdso32.lds.S index f223409629b9..e58ee10fa5c0 100644 --- a/arch/powerpc/kernel/vdso32/vdso32.lds.S +++ b/arch/powerpc/kernel/vdso32/vdso32.lds.S | |||
| @@ -4,7 +4,11 @@ | |||
| 4 | */ | 4 | */ |
| 5 | #include <asm/vdso.h> | 5 | #include <asm/vdso.h> |
| 6 | 6 | ||
| 7 | #ifdef __LITTLE_ENDIAN__ | ||
| 8 | OUTPUT_FORMAT("elf32-powerpcle", "elf32-powerpcle", "elf32-powerpcle") | ||
| 9 | #else | ||
| 7 | OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc") | 10 | OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc") |
| 11 | #endif | ||
| 8 | OUTPUT_ARCH(powerpc:common) | 12 | OUTPUT_ARCH(powerpc:common) |
| 9 | ENTRY(_start) | 13 | ENTRY(_start) |
| 10 | 14 | ||
diff --git a/arch/powerpc/kernel/vdso64/vdso64.lds.S b/arch/powerpc/kernel/vdso64/vdso64.lds.S index e4863819663b..64fb183a47c2 100644 --- a/arch/powerpc/kernel/vdso64/vdso64.lds.S +++ b/arch/powerpc/kernel/vdso64/vdso64.lds.S | |||
| @@ -4,7 +4,11 @@ | |||
| 4 | */ | 4 | */ |
| 5 | #include <asm/vdso.h> | 5 | #include <asm/vdso.h> |
| 6 | 6 | ||
| 7 | #ifdef __LITTLE_ENDIAN__ | ||
| 8 | OUTPUT_FORMAT("elf64-powerpcle", "elf64-powerpcle", "elf64-powerpcle") | ||
| 9 | #else | ||
| 7 | OUTPUT_FORMAT("elf64-powerpc", "elf64-powerpc", "elf64-powerpc") | 10 | OUTPUT_FORMAT("elf64-powerpc", "elf64-powerpc", "elf64-powerpc") |
| 11 | #endif | ||
| 8 | OUTPUT_ARCH(powerpc:common64) | 12 | OUTPUT_ARCH(powerpc:common64) |
| 9 | ENTRY(_start) | 13 | ENTRY(_start) |
| 10 | 14 | ||
