Reputation: 145
I started out with ARM assembly language recently and have assembled two source files model.s and v_bin.s to model.o and v_bin.o respectively; v_bin.s contains a subroutine, and model.s contains the calling code. I wish to link the two object files to an executable. Any ideas?
Upvotes: 2
Views: 899
Reputation: 364593
You need to use .globl my_func
to export the symbol my_func
(defined by a label like my_func:
) so other files can call your my_func
. (GAS manual).
So ld
can match up a reference to my_func
in one .o
with a definition in another .o
.
Then you can link normally by passing multiple .o
files to whatever you normally use to link one into a binary. (e.g. gcc or ld
)
Without .globl
on a symbol name you define, it's private to this object file, like C static
functions and file-scope variables.
Upvotes: 1
Reputation: 923
Simply if you want to link these two files you can run the following to get this done. Assuming you are using arm-none-eabi toolchain and no library dependency.
arm-none-eabi-ld -T your-linker-script.ld -o "app.elf" v_bin.o model.o
A good resource is http://www.martinhubacek.cz/arm/arm-cortex-bare-metal-assembly/stm32f0-cortex-m0-bare-metal-assembly Look at the make file the guy has created
Upvotes: 0