This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Confusing behaviour from gcc and ld with --as-needed


On Mon, Apr 04, 2005 at 08:31:56PM +0100, Mike Hearn wrote:
> On Mon, 2005-04-04 at 14:24 -0400, Daniel Jacobowitz wrote:
> > Try adding -v to those command lines to see what's going on?
> 
> Well, that shows what I expected:
> 
> /usr/libexec/gcc/i386-redhat-linux/3.4.2/collect2 --eh-frame-hdr -m
> elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o vfolder-
> magic /usr/lib/gcc/i386-redhat-
> linux/3.4.2/../../../crt1.o /usr/lib/gcc/i386-redhat-
> linux/3.4.2/../../../crti.o /usr/lib/gcc/i386-redhat-
> linux/3.4.2/crtbegin.o -L/usr/lib -L/usr/lib/gcc/i386-redhat-linux/3.4.2
> -L/usr/lib/gcc/i386-redhat-linux/3.4.2 -L/usr/lib/gcc/i386-redhat-
> linux/3.4.2/../../.. --as-needed -lxml -lz vfolder-magic.o -lgcc --as-
> needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-
> needed /usr/lib/gcc/i386-redhat-linux/3.4.2/crtend.o /usr/lib/gcc/i386-
> redhat-linux/3.4.2/../../../crtn.o
> 
> I think I see now why it doesn't work: --as-needed must make the
> decision based on what source files it's seen so far as it parses it. So
> it sees "-lxml" and says "nothing used that so far, so we'll drop it".
> Then the object file is linked into the file binary, and we end up with
> unresolved references because the DT_NEEDED entry was dropped too early.

This is not what's supposed to happen.  Are there undefined references?
There was no link error in your first mail.

What version of ld are you using?  Have you tried a more recent one?

-- 
Daniel Jacobowitz
CodeSourcery, LLC


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]