contrib/loaders: Enforce Little Endian ARM machine code

arm-none-eabi target triplet defaults to Little Endian, and so far any
submitted machine code snippets have been verified to be Little Endian.
However a user might override [ARM_]CROSS_COMPILE with an armeb toolchain,
potentially resulting in invalid machine code.

Let's be safe and enforce Little Endian mode for assembler and compiler.

Change-Id: I9cefe24689eaded25d60ffb1f254b254e8d76f9d
Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-on: http://openocd.zylin.com/3498
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
__archive__
Andreas Färber 2016-05-22 00:41:15 +02:00 committed by Andreas Fritiofson
parent 0e95629eb1
commit 81631e49a6
6 changed files with 20 additions and 8 deletions

View File

@ -4,10 +4,12 @@ ARM_CROSS_COMPILE ?= arm-none-eabi-
ARM_AS ?= $(ARM_CROSS_COMPILE)as
ARM_OBJCOPY ?= $(ARM_CROSS_COMPILE)objcopy
ARM_AFLAGS = -EL
arm: armv4_5_crc.inc armv7m_crc.inc
armv4_5_%.elf: armv4_5_%.s
$(ARM_AS) $< -o $@
$(ARM_AS) $(ARM_AFLAGS) $< -o $@
armv4_5_%.bin: armv4_5_%.elf
$(ARM_OBJCOPY) -Obinary $< $@
@ -16,7 +18,7 @@ armv4_5_%.inc: armv4_5_%.bin
$(BIN2C) < $< > $@
armv7m_%.elf: armv7m_%.s
$(ARM_AS) $< -o $@
$(ARM_AS) $(ARM_AFLAGS) $< -o $@
armv7m_%.bin: armv7m_%.elf
$(ARM_OBJCOPY) -Obinary $< $@

View File

@ -4,10 +4,12 @@ ARM_CROSS_COMPILE ?= arm-none-eabi-
ARM_AS ?= $(ARM_CROSS_COMPILE)as
ARM_OBJCOPY ?= $(ARM_CROSS_COMPILE)objcopy
ARM_AFLAGS = -EL
arm: armv4_5_erase_check.inc armv7m_erase_check.inc armv7m_0_erase_check.inc
armv4_5_%.elf: armv4_5_%.s
$(ARM_AS) $< -o $@
$(ARM_AS) $(ARM_AFLAGS) $< -o $@
armv4_5_%.bin: armv4_5_%.elf
$(ARM_OBJCOPY) -Obinary $< $@
@ -16,7 +18,7 @@ armv4_5_%.inc: armv4_5_%.bin
$(BIN2C) < $< > $@
armv7m_%.elf: armv7m_%.s
$(ARM_AS) $< -o $@
$(ARM_AS) $(ARM_AFLAGS) $< -o $@
armv7m_%.bin: armv7m_%.elf
$(ARM_OBJCOPY) -Obinary $< $@

View File

@ -6,6 +6,8 @@ CC=$(CROSS_COMPILE)gcc
OBJCOPY=$(CROSS_COMPILE)objcopy
OBJDUMP=$(CROSS_COMPILE)objdump
CFLAGS = -static -nostartfiles -mlittle-endian -Wa,-EL
all: erase.inc write.inc
.PHONY: clean
@ -15,7 +17,7 @@ all: erase.inc write.inc
erase.elf write.elf: fm4.h
%.elf: %.S
$(CC) -static -nostartfiles $< -o $@
$(CC) $(CFLAGS) $< -o $@
%.lst: %.elf
$(OBJDUMP) -S $< > $@

View File

@ -4,10 +4,12 @@ CROSS_COMPILE ?= arm-none-eabi-
AS = $(CROSS_COMPILE)as
OBJCOPY = $(CROSS_COMPILE)objcopy
AFLAGS = -EL
all: kinetis_ke_flash.inc kinetis_ke_watchdog.inc
%.elf: %.s
$(AS) $< -o $@
$(AS) $(AFLAGS) $< -o $@
%.bin: %.elf
$(OBJCOPY) -Obinary $< $@

View File

@ -6,6 +6,8 @@ CC=$(CROSS_COMPILE)gcc
OBJCOPY=$(CROSS_COMPILE)objcopy
OBJDUMP=$(CROSS_COMPILE)objdump
CFLAGS = -static -nostartfiles -mlittle-endian -Wa,-EL
all: erase.inc erase_check.inc write.inc
.PHONY: clean
@ -15,7 +17,7 @@ all: erase.inc erase_check.inc write.inc
erase.elf erase_check.elf write.elf: xmc1xxx.S
%.elf: %.S
$(CC) -static -nostartfiles $< -o $@
$(CC) $(CFLAGS) $< -o $@
%.lst: %.elf
$(OBJDUMP) -S $< > $@

View File

@ -4,10 +4,12 @@ ARM_CROSS_COMPILE ?= arm-none-eabi-
ARM_AS ?= $(ARM_CROSS_COMPILE)as
ARM_OBJCOPY ?= $(ARM_CROSS_COMPILE)objcopy
ARM_AFLAGS = -EL -mthumb
arm: armv7m_kinetis_wdog.inc
armv7m_%.elf: armv7m_%.s
$(ARM_AS) -mthumb $< -o $@
$(ARM_AS) $(ARM_AFLAGS) $< -o $@
armv7m_%.bin: armv7m_%.elf
$(ARM_OBJCOPY) -Obinary $< $@