about summary refs log tree commit diff
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rw-r--r--misc/Versions3
-rw-r--r--misc/getauxval.c33
-rw-r--r--misc/sys/auxv.h4
3 files changed, 40 insertions, 0 deletions
diff --git a/misc/Versions b/misc/Versions
index d5b348e83a..669a03ffb3 100644
--- a/misc/Versions
+++ b/misc/Versions
@@ -164,6 +164,9 @@ libc {
   GLIBC_2.32 {
     __libc_single_threaded;
   }
+  GLIBC_2.36 {
+    __getauxptr; getauxptr;
+  }
   GLIBC_PRIVATE {
     __madvise;
     __mktemp;
diff --git a/misc/getauxval.c b/misc/getauxval.c
index 714ce5bd62..a4625b8596 100644
--- a/misc/getauxval.c
+++ b/misc/getauxval.c
@@ -20,6 +20,39 @@
 #include <ldsodefs.h>
 #include <stdbool.h>
 
+void *
+__getauxptr (unsigned long int type)
+{
+  /* error if asking for a non-pointer from getauxptr(). This list is not a
+     perfect enforcement as it currently supports both transitional and draft
+     ABIs, which have different capability entries.  */
+  switch (type) {
+    case AT_ENTRY:
+    case AT_PHDR:
+    case AT_BASE:
+    case AT_SYSINFO_EHDR:
+    case AT_EXECFN:
+    case AT_RANDOM:
+    case AT_PLATFORM:
+    case AT_CHERI_EXEC_RW_CAP:
+    case AT_CHERI_EXEC_RX_CAP:
+    case AT_CHERI_INTERP_RW_CAP:
+    case AT_CHERI_INTERP_RX_CAP:
+    case AT_CHERI_SEAL_CAP:
+    {
+      ElfW(auxv_t) *p;
+      for (p = GLRO(dl_auxv); p->a_type != AT_NULL; p++)
+        if (p->a_type == type)
+          return (void *) p->a_un.a_val;
+    }
+  }
+
+  __set_errno (ENOENT);
+  return 0;
+}
+weak_alias (__getauxptr, getauxptr)
+libc_hidden_def (__getauxptr)
+
 bool
 __getauxval2 (unsigned long int type, unsigned long int *result)
 {
diff --git a/misc/sys/auxv.h b/misc/sys/auxv.h
index b5ab30ab77..8446aeddd0 100644
--- a/misc/sys/auxv.h
+++ b/misc/sys/auxv.h
@@ -31,6 +31,10 @@ __BEGIN_DECLS
 extern unsigned long int getauxval (unsigned long int __type)
   __THROW;
 
+/* Same as getauxval, but for Arm Morello capabilities.  */
+extern void * getauxptr (unsigned long int __type)
+  __THROW;
+
 __END_DECLS
 
 #endif /* sys/auxv.h */