bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undefined use of weak symbols in gnulib


From: Florian Weimer
Subject: Re: Undefined use of weak symbols in gnulib
Date: Wed, 28 Apr 2021 10:35:24 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

* H. J. Lu via Libc-alpha:

> Alan extended the fix to PPC:
>
> commit 954b63d4c8645f86e40c7ef6c6d60acd2bf019de
> Author: Alan Modra <amodra@gmail.com>
> Date:   Wed Apr 19 01:26:57 2017 +0930
>
>     Implement -z dynamic-undefined-weak
>
>     -z nodynamic-undefined-weak is only implemented for x86.  (The sparc
>     backend has some support code but doesn't enable the option by
>     including ld/emulparams/dynamic_undefined_weak.sh, and since the
>     support looks like it may be broken I haven't enabled it.)  This patch
>     adds the complementary -z dynamic-undefined-weak, extends both options
>     to affect building of shared libraries as well as executables, and
>     adds support for the option on powerpc.

I'm not sure if this option is compatible with all compilers on POWER.

The old binutils behavior allowed the compiler to optimize this common
pattern

void f1 (void) __attribute__ ((weak));

void
f2 (void)
{
  if (f1 != 0)
    f1 ();
}

into an unconditional call to f1 because the linker would replace the
call with a NOP if the symbol is undefined, reproducing the effect of
the if condition.  However, GCC 10 does not appear to perform this
optimization on powerpc64le.

Thanks,
Florian




reply via email to

[Prev in Thread] Current Thread [Next in Thread]