Linking additional code for the microcontroller (AVR) against already existing code

The problem definition: There is a need to have two parts of the code in an AVR microcontroller, a fixed one that is always there and does not change (often), and a transient one, that is (not so) often to be replaced or appended. The challenge is to give the ability for the transient code to call functions and access global variables of the fixed one -- and vice versa.

It is quite obvious that there should be special methods for the fixed code to access transient one -- like having calculated function pointers in RAM and using only them to call transient code procedures.

For the calling in backwards direction, I was thinking about linking transient code against existing .elf file of the fixed code.

I'm using avr-gcc toolchain (as in ubuntu 20.20), gcc version 5.4.0

What's I've already tried:

  1. adding '-shared' as a link argument when building fixed code -- appears to be unsupported for AVR (linker reports an error).

  2. adding instead '-Wl,--export-dynamic' as a link argument -- it seems to be ignored, no .dynsym section appears in the elf.

There is still a .symtab section in the fixed code elf -- could that be somehow used to link against it?

Note: my division of 'fixed' and 'transient' code has nothing to do with boot-area of some AVR microcontroller, boot is just something I do not care here about.

Note2: The question is much alike this one, but gives clear explanation for the need.

1 answer

  • answered 2020-11-20 11:44 P__J supports women in Poland

    You have to forget all big computer knowledge. 8 bits AVRs are timy microcontrollers. Code has to be linked statically. There is no other way.