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