This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


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

Re: Versioning mess proved!!!


Roland McGrath <roland@gnu.org> writes:

> I don't follow you.  Geoff is talking about data references, which are
> always relocated at startup.  Such references resolve to zero now even
> though lazy relocation of the corresponding PLT references might later be
> resolved differently after a dlopen(,RTLD_GLOBAL).

There is another twist:

- you can leave the PLT reference unrelocated and simply test whether
  it is weak and undefined.  In this case you return zero.  The problem
  is that, as in the PPC problem, the symbol itself might be undefined
  (marked STB_WEAK with SHN_UNDEF) in which case the reference through
  the function pointer goes into nirvana.

or

- you at this point perform the relocation of the PLT entry (only this one)
  and find out whether there is a reference.  This fails if the necessary
  symbol only gets introduced in the global namespace later with
  dlopen(,RTLD_GLOBAL).

In either way you can end up with wrong results.

> I would hope that the ELF spec (especially the new one you all have been
> working on) would be clear on the correct behavior in these cases.

Well, what is the correct behavior in this case?  The data reference
must resolve to the PLT entry in general since otherwise pointer
comparisons might fail (C semantics demands this; we're not HP who
breaks this assumption).  But if you accept this how do you recognize
at the time you process data relocations whether you actually have a
correct definition?  Given the cases above this is not possible
without breaking something.


More and more I think this is simply a program/compiler problem.  It
must be prohibited to write

	if (&foo)
	  foo ();

Instead you have to write

	__typeof__ (foo) fp = &foo;
	if (fp)
	  fp ();

And the compiler must not try to be clever and transform the fp() call
into a call to foo().

We can easily document this (and change the glibc code which currently
violates this rule).

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------

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