r_debug.h
new file mode 100644
@@ -0,0 +1,26 @@
+/* Function to access r_debug structure.
+ Copyright (C) 2020-2022 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+static EW(Addr)
+E(r_debug_offset) (EW(Dyn) *d, int, EW(Addr))
+{
+ if (d->d_tag == DT_DEBUG)
+ return (EW(Addr)) d->d_un.d_ptr;
+
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,48 @@
+/* Function to access r_debug structure, MIPS specific version.
+ Copyright (C) 2020-2022 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+static EW(Addr)
+E(r_debug_offset) (EW(Dyn) *d, int memfd, EW(Addr) d_addr)
+{
+ EW(Addr) ptr;
+
+#ifdef R_DEBUG_IN_PROCESS
+ d_addr = (EW(Addr)) d;
+#endif
+
+ switch (d->d_tag)
+ {
+ case DT_MIPS_RLD_MAP_REL:
+ ptr = d_addr + d->d_un.d_val;
+ break;
+ case DT_MIPS_RLD_MAP:
+ ptr = d->d_un.d_ptr;
+ break;
+ default:
+ return 0;
+ }
+
+#ifdef R_DEBUG_IN_PROCESS
+ ptr = *(EW(Addr) *) ptr;
+#else
+ if (pread (memfd, &ptr, sizeof (ptr), ptr) != sizeof (ptr))
+ return 0;
+#endif
+
+ return ptr;
+}