Subject: kern/20423: ARGV[] is broken in FreeBSD binary emulation
To: None <>
From: None <>
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
>Originator:     Shingo WATANABE
>Release:        NetBSD current (1.6O)
NetBSD 1.6O NetBSD 1.6O (X30) #30: Wed Feb 19 15:30:51 JST 2003 i386

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.
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);

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) },
+	  howmany(ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof (Elf32_Addr)),
 	  coredump_elf32 },