Subject: kern/20423: ARGV[] is broken in FreeBSD binary emulation
To: None <gnats-bugs@gnats.netbsd.org>
From: None <nabe@nabechan.org>
List: netbsd-bugs
Date: 02/19/2003 01:29:37
>Number:         20423
>Category:       kern
>Synopsis:       ARGV[] is broken in FreeBSD binary emulation
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 19 01:30:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Shingo WATANABE
>Release:        NetBSD current (1.6O)
>Organization:
>Environment:
NetBSD think.nabechan.org 1.6O NetBSD 1.6O (X30) #30: Wed Feb 19 15:30:51 JST 2003     nabe@think.nabechan.org:/sys/arch/i386/compile/X30 i386

>Description:
The command line arguments (ARGV[]) is broken when I launch FreeBSD ELF binary on NetBSD with COMPAT_FREEBSD. So I can not get program name (ARGV[0]) and also can not get any command line arguments.
>How-To-Repeat:
compile following program on FreeBSD and launch under NetBSD.

#include <stdio.h>

int main(int ac, char **av)
{
  int i;

  for (i=0; i<ac; i++) {
    printf("argv[%d]: %s\n", i, av[i]);
  }
  return (0);
}

>Fix:
apply following patch to /sys/kern/exec_conf.c


diff -ur /home/nabe/work/cvs/NetBSD/src/sys/kern/exec_conf.c kern/exec_conf.c
--- /home/nabe/work/cvs/NetBSD/src/sys/kern/exec_conf.c	2002-11-30 22:19:37.000000000 +0900
+++ kern/exec_conf.c	2003-01-29 13:11:37.000000000 +0900
@@ -344,7 +344,7 @@
 	  { ELF32NAME2(freebsd,probe) },
 	  &emul_freebsd,
 	  EXECSW_PRIO_ANY,
-	  FREEBSD_ELF_AUX_ARGSIZ,
+	  howmany(ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof (Elf32_Addr)),
 	  elf32_copyargs,
 	  NULL,
 	  coredump_elf32 },

>Release-Note:
>Audit-Trail:
>Unformatted: