The goal is to migrate from the ARMCC compiler to the TI ARM CLang compiler for an ARM Cortex M0+ device.
The flow used currently for the ARMCC compiler is as follows
- Compile all source files into object files
- Link them with the arm linker to produce an ELF format file
- Input the output from the previous step to the fromelf tool to output a hex32 file that is preloaded into a ROM.
- The hex32 file is ROM Size lines in size
- Each line is 2x 16-bit thumb instructions
To try and replicate this with the tiarmclang compiler, the sequence is:
- Compile all source files into object files. The options used are:
- -std=c99
- -O3
- -g
- -c
- -mcpu=cortex-m0
- -march=thumbv6m
- --target=armv6m-ti-none-eabi
- To link the options passed are:
- -Xlinker --disable_auto_rts
- -Xlinker --search_path=$(CLANG_GENERIC_LIB_DIR)
- -Xlinker <command file that utilizes the MEMORY and SECTIONS directives>
- Pass the output of the previous step to the tiarmhex tool with the following switches:
- --byte
- --binary
The desired output looks roughly like:
One example of the output I am getting looks like:
I have tried all variations as described on the compiler documentation and I have toyed with the ROMS directive inside of a command file. Nothing I have tried has output a file of word aligned thumb machine code.
Thanks in advance for any feedback.
Edit: I have added a zip file that shows an example of the behavior with armcc and the attempts to make that behavior work with clang.