This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: Miscompilation of glibc with CVS mainline
Andreas Jaeger <aj@suse.de> writes:
> Jakub Jelinek <jakub@redhat.com> writes:
>
>> On Thu, Jan 02, 2003 at 02:16:01PM +0100, Andreas Jaeger wrote:
>>> I could reproduce this with a simple hello-world program and also with
>>> some smaller program, it is indeed a bug in handling of weak extern
>>> functions.
>>>
>>> Here's a small testcase that has the same behaviour:
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>> extern void weak_func (void *arg);
>>> asm (".weak weak_func");
>>>
>>> void
>>> test (void *arg)
>>> {
>>> if (&weak_func != (void *)0)
>>> weak_func (arg);
>>>
>>> }
>>
>> As GCC is not told in any way that weak_func is actually weak, I think
>> it is glibc's fault.
>> Does:
>> #define weak_extern(x) extern __typeof (x) x __attribute__((weak));
>> work ok?
>
> I'm playing now with:
> # define __pragma_weak(expr) _Pragma(#expr)
> # define _weak_extern(symbol) __pragma_weak("weak " #symbol)
>
> And this works with my small testcase and I've just started
> recompiling glibc with it.
Unfortunately my solution didn't work out, it gave a number of these
warnings:
In file included from ../sysdeps/generic/abort.c:19:
../linuxthreads/sysdeps/pthread/bits/libc-lock.h:312: warning: ignoring #pragma "weak "
../linuxthreads/sysdeps/pthread/bits/libc-lock.h:313: warning: ignoring #pragma "weak "
> I'll try your definition also and let you know about the results,
With your change in, it looked better but I had to disable the alias
for res_init to fix compilation:
res_libc.c:95: error: weak declaration of `__res_init_weak' must precede defininition
make[2]: *** [/builds/glibc/main-gcc3.4/resolv/res_libc.os] Error 1
And add declarations in libc-tsd.h. With these changes everything
compiled but running the testsuite failed directly:
make[2]: *** [/builds/glibc/main-gcc3.4/iconv/tst-iconv1.out] Error 139
Andreas
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj