]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
FreeBSD startup: do not skip exename if it is not present
authorPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 25 Nov 2025 20:03:35 +0000 (21:03 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 25 Nov 2025 20:03:35 +0000 (21:03 +0100)
Don't remember why this code was there. Allowing no exename
is a bad idea (argv[0] will be NULL). I don't think there is
a need any more for this permissiveness.

coregrind/m_initimg/initimg-freebsd.c

index 874d129f62db0c5094b0a6f862155e67bd7b0f3a..09f3dda84741ef175b2dd8711c5a6aba81b804a0 100644 (file)
@@ -410,7 +410,6 @@ static Addr setup_client_stack(const void*  init_sp,
    Addr client_SP;           /* client stack base (initial SP) */
    Addr clstack_start;       /* client_SP rounded down to nearest page */
    Int i;
-   Bool have_exename;
    Word client_argv;
 
    vg_assert(VG_IS_PAGE_ALIGNED(clstack_end+1));
@@ -431,7 +430,6 @@ static Addr setup_client_stack(const void*  init_sp,
 
    /* first of all, work out how big the client stack will be */
    stringsize   = 0;
-   have_exename = VG_(args_the_exename) != NULL;
 
    /* paste on the extra args if the loader needs them (ie, the #!
       interpreter and its argument) */
@@ -446,9 +444,7 @@ static Addr setup_client_stack(const void*  init_sp,
    }
 
    /* now scan the args we're given... */
-   if (have_exename) {
-      stringsize += VG_(strlen)( VG_(args_the_exename) ) + 1;
-   }
+   stringsize += VG_(strlen)( VG_(args_the_exename) ) + 1;
 
    for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
       argc++;
@@ -506,7 +502,7 @@ static Addr setup_client_stack(const void*  init_sp,
    /* OK, now we know how big the client stack is */
    used_stacksize =
       sizeof(Word) +                          /* argc */
-      (have_exename ? sizeof(HChar **) : 0) +  /* argc[0] == exename */
+      sizeof(HChar **) +                      /* argc[0] == exename */
       sizeof(HChar **)*argc +                 /* argv */
       sizeof(HChar **) +                      /* terminal NULL */
       sizeof(HChar **)*envc +                 /* envp */
@@ -641,7 +637,7 @@ static Addr setup_client_stack(const void*  init_sp,
    ptr = (Addr*)client_SP;
 
    /* --- client argc --- */
-   *ptr++ = argc + (have_exename ? 1 : 0);
+   *ptr++ = argc + 1;
 
    /* --- client argv --- */
    client_argv = (Word)ptr;
@@ -652,9 +648,7 @@ static Addr setup_client_stack(const void*  init_sp,
       *ptr++ = (Addr)copy_str(&strtab, info->interp_args);
    }
 
-   if (have_exename) {
-      *ptr++ = (Addr)copy_str(&strtab, VG_(args_the_exename));
-   }
+   *ptr++ = (Addr)copy_str(&strtab, VG_(args_the_exename));
 
    for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
       *ptr++ = (Addr)copy_str(