[v2,0/2] riscv: add support for GNU indirect function

Message ID 1608023800-14560-1-git-send-email-vincent.chen@sifive.com
Headers
Series riscv: add support for GNU indirect function |

Message

Vincent Chen Dec. 15, 2020, 9:16 a.m. UTC
  The riscv Binutils supported GNU indirect function in the commit 
02dd9d25. To make the entire mechanism work, these patches adds the
required ports to enable Glibc to address the IRELATIVE relocation.

Because the dynamic linker resolves the IRELATIVE relocation before
jumping into the executable program, the $gp register is not initialized
when executing the IFUNC resolver function. It may cause some unexpected
error to occur when the dynamic loader resolves the IREALTIVE relocation
of the position-dependent executable program. To solve this issue, the
second patch enables dynamic linker to look for the __global_pointer$
symbol and use it to initialize $gp before resolving the IREALTIVE
relocation of the PDE program.


Changes since v1:
1. Move the riscv entry to the end of libc-abis file
2. Add the second input argument to IFUNC resolver to preserve the
   extension flexibility
3. Enable ld.so to initilize $gp by __global_pointer$ symbol instead
   of the DT_RISCV_GP dynamic entry to avoid to modify the riscv ELF
   psABI specification.


Vincent Chen (2):
  riscv: support GNU indirect function
  riscv: Initialize $gp before resolving the IRELATIVE relocation

 libc-abis                  |  1 +
 sysdeps/riscv/dl-irel.h    | 56 ++++++++++++++++++++++++++++++++++++++
 sysdeps/riscv/dl-machine.h | 44 +++++++++++++++++++++++++++++-
 3 files changed, 100 insertions(+), 1 deletion(-)
 create mode 100644 sysdeps/riscv/dl-irel.h
  

Comments

Vincent Chen Jan. 4, 2021, 1:38 a.m. UTC | #1
On Tue, Dec 15, 2020 at 5:16 PM Vincent Chen <vincent.chen@sifive.com> wrote:
>
> The riscv Binutils supported GNU indirect function in the commit
> 02dd9d25. To make the entire mechanism work, these patches adds the
> required ports to enable Glibc to address the IRELATIVE relocation.
>
> Because the dynamic linker resolves the IRELATIVE relocation before
> jumping into the executable program, the $gp register is not initialized
> when executing the IFUNC resolver function. It may cause some unexpected
> error to occur when the dynamic loader resolves the IREALTIVE relocation
> of the position-dependent executable program. To solve this issue, the
> second patch enables dynamic linker to look for the __global_pointer$
> symbol and use it to initialize $gp before resolving the IREALTIVE
> relocation of the PDE program.
>
>
> Changes since v1:
> 1. Move the riscv entry to the end of libc-abis file
> 2. Add the second input argument to IFUNC resolver to preserve the
>    extension flexibility
> 3. Enable ld.so to initilize $gp by __global_pointer$ symbol instead
>    of the DT_RISCV_GP dynamic entry to avoid to modify the riscv ELF
>    psABI specification.
>

Gentle ping on this series. Thanks and happy new year.

>
> Vincent Chen (2):
>   riscv: support GNU indirect function
>   riscv: Initialize $gp before resolving the IRELATIVE relocation
>
>  libc-abis                  |  1 +
>  sysdeps/riscv/dl-irel.h    | 56 ++++++++++++++++++++++++++++++++++++++
>  sysdeps/riscv/dl-machine.h | 44 +++++++++++++++++++++++++++++-
>  3 files changed, 100 insertions(+), 1 deletion(-)
>  create mode 100644 sysdeps/riscv/dl-irel.h
>
> --
> 2.29.2
>
  
Jim Wilson Jan. 5, 2021, 1:53 a.m. UTC | #2
On Sun, Jan 3, 2021 at 5:38 PM Vincent Chen <vincent.chen@sifive.com> wrote:

> Gentle ping on this series. Thanks and happy new year.
>

This is on the release blockers list at my request, so hopefully it will
get looked at before the release.
    https://sourceware.org/glibc/wiki/Release/2.33#Release_blockers.3F

Jim
  
Nelson Chu Jan. 5, 2021, 3:13 a.m. UTC | #3
On Tue, Jan 5, 2021 at 9:53 AM Jim Wilson <jimw@sifive.com> wrote:
> This is on the release blockers list at my request, so hopefully it will get looked at before the release.
>     https://sourceware.org/glibc/wiki/Release/2.33#Release_blockers.3F

Thank you very much, Jim.

> 3. Enable ld.so to initilize $gp by __global_pointer$ symbol instead
> of the DT_RISCV_GP dynamic entry to avoid to modify the riscv ELF

The binutils commit 18b9872261b950a8d10a4ae6ccb8f2acdaebc3e6 is
committed, so this should work when updating the mainline binutils.

Thanks
Nelson
   psABI specification.
  
Carlos O'Donell Jan. 5, 2021, 12:32 p.m. UTC | #4
On 1/4/21 8:53 PM, Jim Wilson wrote:
> On Sun, Jan 3, 2021 at 5:38 PM Vincent Chen <vincent.chen@sifive.com> wrote:
> 
>> Gentle ping on this series. Thanks and happy new year.
>>
> 
> This is on the release blockers list at my request, so hopefully it will
> get looked at before the release.
>     https://sourceware.org/glibc/wiki/Release/2.33#Release_blockers.3F

The patches were discussed on the Monday patch review meeting.

I've asked DJ to help move these along.

I have confidence that we will get to them before the release.
  
Vincent Chen Jan. 6, 2021, 12:53 a.m. UTC | #5
On Tue, Jan 5, 2021 at 8:32 PM Carlos O'Donell <carlos@redhat.com> wrote:
>
> On 1/4/21 8:53 PM, Jim Wilson wrote:
> > On Sun, Jan 3, 2021 at 5:38 PM Vincent Chen <vincent.chen@sifive.com> wrote:
> >
> >> Gentle ping on this series. Thanks and happy new year.
> >>
> >
> > This is on the release blockers list at my request, so hopefully it will
> > get looked at before the release.
> >     https://sourceware.org/glibc/wiki/Release/2.33#Release_blockers.3F
>
> The patches were discussed on the Monday patch review meeting.
>
> I've asked DJ to help move these along.
>
> I have confidence that we will get to them before the release.
>

Glad to hear this information. Thanks to the people who have given me
help on this patch set.

Best Regards
Vincent Chen
  
Nelson Chu Jan. 11, 2021, 7:34 a.m. UTC | #6
Thank you all !

Nelson

On Mon, Jan 11, 2021 at 10:29 AM DJ Delorie <dj@redhat.com> wrote:
>
> Vincent Chen <vincent.chen@sifive.com> writes:
> > Gentle ping on this series. Thanks and happy new year.
>
> Series committed.  Thanks!
>