4c1956
commit acdcca72940e060270e4e54d9c0457398110f409
4c1956
Author: John David Anglin <danglin@gcc.gnu.org>
4c1956
Date:   Mon Mar 30 21:58:06 2020 +0000
4c1956
4c1956
    Add new file missed in previous hppa commit.
4c1956
4c1956
diff --git a/sysdeps/hppa/dl-runtime.c b/sysdeps/hppa/dl-runtime.c
4c1956
new file mode 100644
4c1956
index 0000000000000000..885a3f1837cbc56d
4c1956
--- /dev/null
4c1956
+++ b/sysdeps/hppa/dl-runtime.c
4c1956
@@ -0,0 +1,58 @@
4c1956
+/* On-demand PLT fixup for shared objects.  HPPA version.
4c1956
+   Copyright (C) 2019 Free Software Foundation, Inc.
4c1956
+   This file is part of the GNU C Library.
4c1956
+
4c1956
+   The GNU C Library is free software; you can redistribute it and/or
4c1956
+   modify it under the terms of the GNU Lesser General Public
4c1956
+   License as published by the Free Software Foundation; either
4c1956
+   version 2.1 of the License, or (at your option) any later version.
4c1956
+
4c1956
+   The GNU C Library is distributed in the hope that it will be useful,
4c1956
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
4c1956
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c1956
+   Lesser General Public License for more details.
4c1956
+
4c1956
+   You should have received a copy of the GNU Lesser General Public
4c1956
+   License along with the GNU C Library; if not, write to the Free
4c1956
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4c1956
+   02111-1307 USA.  */
4c1956
+
4c1956
+/* Clear PA_GP_RELOC bit in relocation offset.  */
4c1956
+#define reloc_offset (reloc_arg & ~PA_GP_RELOC)
4c1956
+#define reloc_index  (reloc_arg & ~PA_GP_RELOC) / sizeof (PLTREL)
4c1956
+
4c1956
+#include <elf/dl-runtime.c>
4c1956
+
4c1956
+/* The caller has encountered a partially relocated function descriptor.
4c1956
+   The gp of the descriptor has been updated, but not the ip.  We find
4c1956
+   the function descriptor again and compute the relocation offset and
4c1956
+   return that to the caller.  The caller will continue on to call
4c1956
+   _dl_fixup with the relocation offset.  */
4c1956
+
4c1956
+ElfW(Word)
4c1956
+attribute_hidden __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE
4c1956
+_dl_fix_reloc_arg (struct fdesc *fptr, struct link_map *l)
4c1956
+{
4c1956
+  Elf32_Addr l_addr, iplt, jmprel, end_jmprel, r_type;
4c1956
+  const Elf32_Rela *reloc;
4c1956
+
4c1956
+  l_addr = l->l_addr;
4c1956
+  jmprel = D_PTR(l, l_info[DT_JMPREL]);
4c1956
+  end_jmprel = jmprel + l->l_info[DT_PLTRELSZ]->d_un.d_val;
4c1956
+
4c1956
+  /* Look for the entry...  */
4c1956
+  for (iplt = jmprel; iplt < end_jmprel; iplt += sizeof (Elf32_Rela))
4c1956
+    {
4c1956
+      reloc = (const Elf32_Rela *) iplt;
4c1956
+      r_type = ELF32_R_TYPE (reloc->r_info);
4c1956
+
4c1956
+      if (__builtin_expect (r_type == R_PARISC_IPLT, 1)
4c1956
+	  && fptr == (struct fdesc *) (reloc->r_offset + l_addr))
4c1956
+	/* Found entry. Return the reloc offset.  */
4c1956
+	return iplt - jmprel;
4c1956
+    }
4c1956
+
4c1956
+  /* Crash if we weren't passed a valid function pointer.  */
4c1956
+  ABORT_INSTRUCTION;
4c1956
+  return 0;
4c1956
+}