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'


>>>>> Richard Henderson writes:

Richard> You can't look up decls from varasm.c.  You have to have
Richard> them passed down to you.

	The whole problem, and what Alan is trying to get around, is that
one may not know the DECL at the time one sees the #pragma weak.  This is
why I had my ugly patch to c-pragma.c differentiating identifiers from
strings, which also did not work in all cases covered by Alan's patch.

	One wants to be able to say

#pragma weak foo
extern int foo(void);

int main (void)
{
  if (foo)
    return (*foo) ();
  return 0;
}

At the point that the pragma is parsed, one has not seen the DECL for foo.
GCC's attribute extension weakens the DECL, but #pragma weak just puts the
string on a list.  Even if we walk the weak list when creating any DECL to
mark it weak if we have seen a #pragma weak, we still need to be able to
find the DECL again when we finish the weak symbols if the weak symbol was
not already emitted.

	The names of the symbols that need to be weakened need to be
deferred as long as possible, which is why Alan is looking up the names in
weak_finish when GCC is about to emit the symbols.  That is the point
where we have committed to emitting the symbol names and have our last
chance to find a DECL corresponding to the string.  Otherwise, we are back
to weakening strings without any knowledge of a DECL to which it might
correspond.

Thanks, David


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