This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Linker script to resolve common symbols.
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Jason Algol <slashdotcommacolon at hotmail dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Fri, 15 Aug 2003 10:03:30 +0930
- Subject: Re: Linker script to resolve common symbols.
- References: <Law15-F78oifeD6tono000351a5@hotmail.com>
On Thu, Aug 14, 2003 at 10:56:15AM +0000, Jason Algol wrote:
> Hi there, im investigating a way to "teach" the linker about certain
> references and how to resolve them
>
> for example, i have a c program that uses gzread() from zlib, when i
> compile it i might get a message like
>
> undefined reference to `gzread'
>
> would it be possible to edit the linker script to know that if gzread is
> undefined, libz.a must be added to the list of files to link (this is just
> an example), so that i wouldnt need to use -lz, but it only links with libz
> if nescessary.
Write a program that runs ld and scans its output. Provide some means
for your program to map undefined refs to libs. On finding an undefined
ref, rerun ld with the extra lib.
--
Alan Modra
IBM OzLabs - Linux Technology Centre