2

Can I exclude certain addresses inside the code segment in SDCC? For example if my code segment spans from addr. 0x0000 to 0x4000, can I somehow tell the linker/compiler to avoid addr. from 0x2000 to 0x2100 and not place any code there?

The two practical case for this are:

  1. Replacing a ROM with a new (drastically different!) version and wanting to maintain binary compatibility with the old ROM. Certain absolute addresses in the old ROM are called by existing software and I want to provide "compatibility mode", assuring that at least most common jump will still work.
  2. The memory mapped hardware does nasty things to the ROM (such as disabling it!) if I "touch" certain addresses. So I want to make sure no code is ever placed there.

I could create multiple segments and manually allocate functions to them until "full", but I wonder if I can get any help from the compiler / linker? Because the code frequently changes and I don't want to adjust what goes into which segment for every bugfix that increases the size of a function for a few bytes...

Tomaz Stih
  • 529
  • 3
  • 10
  • I think the SDCC linker uses some form of linker scripts (.lnk files), but I don't know exactly what you're able to control with those scripts. Have you tried looking at those files and/or checked if the documentation explains their contents? – Michael Jul 26 '21 at 08:41

0 Answers0