This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: ld definitely not discarding unreferenced routines
- From: Alan Modra <amodra at gmail dot com>
- To: Alex Buell <alex dot buell at munted dot org dot uk>
- Cc: binutils at sourceware dot org
- Date: Mon, 19 Jul 2010 10:45:35 +0930
- Subject: Re: ld definitely not discarding unreferenced routines
- References: <1279460964.23488.12.camel@lithium.local.net>
On Sun, Jul 18, 2010 at 02:49:24PM +0100, Alex Buell wrote:
> In the common library archive (libcommon.a), there are two main
> routines. One is 16 bit and the other is 32 bit. Linking part1.bin
> should only pull in the 16 bit routine from the library, whilst linking
> part2.bin should do the same for the 32 bit routine.
You put both functions in one object file. ld extracts from archives
on a file by file basis to satisfy undefined symbols. ld is working
exactly as designed.
If you must put both functions in one object file for some reason,
then you'll need to link with -gc-sections, *and* put the functions in
separate sections. Garbage collection works on a section by section
basis.
--
Alan Modra
Australia Development Lab, IBM