]> git.sur5r.net Git - openocd/commitdiff
contrib/loaders: Enforce Little Endian ARM machine code
authorAndreas Färber <afaerber@suse.de>
Sat, 21 May 2016 22:41:15 +0000 (00:41 +0200)
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>
Sun, 14 Aug 2016 10:45:15 +0000 (11:45 +0100)
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>
contrib/loaders/checksum/Makefile
contrib/loaders/erase_check/Makefile
contrib/loaders/flash/fm4/Makefile
contrib/loaders/flash/kinetis_ke/Makefile
contrib/loaders/flash/xmc1xxx/Makefile
contrib/loaders/watchdog/Makefile

index 34430e2f82efa5e809822006cbac73d7f91ffbde..b9f59b8d851c253a10a52da222718c8c20bfaffe 100644 (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 $< $@
index cd4d3221fcc3d5d075338b52992b575a2ab145ec..01e62dead37b85bdc731563fd5ea11671ee99348 100644 (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 $< $@
index eb4cbd0c31b99a1956b039f2bb284ebc48e8b89b..207b9d0fa41f4771dd37a77b2803fc6aeb079236 100644 (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 $< > $@
index a0331a2ed66d6c1f13a49600e6386bce89d7ef0f..7d8dba8c73e2b65d1e92e9e0732d748bb1d0227a 100644 (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 $< $@
index 066466efdb5656975158bb04cc1e8286c74987f8..b97c602d035a84eefaa88364a4b3894fe74834b1 100644 (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 $< > $@
index d9ef1d2c5263af46b7f91c26e11528367658638b..623e74407c09a7407defd799f3d64adfe0d013af 100644 (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 $< $@