3

I am writing code for embedded platform. I need to link with 3rd party SDK. However, the symbols from that SDK should go into specific section (not .text). Is it possible to do that?

I use GNU-based toolchain for xtensa-lx106 processor and build for ESP8266 chip.

mpromonet
  • 11,326
  • 43
  • 62
  • 91
RostakaGmfun
  • 487
  • 6
  • 21

1 Answers1

3

To do so you have to modify the linker script that you're using.

You'll likely find it in your makefile in the line that links the final binary. The linker script is the file passed via the -T option.

Once you have this, open it in a text editor and search for the SECTION directive. You'll likely find a group called .text in it which lists all sections that should go into the final text segment.

You can just add the code-section name of the SDK to this list. You can even use wildcards if the SDK has multiple sections with a common prefix (that happends quite a lot).

The same thing can be done using the .data group and the .bss group if nessesary.

After these modifications you can re-link your executable and the sections from the SDK library should go straight into the .text and .data groups.

If you want to, you can also create new groups in the MEMORY declaration at the top of the linker file. That gives you direct control over the exact address that the linker will use. You can then redirect the SDK library sections right into the new memory regions that you've created and you have the libs always at the same address.

Nils Pipenbrinck
  • 83,631
  • 31
  • 151
  • 221