Skip to content

Commit 3446d44

Browse files
dlechdpgeorge
authored andcommitted
shared/runtime/gchelper: Drop cpu directive from ARM asm helpers.
This drops the `.cpu` directive from the ARM gchelper_*.s files. Having this directive breaks the linker when targeting older CPUs (e.g. `-mthumb -mthumb-interwork` for `-mcpu=arm7tdmi`). The actual target CPU should be determined by the compiler options. The exact CPU doesn't actually matter, but rather the supported assembly instruction set. So the files are renamed to *_thumb1.s and *thumb2.s to indicate the instruction set support instead of the CPU support. Signed-off-by: David Lechner <[email protected]>
1 parent c2ab1b5 commit 3446d44

File tree

12 files changed

+19
-16
lines changed

12 files changed

+19
-16
lines changed

ports/cc3200/application.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ APP_STM_SRC_C = $(addprefix ports/stm32/,\
162162
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(APP_FATFS_SRC_C:.c=.o) $(APP_RTOS_SRC_C:.c=.o) $(APP_FTP_SRC_C:.c=.o) $(APP_HAL_SRC_C:.c=.o) $(APP_MISC_SRC_C:.c=.o))
163163
OBJ += $(addprefix $(BUILD)/, $(APP_MODS_SRC_C:.c=.o) $(APP_CC3100_SRC_C:.c=.o) $(APP_SL_SRC_C:.c=.o) $(APP_TELNET_SRC_C:.c=.o) $(APP_UTIL_SRC_C:.c=.o) $(APP_UTIL_SRC_S:.s=.o))
164164
OBJ += $(addprefix $(BUILD)/, $(APP_MAIN_SRC_C:.c=.o) $(APP_SHARED_SRC_C:.c=.o) $(APP_LIB_SRC_C:.c=.o) $(APP_STM_SRC_C:.c=.o))
165-
OBJ += $(BUILD)/shared/runtime/gchelper_m3.o
165+
OBJ += $(BUILD)/shared/runtime/gchelper_thumb2.o
166166
OBJ += $(BUILD)/pins.o
167167

168168
# List of sources for qstr extraction

ports/mimxrt/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ SRC_SS = \
262262
$(MCU_DIR)/gcc/startup_$(MCU_SERIES)$(MCU_CORE).S \
263263
hal/resethandler_MIMXRT10xx.S
264264

265-
SRC_S += shared/runtime/gchelper_m3.s \
265+
SRC_S += shared/runtime/gchelper_thumb2.s \
266266

267267
# =============================================================================
268268
# QSTR Sources

ports/qemu-arm/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ifeq ($(BOARD),netduino2)
1717
CFLAGS += -mthumb -mcpu=cortex-m3 -mfloat-abi=soft
1818
CFLAGS += -DQEMU_SOC_STM32
1919
LDSCRIPT = stm32.ld
20-
SRC_BOARD_O = shared/runtime/gchelper_native.o shared/runtime/gchelper_m3.o
20+
SRC_BOARD_O = shared/runtime/gchelper_native.o shared/runtime/gchelper_thumb2.o
2121
MPY_CROSS_FLAGS += -march=armv7m
2222
endif
2323

@@ -26,15 +26,15 @@ CFLAGS += -mthumb -mcpu=cortex-m0 -mfloat-abi=soft
2626
CFLAGS += -DQEMU_SOC_NRF51
2727
LDSCRIPT = nrf51.ld
2828
QEMU_EXTRA = -global nrf51-soc.flash-size=1048576 -global nrf51-soc.sram-size=262144
29-
SRC_BOARD_O = shared/runtime/gchelper_native.o shared/runtime/gchelper_m0.o
29+
SRC_BOARD_O = shared/runtime/gchelper_native.o shared/runtime/gchelper_thumb1.o
3030
MPY_CROSS_FLAGS += -march=armv7m
3131
endif
3232

3333
ifeq ($(BOARD),mps2-an385)
3434
CFLAGS += -mthumb -mcpu=cortex-m3 -mfloat-abi=soft
3535
CFLAGS += -DQEMU_SOC_MPS2
3636
LDSCRIPT = mps2.ld
37-
SRC_BOARD_O = shared/runtime/gchelper_native.o shared/runtime/gchelper_m3.o
37+
SRC_BOARD_O = shared/runtime/gchelper_native.o shared/runtime/gchelper_thumb2.o
3838
MPY_CROSS_FLAGS += -march=armv7m
3939
endif
4040

ports/renesas-ra/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ SRC_O += \
335335
$(SYSTEM_FILE)
336336

337337
SRC_O += \
338-
shared/runtime/gchelper_m3.o
338+
shared/runtime/gchelper_thumb2.o
339339

340340
HAL_SRC_C += $(addprefix $(HAL_DIR)/ra/board/$(BOARD_LOW)/,\
341341
board_init.c \

ports/rp2/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ set(MICROPY_SOURCE_LIB
8787
${MICROPY_DIR}/shared/netutils/netutils.c
8888
${MICROPY_DIR}/shared/netutils/trace.c
8989
${MICROPY_DIR}/shared/readline/readline.c
90-
${MICROPY_DIR}/shared/runtime/gchelper_m0.s
90+
${MICROPY_DIR}/shared/runtime/gchelper_thumb1.s
9191
${MICROPY_DIR}/shared/runtime/gchelper_native.c
9292
${MICROPY_DIR}/shared/runtime/interrupt_char.c
9393
${MICROPY_DIR}/shared/runtime/mpirq.c

ports/samd/mcu/samd21/mpconfigmcu.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CFLAGS_MCU += -mtune=cortex-m0plus -mcpu=cortex-m0plus -msoft-float
22

33
MPY_CROSS_MCU_ARCH = armv6m
44

5-
SRC_S += shared/runtime/gchelper_m0.s
5+
SRC_S += shared/runtime/gchelper_thumb1.s
66

77
LIBM_SRC_C += $(addprefix lib/libm/,\
88
acoshf.c \

ports/samd/mcu/samd51/mpconfigmcu.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ MICROPY_VFS_LFS2 ?= 1
66
MICROPY_VFS_FAT ?= 1
77
FROZEN_MANIFEST ?= mcu/$(MCU_SERIES_LOWER)/manifest.py
88

9-
SRC_S += shared/runtime/gchelper_m3.s
9+
SRC_S += shared/runtime/gchelper_thumb2.s
1010

1111
SRC_C += \
1212
fatfs_port.c \

ports/stm32/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -362,18 +362,18 @@ ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),f0 g0 l0))
362362
CSUPEROPT = -Os # save some code space
363363
SRC_O += \
364364
resethandler_m0.o \
365-
shared/runtime/gchelper_m0.o
365+
shared/runtime/gchelper_thumb1.o
366366
else
367367
ifeq ($(MCU_SERIES),l1)
368368
CFLAGS += -DUSE_HAL_DRIVER
369369
SRC_O += \
370370
resethandler_m3.o \
371-
shared/runtime/gchelper_m3.o
371+
shared/runtime/gchelper_thumb2.o
372372
else
373373
SRC_O += \
374374
system_stm32.o \
375375
resethandler.o \
376-
shared/runtime/gchelper_m3.o
376+
shared/runtime/gchelper_thumb2.o
377377
endif
378378
endif
379379

ports/teensy/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
169169
OBJ += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o))
170170
OBJ += $(addprefix $(BUILD)/, $(SRC_TEENSY:.c=.o))
171171
OBJ += $(addprefix $(BUILD)/, $(SHARED_SRC_C:.c=.o))
172-
OBJ += $(BUILD)/shared/runtime/gchelper_m3.o
172+
OBJ += $(BUILD)/shared/runtime/gchelper_thumb2.o
173173
OBJ += $(GEN_PINS_SRC:.c=.o)
174174

175175
all: hex

shared/runtime/gchelper_generic.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
9898

9999
#elif defined(__thumb2__) || defined(__thumb__) || defined(__arm__)
100100

101-
// Fallback implementation, prefer gchelper_m0.s or gchelper_m3.s
101+
// Fallback implementation, prefer gchelper_thumb1.s or gchelper_thumb2.s
102102

103103
STATIC void gc_helper_get_regs(gc_helper_regs_t arr) {
104104
register long r4 asm ("r4");

shared/runtime/gchelper_m0.s renamed to shared/runtime/gchelper_thumb1.s

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
*/
2626

2727
.syntax unified
28-
.cpu cortex-m0
2928
.thumb
3029

3130
.section .text
@@ -34,6 +33,9 @@
3433
.global gc_helper_get_regs_and_sp
3534
.type gc_helper_get_regs_and_sp, %function
3635

36+
@ This function will compile on processors like Cortex M0 that don't support
37+
@ newer Thumb-2 instructions.
38+
3739
@ uint gc_helper_get_regs_and_sp(r0=uint regs[10])
3840
gc_helper_get_regs_and_sp:
3941
@ store registers into given array

shared/runtime/gchelper_m3.s renamed to shared/runtime/gchelper_thumb2.s

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
*/
2626

2727
.syntax unified
28-
.cpu cortex-m3
2928
.thumb
3029

3130
.section .text
@@ -34,6 +33,8 @@
3433
.global gc_helper_get_regs_and_sp
3534
.type gc_helper_get_regs_and_sp, %function
3635

36+
@ This function requires Thumb-2 instruction support, e.g. Cortex M3/M4.
37+
3738
@ uint gc_helper_get_regs_and_sp(r0=uint regs[10])
3839
gc_helper_get_regs_and_sp:
3940
@ store registers into given array

0 commit comments

Comments
 (0)