[1/2] powerpc: Initialize rtld_global_ro for static dlopen [BZ #20802]

Message ID 20200110222743.79551-1-tuliom@linux.ibm.com
State Committed
Delegated to: Carlos O'Donell
Headers

Commit Message

Tulio Magno Quites Machado Filho Jan. 10, 2020, 10:27 p.m. UTC
  Notice this patch is required in order to let the static dlopen test
from the next patch to work.

----8<----

Initialize dl_auxv, dl_hwcap and dl_hwcap2 in rtld_global_ro for DSOs
that have been statically dlopen'ed.
---
 sysdeps/unix/sysv/linux/powerpc/dl-static.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
  

Comments

Carlos O'Donell Jan. 16, 2020, 4:21 p.m. UTC | #1
On 1/10/20 5:27 PM, Tulio Magno Quites Machado Filho wrote:
> Notice this patch is required in order to let the static dlopen test
> from the next patch to work.

OK for master. Please check with Siddhesh about committing this.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ----8<----
> 
> Initialize dl_auxv, dl_hwcap and dl_hwcap2 in rtld_global_ro for DSOs
> that have been statically dlopen'ed.
> ---
>  sysdeps/unix/sysv/linux/powerpc/dl-static.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/powerpc/dl-static.c b/sysdeps/unix/sysv/linux/powerpc/dl-static.c
> index 48fec16dca..59ce4e8972 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/dl-static.c
> +++ b/sysdeps/unix/sysv/linux/powerpc/dl-static.c
> @@ -26,17 +26,26 @@ _dl_var_init (void *array[])
>    /* It has to match "variables" below. */
>    enum
>      {
> -      DL_PAGESIZE = 0
> +      DL_PAGESIZE = 0,
> +      DL_AUXV = 1,
> +      DL_HWCAP = 2,
> +      DL_HWCAP2 = 3,

OK. Add auxv, hwcap and hwcap2 in that order.

>      };
>  
>    GLRO(dl_pagesize) = *((size_t *) array[DL_PAGESIZE]);
> +  GLRO(dl_auxv) = (ElfW(auxv_t) *) *((size_t *) array[DL_AUXV]);
> +  GLRO(dl_hwcap)  = *((unsigned long int *) array[DL_HWCAP]);
> +  GLRO(dl_hwcap2) = *((unsigned long int *) array[DL_HWCAP2]);

OK. Matches order above for auxv, hwcap, and hwcap2.

>  }
>  
>  #else
>  
>  static void *variables[] =
>  {
> -  &GLRO(dl_pagesize)
> +  &GLRO(dl_pagesize),
> +  &GLRO(dl_auxv),
> +  &GLRO(dl_hwcap),
> +  &GLRO(dl_hwcap2),

OK. Matches order above.

>  };
>  
>  static void
>
  
Siddhesh Poyarekar Jan. 16, 2020, 4:25 p.m. UTC | #2
On 16/01/20 9:51 pm, Carlos O'Donell wrote:
> On 1/10/20 5:27 PM, Tulio Magno Quites Machado Filho wrote:
>> Notice this patch is required in order to let the static dlopen test
>> from the next patch to work.
> 
> OK for master. Please check with Siddhesh about committing this.
> 
> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
> 

Fine with me.

Siddhesh
  

Patch

diff --git a/sysdeps/unix/sysv/linux/powerpc/dl-static.c b/sysdeps/unix/sysv/linux/powerpc/dl-static.c
index 48fec16dca..59ce4e8972 100644
--- a/sysdeps/unix/sysv/linux/powerpc/dl-static.c
+++ b/sysdeps/unix/sysv/linux/powerpc/dl-static.c
@@ -26,17 +26,26 @@  _dl_var_init (void *array[])
   /* It has to match "variables" below. */
   enum
     {
-      DL_PAGESIZE = 0
+      DL_PAGESIZE = 0,
+      DL_AUXV = 1,
+      DL_HWCAP = 2,
+      DL_HWCAP2 = 3,
     };
 
   GLRO(dl_pagesize) = *((size_t *) array[DL_PAGESIZE]);
+  GLRO(dl_auxv) = (ElfW(auxv_t) *) *((size_t *) array[DL_AUXV]);
+  GLRO(dl_hwcap)  = *((unsigned long int *) array[DL_HWCAP]);
+  GLRO(dl_hwcap2) = *((unsigned long int *) array[DL_HWCAP2]);
 }
 
 #else
 
 static void *variables[] =
 {
-  &GLRO(dl_pagesize)
+  &GLRO(dl_pagesize),
+  &GLRO(dl_auxv),
+  &GLRO(dl_hwcap),
+  &GLRO(dl_hwcap2),
 };
 
 static void