简体   繁体   中英

GCC-ARM: Make a jump in C to a linker section instead to a absolute address

I have a SW that is divided into two binaries (loaded in different memories).

Therefore I have two linker files.

A binary runs and loads the second binary in the other memory, and this second runs.

There is a function that both codes use, and it is loaded in RAM by the first one, so in the second I make the call to this function really a JUMP to the address where it is loaded in RAM (in the linker file of the first SW I have defined a specific section where I force this function to be loaded).

Currently, this mechanism works for me correctly.

My question is, is it possible to jump to a tag or symbol instead of the specific address?

Ideally, in my linker file I would define the address with a tag, and in the code I would refer to that tag.

That is, both the compiler and the linker would understand that tag and translate it to the address.

So if I change the address in the linker I would not have to change also in the JUMP instruction.

Many thanks

NOTE: gcc-arm-none-eabi-4_9-2015q3

Accessing Linker Sections directly from C code

NOLOAD directive

Splitting linker files in two and using both for linking (the question's answer has an example of that)

You can use NOLOAD in App2 (while loading it normally in App1) to know about the function, but not load it, and then access it as mentioned in the first link.

If you wanted to play around with preprocessor macros and compilation/linking options, you could have an additional linker file that is shared between both apps, but conditionally loads sections based on the switches. This would help you avoid repeating the address in both linker files (eg App1 would be linked using ld1 + ldshared , App2 using ld1 + ldshared with different switches ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM