From c718b41dc68e197f79812d0652a3868e16bad7ff Mon Sep 17 00:00:00 2001 From: Tristan Ravitch Date: Mon, 20 Aug 2018 22:28:04 -0700 Subject: [PATCH] arm: Add a test with mixed ARM and Thumb code --- macaw-arm/tests/arm/Makefile | 15 +++++++++------ macaw-arm/tests/arm/test-mixed.c | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 macaw-arm/tests/arm/test-mixed.c diff --git a/macaw-arm/tests/arm/Makefile b/macaw-arm/tests/arm/Makefile index 3d4a5cd8..f50f58c9 100644 --- a/macaw-arm/tests/arm/Makefile +++ b/macaw-arm/tests/arm/Makefile @@ -1,19 +1,22 @@ -A32CC=arm-none-eabi-gcc -T32CC=arm-none-eabi-gcc -march=armv7-m +A32CC=arm-linux-gnueabi-gcc +# arm-none-eabi-gcc +T32CC=arm-linux-gnueabi-gcc -mthumb +# -march=armv7-m +# arm-none-eabi-gcc -march=armv7-m all: $(patsubst %.c,%-a32.exe,$(wildcard *.c)) $(patsubst %.c,%-t32.exe,$(wildcard *.c)) -%-a32.exe: %.s +%-a32.exe: %-a32.s $(A32CC) -fno-stack-protector -nostdlib $< -o $@ -%-t32.exe: %.s +%-t32.exe: %-t32.s $(T32CC) -fno-stack-protector -nostdlib $< -o $@ %-a32.s: %.c - $(CC) -fno-stack-protector -S -c $< -o $@ + $(A32CC) -fno-stack-protector -S -c $< -o $@ %-t32.s: %.c - $(CC) -march=thumb -fno-stack-protector -S -c $< -o $@ + $(T32CC) -fno-stack-protector -S -c $< -o $@ .PRECIOUS: %.s diff --git a/macaw-arm/tests/arm/test-mixed.c b/macaw-arm/tests/arm/test-mixed.c new file mode 100644 index 00000000..a78c8edf --- /dev/null +++ b/macaw-arm/tests/arm/test-mixed.c @@ -0,0 +1,20 @@ +#include "util.h" + +void thumbFunc(int x, int*res) __attribute__((target("thumb"))); +void thumbFunc(int x, int* res) { + if(x > 0) { + x = x + 10; + } + + *res = x; +} + +void driver(int x, int* res) { + thumbFunc(x + 1, res); +} + +void _start() { + int i; + driver((int)&driver, &i); + EXIT(); +}