This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Run an image with static library objects placed in a specific execution region

Hi all,

First I want to deliver some background information to the given problem: I'm developing a firmware on a SoC with a cortex-M0 (with Arm Compiler for Embedded 6.21) for a metering device with legally relevant software parts. This means, that after certification a change in the legally part of the firmware is not allowed without re-certification. My idea is, to compile the legally relevant code separately and pack the objects into a static library. This code contains only functions which modify data in a fixed positioned data structure in RAM.

At link time, I want to place all those objects from the library in a specific execution region with use of a scatter file. So far so good, up to this step everything was possible to do for me.

My compiler flags to build the library object user_function.o (it contains only one function: add_num) are:

After this step, I create an archive with armar:

My compiler flags to build the main firmware objects are:

The linker flags to link the whole image are:

My scatter file looks like this:

This ends up in an image like this:

As I said before, this is the result I wanted to achieve. My user_function.o is placed at 0x0001e204. But, if I debug the firmware in gdb, the program runs until my function "add_num" in user_function.o. After that, the program crashes. If I have a look on the disassembly output, it shows:

The output with fromelf -c of user_function.o looks like this:

What am I missing here? My first guess was, that I have to compile location independent code for the lib objects, therefore I added "-fbare-metal-pie". Without success.

I would be very happy about any advice

Thanks in advance

0