How to include a linkable object in your project?

I posted how to convert a binary file into a linkable object file in the earlier post, but I didn’t show you how to take it in a project.

This time, I will show you how to take such a converted linkable object in your project.

I think this post will be very short, and to take the object file in the project is very easy.

Prepare a linkable object file

First, you need to prepare a linkable ELF format object file. See the previous post in detail.

Ref. Want to convert a binary data to ARM object file?You can do it easy.

Once you can successfully convert your binary file into ELF format object, you might as well copy it into your project workspace so that you can easily find and access to the file.

Memo: It is important that you need to rename the section section to .rodata section. Otherwise, it will be placed in RAM.
If you want to place it in RAM, you don’t need to do so.
In the case you want to place it in FlashROM, be sure to rename the section.

In case of MCUXpresso IDE

First case is to use MCUXpresso IDE. This is very easy.

All you have to do is to add the linkable object file in the file path of Linker Object as shown below picture.

Tool settings-MCU Linker- Miscellaneous-Other Objects

Enter the binary object
Enter the binary object

That should do it.

In case of IAR EWARM

you need to do a little in case of EWARM. It is better to check the symbol by using “objdump”.

Using the symbol name, you need to put the file name of the raw binary image(linkable object) in the file path. And, you need to put the symbol name as below picture.

In the “Section” area, you might want to put “text” or “readonly” as you renamed the section when you converted it into the linkable object.


That is all.

How to access the binary from C source

You can access to the binary from C source like this.

You can declare the table name as below as the start, end  and size address of the binary file.

extern char _binary_filename_bin_start[];
extern char _binary_filename_bin_end[];
extern char _binary_filename_bin_size[];

Actually, you can use the pointer to access to the binary.

This is all what you need to put the binary object in your project.