public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/arm/morello/main] aarch64: morello: add dl-r_debug.h
@ 2022-11-23 14:48 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-11-23 14:48 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=10247e0d2fad3794c8443b78fc39a2e271fe15eb

commit 10247e0d2fad3794c8443b78fc39a2e271fe15eb
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Wed Sep 14 11:25:55 2022 +0100

    aarch64: morello: add dl-r_debug.h
    
    Used internally for r_debug tests, but with the assumption that
    the return value can be dereferenced, so change the prototype
    and return a valid capability.
    
    Also used in pldd, where we only support purecap abi processes.

Diff:
---
 sysdeps/aarch64/morello/dl-r_debug.h | 61 ++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/sysdeps/aarch64/morello/dl-r_debug.h b/sysdeps/aarch64/morello/dl-r_debug.h
new file mode 100644
index 0000000000..827609ff76
--- /dev/null
+++ b/sysdeps/aarch64/morello/dl-r_debug.h
@@ -0,0 +1,61 @@
+/* Function to access r_debug structure.  Morello version.
+   Copyright (C) 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/>.  */
+
+#include <stdint.h>
+#include <link.h>
+
+static int
+E(callback) (struct dl_phdr_info *info, size_t size, void *data)
+{
+  /* Assume phdr covers the load segments.  */
+  const void *phdr = info->dlpi_phdr;
+  uintptr_t *p = data;
+  unsigned long addr = *p;
+  unsigned long base = __builtin_cheri_base_get (phdr);
+  unsigned long len = __builtin_cheri_length_get (phdr);
+  if (addr - base >= len)
+    return 0;
+  *p = __builtin_cheri_address_set ((uintptr_t) phdr, addr);
+  return 1;
+}
+
+/* Return a valid runtime pointer to r_debug instead of an address since
+   that's how this function is used despite its generic prototype.
+   Assume the lookup is for the main exe and return uintptr_t type.  */
+
+static inline uintptr_t
+E(r_debug_address) (ElfW(Dyn) *d)
+{
+  if (d->d_tag != DT_DEBUG)
+    return 0;
+  uintptr_t p = d->d_un.d_ptr;
+  if (dl_iterate_phdr (E(callback), &p) == 1)
+    return p;
+  return 0;
+}
+
+/* Return the offset of the struct r_debug before relocation.  */
+
+static inline EW(Addr)
+E(r_debug_offset) (EW(Dyn) *d, int fd, EW(Addr) offset)
+{
+  if (d->d_tag == DT_DEBUG)
+    return (EW(Addr)) d->d_un.d_ptr;
+
+  return 0;
+}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [glibc/arm/morello/main] aarch64: morello: add dl-r_debug.h
@ 2022-10-27 13:58 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-10-27 13:58 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=fc00799a8d1f3975714c82c351b5c8ff08e7caf9

commit fc00799a8d1f3975714c82c351b5c8ff08e7caf9
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Wed Sep 14 11:25:55 2022 +0100

    aarch64: morello: add dl-r_debug.h
    
    Used internally for r_debug tests, but with the assumption that
    the return value can be dereferenced, so change the prototype
    and return a valid capability.
    
    Also used in pldd, where we only support purecap abi processes.

Diff:
---
 sysdeps/aarch64/morello/dl-r_debug.h | 61 ++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/sysdeps/aarch64/morello/dl-r_debug.h b/sysdeps/aarch64/morello/dl-r_debug.h
new file mode 100644
index 0000000000..827609ff76
--- /dev/null
+++ b/sysdeps/aarch64/morello/dl-r_debug.h
@@ -0,0 +1,61 @@
+/* Function to access r_debug structure.  Morello version.
+   Copyright (C) 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/>.  */
+
+#include <stdint.h>
+#include <link.h>
+
+static int
+E(callback) (struct dl_phdr_info *info, size_t size, void *data)
+{
+  /* Assume phdr covers the load segments.  */
+  const void *phdr = info->dlpi_phdr;
+  uintptr_t *p = data;
+  unsigned long addr = *p;
+  unsigned long base = __builtin_cheri_base_get (phdr);
+  unsigned long len = __builtin_cheri_length_get (phdr);
+  if (addr - base >= len)
+    return 0;
+  *p = __builtin_cheri_address_set ((uintptr_t) phdr, addr);
+  return 1;
+}
+
+/* Return a valid runtime pointer to r_debug instead of an address since
+   that's how this function is used despite its generic prototype.
+   Assume the lookup is for the main exe and return uintptr_t type.  */
+
+static inline uintptr_t
+E(r_debug_address) (ElfW(Dyn) *d)
+{
+  if (d->d_tag != DT_DEBUG)
+    return 0;
+  uintptr_t p = d->d_un.d_ptr;
+  if (dl_iterate_phdr (E(callback), &p) == 1)
+    return p;
+  return 0;
+}
+
+/* Return the offset of the struct r_debug before relocation.  */
+
+static inline EW(Addr)
+E(r_debug_offset) (EW(Dyn) *d, int fd, EW(Addr) offset)
+{
+  if (d->d_tag == DT_DEBUG)
+    return (EW(Addr)) d->d_un.d_ptr;
+
+  return 0;
+}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [glibc/arm/morello/main] aarch64: morello: add dl-r_debug.h
@ 2022-10-26 15:19 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-10-26 15:19 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=30bd81bdab163ecd5866ff6579a69c713975d1b8

commit 30bd81bdab163ecd5866ff6579a69c713975d1b8
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Wed Sep 14 11:25:55 2022 +0100

    aarch64: morello: add dl-r_debug.h
    
    Used internally for r_debug tests, but with the assumption that
    the return value can be dereferenced, so change the prototype
    and return a valid capability.
    
    Also used in pldd, where we only support purecap abi processes.

Diff:
---
 sysdeps/aarch64/morello/dl-r_debug.h | 61 ++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/sysdeps/aarch64/morello/dl-r_debug.h b/sysdeps/aarch64/morello/dl-r_debug.h
new file mode 100644
index 0000000000..827609ff76
--- /dev/null
+++ b/sysdeps/aarch64/morello/dl-r_debug.h
@@ -0,0 +1,61 @@
+/* Function to access r_debug structure.  Morello version.
+   Copyright (C) 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/>.  */
+
+#include <stdint.h>
+#include <link.h>
+
+static int
+E(callback) (struct dl_phdr_info *info, size_t size, void *data)
+{
+  /* Assume phdr covers the load segments.  */
+  const void *phdr = info->dlpi_phdr;
+  uintptr_t *p = data;
+  unsigned long addr = *p;
+  unsigned long base = __builtin_cheri_base_get (phdr);
+  unsigned long len = __builtin_cheri_length_get (phdr);
+  if (addr - base >= len)
+    return 0;
+  *p = __builtin_cheri_address_set ((uintptr_t) phdr, addr);
+  return 1;
+}
+
+/* Return a valid runtime pointer to r_debug instead of an address since
+   that's how this function is used despite its generic prototype.
+   Assume the lookup is for the main exe and return uintptr_t type.  */
+
+static inline uintptr_t
+E(r_debug_address) (ElfW(Dyn) *d)
+{
+  if (d->d_tag != DT_DEBUG)
+    return 0;
+  uintptr_t p = d->d_un.d_ptr;
+  if (dl_iterate_phdr (E(callback), &p) == 1)
+    return p;
+  return 0;
+}
+
+/* Return the offset of the struct r_debug before relocation.  */
+
+static inline EW(Addr)
+E(r_debug_offset) (EW(Dyn) *d, int fd, EW(Addr) offset)
+{
+  if (d->d_tag == DT_DEBUG)
+    return (EW(Addr)) d->d_un.d_ptr;
+
+  return 0;
+}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [glibc/arm/morello/main] aarch64: morello: add dl-r_debug.h
@ 2022-10-12 14:18 Szabolcs Nagy
  0 siblings, 0 replies; 4+ messages in thread
From: Szabolcs Nagy @ 2022-10-12 14:18 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0648dbf3a02cf39029c206d7e6003bb2ec1dce0c

commit 0648dbf3a02cf39029c206d7e6003bb2ec1dce0c
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date:   Wed Sep 14 11:25:55 2022 +0100

    aarch64: morello: add dl-r_debug.h
    
    Used internally for r_debug tests, but with the assumption that
    the return value can be dereferenced, so change the prototype
    and return a valid capability.
    
    Also used in pldd, where we only support purecap abi processes.

Diff:
---
 sysdeps/aarch64/morello/dl-r_debug.h | 61 ++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/sysdeps/aarch64/morello/dl-r_debug.h b/sysdeps/aarch64/morello/dl-r_debug.h
new file mode 100644
index 0000000000..827609ff76
--- /dev/null
+++ b/sysdeps/aarch64/morello/dl-r_debug.h
@@ -0,0 +1,61 @@
+/* Function to access r_debug structure.  Morello version.
+   Copyright (C) 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/>.  */
+
+#include <stdint.h>
+#include <link.h>
+
+static int
+E(callback) (struct dl_phdr_info *info, size_t size, void *data)
+{
+  /* Assume phdr covers the load segments.  */
+  const void *phdr = info->dlpi_phdr;
+  uintptr_t *p = data;
+  unsigned long addr = *p;
+  unsigned long base = __builtin_cheri_base_get (phdr);
+  unsigned long len = __builtin_cheri_length_get (phdr);
+  if (addr - base >= len)
+    return 0;
+  *p = __builtin_cheri_address_set ((uintptr_t) phdr, addr);
+  return 1;
+}
+
+/* Return a valid runtime pointer to r_debug instead of an address since
+   that's how this function is used despite its generic prototype.
+   Assume the lookup is for the main exe and return uintptr_t type.  */
+
+static inline uintptr_t
+E(r_debug_address) (ElfW(Dyn) *d)
+{
+  if (d->d_tag != DT_DEBUG)
+    return 0;
+  uintptr_t p = d->d_un.d_ptr;
+  if (dl_iterate_phdr (E(callback), &p) == 1)
+    return p;
+  return 0;
+}
+
+/* Return the offset of the struct r_debug before relocation.  */
+
+static inline EW(Addr)
+E(r_debug_offset) (EW(Dyn) *d, int fd, EW(Addr) offset)
+{
+  if (d->d_tag == DT_DEBUG)
+    return (EW(Addr)) d->d_un.d_ptr;
+
+  return 0;
+}

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-23 14:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 14:48 [glibc/arm/morello/main] aarch64: morello: add dl-r_debug.h Szabolcs Nagy
  -- strict thread matches above, loose matches on Subject: below --
2022-10-27 13:58 Szabolcs Nagy
2022-10-26 15:19 Szabolcs Nagy
2022-10-12 14:18 Szabolcs Nagy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).