Philippe Gerum kirjoitti:
Heikki Lindholm wrote:

Philippe Gerum kirjoitti:

Heikki Lindholm wrote:

libpthread_rt won't produce usable exec apps on ppc64 if it uses --wrap.
There seems to be no reason to use --wrap for building the lib itself.




Good catch for the lib flags. However, substituting __real calls with the genuine ones seems wrong to me. You'd just end up causing the same issue.



I don't think so. Although, I'm not sure how ld is supposed to handle --wrap case for libraries, this works in the dynamic case, at least, for the ppc32 and ppc64 (tested on debian sarge and gentoo ppc64), whereas leaving the __real*'s in dynamic library will fail with unrelocatable symbols.


Ok, that's another issue. We still need to call __real entry points, but we also have to care for the specific issue of dynamic linking which does not substitute the calls:

Excerpt from ld's info page, talking about wrapping malloc:

You may wish to provide a `__real_malloc' function as well, so that
     links without the `--wrap' option will succeed.  If you do this,
     you should not put the definition of `__real_malloc' in the same
     file as `__wrap_malloc'; if you do, the assembler may resolve the
     call before the linker has a chance to wrap it to `malloc'.

So we need a separate .c file glued to the lib, which basically does:

__real_foo ()
{
    foo();
}

For all __real symbols referenced.

Right. Indeed, it seems to be the case that --wrap does not work the same way for dynamic linking as static. Fortunately, there aren't too many __real's used in there.

-- Heikki


Reply via email to