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

Nelson Chu nelson.chu@sifive.com
Fri Sep 20 06:25:00 GMT 2019


Dear Jim,

On Fri, Sep 20, 2019 at 6:23 AM Jim Wilson <jimw@sifive.com> wrote:
> 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.


Thank you for taking the time to help :)

Maybe we will support the auipc relaxation when creating the shared
libraries and pie output in the future, so I have added the comment to
record the above issue in the attached patch.

This patch remove the most redundant `undefined_weak` checking, and
the uninitialized function problem is also resolved when building on
Ubuntu 18.04.

Best Regards
Nelson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-RISC-V-Optimize-lui-and-auipc-relaxations-for-undefw.patch
Type: application/octet-stream
Size: 16444 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20190920/08a7e5d9/attachment.obj>


More information about the Binutils mailing list