Atilla Filiz
Atilla Filiz

Reputation: 2432

Is is possible to have a linker generate a binary, that is as close to the previously generated one as possible?

Here is the context: I work with microcontrollers, where the resulting binary is written to an internal flash, and executed from there. The flash is erased and written in 4KiB blocks. The flasher is smart enough to skip over blocks that do not need to change.

During development, it is typical to make minor changes and recompile and re-flash dozens of times a day.

What I want to achieve is, if possible, have the linker keep the existing structure as much as possible. For example, if I remove an if-check somewhere, the code gets a few bytes smaller, and all subsequent information becomes shifted by a few bytes, hence the entire flash gets erased and reprogrammed.

If, somehow, the linker was able to add padding between the linked symbols, a big are of the flash could often be skipped without overwriting. This will obviously not work when the code gets bigger.

Are there any gcc options that can help with automating such tasks (without handcrafting massive linker scripts)? Are there any compilers that have at least partial support for such behaviours?

Upvotes: 2

Views: 21

Answers (0)

Related Questions