Author Topic: Arm Cortex M4 assembler question  (Read 1224 times)

0 Members and 1 Guest are viewing this topic.

Offline KarelTopic starter

  • Super Contributor
  • ***
  • Posts: 2539
  • Country: 00
Arm Cortex M4 assembler question
« on: November 14, 2025, 10:22:19 am »
asm file for an STM32L4 mcu:

Code: [Select]
  .syntax unified
  .cpu cortex-m4
  .thumb
  .align
  .global t_byte_swap_32
  .global t_byte_swap_16
  .global t_bit_swap_32
  .thumb
  .thumb_func
t_byte_swap_32:
  rev r0, r0
  bx  lr
t_byte_swap_16:
  rev16   r0, r0
  bx  lr
t_bit_swap_32:
  rbit   r0, r0
  bx  lr

compiles fine using the following command:

Code: [Select]
arm-none-eabi-as -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16

but when I call this function from within other c codefiles, the linker produces the following error:

Code: [Select]
arm-none-eabi/bin/ld: release/obj/utils_asm.o(t_byte_swap_16): Unknown destination type (ARM/Thumb) in release/obj/main.o

In the past it seemed to work fine, I don't know what changed, maybe because I use a later version of the compiler...
Code: [Select]
$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (Arm GNU Toolchain 14.3.Rel1 (Build arm-14.174)) 14.3.1 20250623

Any ideas about what I'm doing wrong?
 

Offline KarelTopic starter

  • Super Contributor
  • ***
  • Posts: 2539
  • Country: 00
Re: Arm Cortex M4 assembler question
« Reply #1 on: November 14, 2025, 11:51:02 am »
Solved!

Since binutils 2.44 or higher, assembly functions must include
the assembler directive '.type sym_name, %function', if not
they fail at linking.

https://gcc.gnu.org/pipermail/gcc-help/2025-May/144189.html

 
The following users thanked this post: Foxxz


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf