[PATCH] RISC-V: Optimize lui and auipc relaxations for undefweak symbols

Jim Wilson jimw@sifive.com
Thu Sep 19 22:23:00 GMT 2019


On Thu, Sep 19, 2019 at 3:37 AM Nelson Chu <nelson.chu@sifive.com> wrote:

>
>
> *At first I thought that toolchain will use GOT and PLT if creating a
> shared library.Therefore, there is no harm without checking the above case
> I thought.But you are right, there may have some exceptions, and caution is
> the parent of safety :)*
>

Now that I had a little more time to look at this, it turns out that the
RISC-V port doesn't support the -z [no]dynamic-undefined-weak option.  This
is an optional feature, and only the x86 and ppc ports provide it.  I
hacked support for it in, and then noticed that we don't relax pcrel relocs
when creating shared libraries and pie output.  Also, the auipc sequence
used in pic code results in a local symbol for the addi, and you are only
setting undefined_weak for global symbols.  So the problem I was worried
about can't happen, even if we did have support for -z
[no]dynamic-undefined-weak.  So you can forget about the
UNDEF_NO_DYNAMIC_RELOC comment, it isn't relevant to your patch.

Jim



More information about the Binutils mailing list