Re: [cc65] Specifying segment for library code?

From: Greg King <>
Date: 2012-06-03 15:37:38
From: "Ullrich von Bassewitz"; on Sun, June 03, 2012; at 07:08 AM -0400
> On Sun, Jun 03, 2012 at 01:15:46AM +0200, Oliver Schmidt wrote:
> > Okay, the original question was:
> >
> > "For example, if I have an overlay that uses strncmp(), but the main
> > program doesn't, it would be nice to be able to tell the linker to
> > link strncmp() to the overlay, and not to the main program."
> >
> > Why does one need any special "magic" to do that? I don't see so.
> > Just linking the overlay against the C library.
> If one understands the question literally, then you're right. But,
> then the answer really doesn't help anybody. If you know in advance
> that your main program doesn't contain strncmp() but the overlay needs
> it, then just linking both against the library will do what you want.
> But in real life, you want the overlay to use *all* of the library
> functions from the main program if they already are there. And, you
> want all others to be linked to the overlay.

It's a little more complex:  A more revealing way to write that last
sentence is, "And, you want all others to be linked _into_ the overlay."
That means that there must be two configuration files.  One file puts
CODE, RODATA, DATA, and BSS at the main memory addresses; while the
other one puts them at the overlay memory addresses.

P.S., Remember to include the "-vm" command-line option when making the
map file.

P.P.S., Be careful about constructors, destructors, and interruptors!
If an overlay calls a function that has one of those actors, and the
main file doesn't call it, then that actor won't be run.

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

This archive was generated by hypermail 2.1.8 : 2012-06-03 15:40:50 CEST