Author: brooks
Date: Wed Apr 15 20:26:41 2020
New Revision: 359990
URL: https://svnweb.freebsd.org/changeset/base/359990

Log:
  Support AT_PS_STRINGS in _elf_aux_info().
  
  This will be used by setproctitle().
  
  Reviewed by:  kib
  Obtained from:        CheriBSD
  Sponsored by: DARPA
  Differential Revision:        https://reviews.freebsd.org/D24407

Modified:
  head/lib/libc/gen/auxv.c

Modified: head/lib/libc/gen/auxv.c
==============================================================================
--- head/lib/libc/gen/auxv.c    Wed Apr 15 20:25:38 2020        (r359989)
+++ head/lib/libc/gen/auxv.c    Wed Apr 15 20:26:41 2020        (r359990)
@@ -70,7 +70,7 @@ static pthread_once_t aux_once = PTHREAD_ONCE_INIT;
 static int pagesize, osreldate, canary_len, ncpus, pagesizes_len, bsdflags;
 static int hwcap_present, hwcap2_present;
 static char *canary, *pagesizes, *execpath;
-static void *timekeep;
+static void *ps_strings, *timekeep;
 static u_long hwcap, hwcap2;
 
 #ifdef __powerpc__
@@ -135,6 +135,10 @@ init_aux(void)
                case AT_TIMEKEEP:
                        timekeep = aux->a_un.a_ptr;
                        break;
+
+               case AT_PS_STRINGS:
+                       ps_strings = aux->a_un.a_ptr;
+                       break;
 #ifdef __powerpc__
                /*
                 * Since AT_STACKPROT is always set, and the common
@@ -334,6 +338,16 @@ _elf_aux_info(int aux, void *buf, int buflen)
                if (buflen == sizeof(int)) {
                        *(int *)buf = bsdflags;
                        res = 0;
+               } else
+                       res = EINVAL;
+               break;
+       case AT_PS_STRINGS:
+               if (buflen == sizeof(void *)) {
+                       if (ps_strings != NULL) {
+                               *(void **)buf = ps_strings;
+                               res = 0;
+                       } else
+                               res = ENOENT;
                } else
                        res = EINVAL;
                break;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to