Re: [cc65] Specifying segment for library code?

From: Oliver Schmidt <>
Date: 2012-06-03 16:48:00
Hi Uz,

> But in real life, you want the overlay to use *all* library functions from the
> main program, if they are already there. And you want all others to be linked
> to the overlay. And finally, you want to make this process automatic: If the
> code of the main program changes, and - as an example - two additional library
> functions are now in main, while a third one has been removed, then you want
> your overlays to use the two library functions in main and have the third one
> linked to the overlays if needed instead.

I've quite some experience with a setup like this from Contiki 1.x and
from that perspective I certainly would _not_ suggest anyone to go for
it. As Greg already mentioned contructors/destructors for library code
linked into the overlay aren't run. And even if one would introduce
some mechanism to run them the priority (aka order) wouldn't be
guaranteed. This by no means a hypothetical issue. In Contiki 1.x I
had to add dummy references to certain library functions to the main
module because of that. Therefore I'd classify that approach at best
as fragile.

> Linking them
> in one step - as in your suggestion - will include library functions only
> once, regardless of the actual output target. Which means that code in one
> overlay will try to call the instance of strncmp() that lives in another
> overlay. Which in turn will make your program crash.

Certainly not. The only module with CODE/DATA/RODATA segments is the
main module. Therefore it is guaranteed that all library code is
always available to everybody. Because of the contructor/destructor
issue explained above this setup is from my perspective the only
reasonable one - and therefore it's the only one to be "productized"
as secondary linker configs. This was already discussed and agreed

> Ok, thanks. I feared that it would be a problem on my side, and I'm really
> relieved now :-)

I never said that my "next-release-todo-list" doesn't contain items for me ;-))

To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Jun 3 16:48:17 2012

This archive was generated by hypermail 2.1.8 : 2012-06-03 16:48:21 CEST