076f82
commit 6c9c2307657529e52c5fa7037618835f2a50b916
076f82
Author: John David Anglin <danglin@gcc.gnu.org>
076f82
Date:   Sun Mar 6 16:04:32 2022 +0000
076f82
076f82
    hppa: Fix warnings from _dl_lookup_address
076f82
    
076f82
    This change fixes two warnings from _dl_lookup_address.
076f82
    
076f82
    The first warning comes from dropping the volatile keyword from
076f82
    desc in the call to _dl_read_access_allowed.  We now have a full
076f82
    atomic barrier between loading desc[0] and the access check, so
076f82
    desc no longer needs to be declared as volatile.
076f82
    
076f82
    The second warning comes from the implicit declaration of
076f82
    _dl_fix_reloc_arg.  This is fixed by including dl-runtime.h and
076f82
    declaring _dl_fix_reloc_arg in dl-runtime.h.
076f82
076f82
diff --git a/sysdeps/hppa/dl-fptr.c b/sysdeps/hppa/dl-fptr.c
076f82
index 62ef68b62bd601f4..cd4f77c0ecfd376f 100644
076f82
--- a/sysdeps/hppa/dl-fptr.c
076f82
+++ b/sysdeps/hppa/dl-fptr.c
076f82
@@ -26,6 +26,7 @@
076f82
 #include <ldsodefs.h>
076f82
 #include <elf/dynamic-link.h>
076f82
 #include <dl-fptr.h>
076f82
+#include <dl-runtime.h>
076f82
 #include <dl-unmap-segments.h>
076f82
 #include <atomic.h>
076f82
 #include <libc-pointer-arith.h>
076f82
@@ -351,21 +352,20 @@ _dl_lookup_address (const void *address)
076f82
 {
076f82
   ElfW(Addr) addr = (ElfW(Addr)) address;
076f82
   ElfW(Word) reloc_arg;
076f82
-  volatile unsigned int *desc;
076f82
-  unsigned int *gptr;
076f82
+  unsigned int *desc, *gptr;
076f82
 
076f82
   /* Return ADDR if the least-significant two bits of ADDR are not consistent
076f82
      with ADDR being a linker defined function pointer.  The normal value for
076f82
      a code address in a backtrace is 3.  */
076f82
-  if (((unsigned int) addr & 3) != 2)
076f82
+  if (((uintptr_t) addr & 3) != 2)
076f82
     return addr;
076f82
 
076f82
   /* Handle special case where ADDR points to page 0.  */
076f82
-  if ((unsigned int) addr < 4096)
076f82
+  if ((uintptr_t) addr < 4096)
076f82
     return addr;
076f82
 
076f82
   /* Clear least-significant two bits from descriptor address.  */
076f82
-  desc = (unsigned int *) ((unsigned int) addr & ~3);
076f82
+  desc = (unsigned int *) ((uintptr_t) addr & ~3);
076f82
   if (!_dl_read_access_allowed (desc))
076f82
     return addr;
076f82
 
076f82
@@ -376,7 +376,7 @@ _dl_lookup_address (const void *address)
076f82
   /* Then load first word of candidate descriptor.  It should be a pointer
076f82
      with word alignment and point to memory that can be read.  */
076f82
   gptr = (unsigned int *) desc[0];
076f82
-  if (((unsigned int) gptr & 3) != 0
076f82
+  if (((uintptr_t) gptr & 3) != 0
076f82
       || !_dl_read_access_allowed (gptr))
076f82
     return addr;
076f82
 
076f82
@@ -400,10 +400,11 @@ _dl_lookup_address (const void *address)
076f82
 
076f82
       /* If gp has been resolved, we need to hunt for relocation offset.  */
076f82
       if (!(reloc_arg & PA_GP_RELOC))
076f82
-	reloc_arg = _dl_fix_reloc_arg (addr, l);
076f82
+	reloc_arg = _dl_fix_reloc_arg ((struct fdesc *) addr, l);
076f82
 
076f82
       _dl_fixup (l, reloc_arg);
076f82
     }
076f82
 
076f82
   return (ElfW(Addr)) desc[0];
076f82
 }
076f82
+rtld_hidden_def (_dl_lookup_address)
076f82
diff --git a/sysdeps/hppa/dl-lookupcfg.h b/sysdeps/hppa/dl-lookupcfg.h
076f82
index a9a927f26c6fec09..2f6991aa16e87a00 100644
076f82
--- a/sysdeps/hppa/dl-lookupcfg.h
076f82
+++ b/sysdeps/hppa/dl-lookupcfg.h
076f82
@@ -30,6 +30,7 @@ rtld_hidden_proto (_dl_symbol_address)
076f82
 #define DL_SYMBOL_ADDRESS(map, ref) _dl_symbol_address(map, ref)
076f82
 
076f82
 Elf32_Addr _dl_lookup_address (const void *address);
076f82
+rtld_hidden_proto (_dl_lookup_address)
076f82
 
076f82
 #define DL_LOOKUP_ADDRESS(addr) _dl_lookup_address ((const void *) addr)
076f82
 
076f82
diff --git a/sysdeps/hppa/dl-runtime.c b/sysdeps/hppa/dl-runtime.c
076f82
index e7fbb7417d866bb0..a71b5b2013abf723 100644
076f82
--- a/sysdeps/hppa/dl-runtime.c
076f82
+++ b/sysdeps/hppa/dl-runtime.c
076f82
@@ -25,8 +25,7 @@
076f82
    return that to the caller.  The caller will continue on to call
076f82
    _dl_fixup with the relocation offset.  */
076f82
 
076f82
-ElfW(Word)
076f82
-attribute_hidden __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE
076f82
+ElfW(Word) __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE
076f82
 _dl_fix_reloc_arg (struct fdesc *fptr, struct link_map *l)
076f82
 {
076f82
   Elf32_Addr l_addr, iplt, jmprel, end_jmprel, r_type;
076f82
@@ -52,3 +51,4 @@ _dl_fix_reloc_arg (struct fdesc *fptr, struct link_map *l)
076f82
   ABORT_INSTRUCTION;
076f82
   return 0;
076f82
 }
076f82
+rtld_hidden_def (_dl_fix_reloc_arg)
076f82
diff --git a/sysdeps/hppa/dl-runtime.h b/sysdeps/hppa/dl-runtime.h
076f82
index 5d6ee53b076d5e0e..9913539b5f0e7435 100644
076f82
--- a/sysdeps/hppa/dl-runtime.h
076f82
+++ b/sysdeps/hppa/dl-runtime.h
076f82
@@ -17,6 +17,9 @@
076f82
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
076f82
    02111-1307 USA.  */
076f82
 
076f82
+ElfW(Word) _dl_fix_reloc_arg (struct fdesc *, struct link_map *);
076f82
+rtld_hidden_proto (_dl_fix_reloc_arg)
076f82
+
076f82
 /* Clear PA_GP_RELOC bit in relocation offset.  */
076f82
 static inline uintptr_t
076f82
 reloc_offset (uintptr_t plt0, uintptr_t pltn)