Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

microblaze: fix endian handling

Building an allmodconfig kernel fails horribly because of
endian mismatch. It turns out that the -mlittle-endian
switch was not honored at all as we were using the wrong
Kconfig symbol and failing to apply CPUFLAGS to the CFLAGS.
Finally, the linker flags did not get set right.

This addresses all three of those issues, which now lets
me build both big-endian and little-endian kernels for
testing.

Fixes: 428dbf156cc5 ("arch: change default endian for microblaze")
Fixes: 206d3642d8ee ("arch/microblaze: add choice for endianness and update Makefile")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>

authored by

Arnd Bergmann and committed by
Michal Simek
71e7673d a8750ddc

+11 -6
+11 -6
arch/microblaze/Makefile
··· 36 36 CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_DIV) += -mno-xl-soft-div 37 37 CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_BARREL) += -mxl-barrel-shift 38 38 CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) += -mxl-pattern-compare 39 - CPUFLAGS-$(CONFIG_BIG_ENDIAN) += -mbig-endian 40 - CPUFLAGS-$(CONFIG_LITTLE_ENDIAN) += -mlittle-endian 39 + 40 + ifdef CONFIG_CPU_BIG_ENDIAN 41 + KBUILD_CFLAGS += -mbig-endian 42 + KBUILD_AFLAGS += -mbig-endian 43 + LD += -EB 44 + else 45 + KBUILD_CFLAGS += -mlittle-endian 46 + KBUILD_AFLAGS += -mlittle-endian 47 + LD += -EL 48 + endif 41 49 42 50 CPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER)) 43 51 44 52 # r31 holds current when in kernel mode 45 - KBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-1) $(CPUFLAGS-2) 46 - 47 - LDFLAGS := 48 - LDFLAGS_vmlinux := 53 + KBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-y) $(CPUFLAGS-1) $(CPUFLAGS-2) 49 54 50 55 head-y := arch/microblaze/kernel/head.o 51 56 libs-y += arch/microblaze/lib/