This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: f build dies with: undefined reference to `lookup_name'


On Wed, Mar 06, 2002 at 05:39:05PM -0500, David Edelsohn wrote:
> 	That means weak_decls now needs to be global, but it is defined in
> varasm.c so we will not have any undefined symbols.

No, the *entire* processing of #pragma weak should be moved.

> Current weak_finish() is run at the end of the file, not each function.

Yeah, so?  Means we'd properly get DECL_WEAK set asap.

Which in fact fixes a bug.  Consider

	#pragma weak a
	int a;
	int foo() { return a; }

	int b __attribute__((weak));
	int bar() { return b; }

Compiled on alpha-linux, with ./cc1 -O -fno-common,

foo:
        ldah $1,a($29)          !gprelhigh
        ldl $0,a($1)            !gprellow
        ret $31,($26),1

bar:
        ldq $1,b($29)           !literal
        ldl $0,0($1)
        ret $31,($26),1

We've miscompiled foo.  It should look like bar, since the weak
binding means that the variable may not be resolved within the
current module.


r~


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