Re: [cc65] Linker feature (was: linker bug)

From: Andrew J. Kroll <forge1dr.ea.ms>
Date: 2006-04-28 13:33:12
> 
> 
> On Thu, Apr 27, 2006 at 10:20:48AM -0400, Andrew J. Kroll wrote:
> > The problem is that ld65 sees _main only in object files. It should really
> > not matter if it is inside an archive either. The bug was found while
> > I was tring to link together a program that has a rather large amount of
> > object files, and it is a speedup and easier to link up from a single
> > archive of routines than 30 files.
> 
> It's not a bug, it's a feature:-)
> 
> By default, libraries are only searched once. The problem with your library
> is, that when the linker sees it, there is no reference to a symbol named
> _main. This reference is in the runtime library, which is last on the command
> line, so it is searched at a time, when the linker has already decided it
> doesn't need your module hello.o, containing the symbol _main. You can see
> that from the linker error message
> 
> Unresolved external `_main' referenced in:
>   callmain.s(11)
> 
> callmain.s is none of your modules, so it must be in the runtime library
> (c64.lib or whatever).
> 
> To solve the problem, you need to change the linker search strategy. Within a
> library group, the linker will repeatedly search all libraries until all
> symbols are resolved. So all you have to do is to change the command line and
> place both libraries into one library group:
> 
>         ld65 -t c64 -o hello c64.o -\( hello.lib c64.lib -\)
> 
> (you do not need the backslashes before the parens when using DOSish operating
> systems).
> 

Okay, that makes some amount of sense...

One last ld question then...

When ld65 does a search, does it replace functions from earlier libraries?

For example, if I have a new printf function, which is already in the regular
libc, and I want to replace it with my own, if I link it in AFTER will it 
replace the libc version, or do I link it in BEFORE so that it isn't searched
for in the libc to begin with?

Yours,
-- 
Andrew J. Kroll
Software and Hardware Engineer and Consultant
Grafixoft http://dr.ea.ms/HW/
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Apr 28 13:33:31 2006

This archive was generated by hypermail 2.1.8 : 2006-04-28 13:33:35 CEST