This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Misleading linker message
On Fri, Nov 30, 2001 at 01:52:28PM -0800, Geoff Keating wrote:
> > Date: Fri, 30 Nov 2001 13:20:43 -0800
> > From: "H . J . Lu" <hjl@lucon.org>
>
> > # cat foo.c
> > extern void bar ();
> >
> > void (*func) () = bar;
> >
> > _start ()
> > {
> > }
> > # gcc -g foo.c -c
> > # ld -o static foo.o
> > foo.o: In function `_start':
> > /home/hjl/bugs/gas/discard3/foo.c:6: undefined reference to `bar'
> >
> > The line number is totally wrong. In the case of the Linux kernel, ld
> > reports the undefined reference in a totally unrelated source file.
>
> Try it with DWARF2; there are long-standing bugs with stabs and
> changing sections. I think GCC already has a testcase, perhaps
> g++.law/instantiate2.C?
It is even worse:
# /export/build/gnu/gcc/build-i686-linux/gcc/xgcc -B/export/build/gnu/gcc/build-i686-linux/gcc/ -gdwarf-2 -c foo.c
# ld -o static foo.o
foo.o: In function `GNU C 3.1 20011129 (experimental)':
GNU C 3.1 20011129 (experimental)/foo.c:6: undefined reference to `bar'
H.J.