NetBSD Problem Report #33220

From www@netbsd.org  Sat Apr  8 18:28:25 2006
Return-Path: <www@netbsd.org>
Received: by narn.netbsd.org (Postfix, from userid 31301)
	id 8A50463B9C2; Sat,  8 Apr 2006 18:28:25 +0000 (UTC)
Message-Id: <20060408182825.8A50463B9C2@narn.netbsd.org>
Date: Sat,  8 Apr 2006 18:28:25 +0000 (UTC)
From: taviso@sdf.lonestar.org
Reply-To: taviso@sdf.lonestar.org
To: gnats-bugs@netbsd.org
Subject: bash builtins cannot access bash symbols
X-Send-Pr-Version: www-1.0

>Number:         33220
>Category:       pkg
>Synopsis:       bash builtins cannot access bash symbols
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    joerg
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Apr 08 18:30:00 +0000 2006
>Closed-Date:    Fri May 26 14:17:10 +0000 2006
>Last-Modified:  Fri May 26 14:17:10 +0000 2006
>Originator:     Tavis Ormandy
>Release:        NetBSD 2.1.0_STABLE
>Organization:
none
>Environment:
NetBSD sdf 2.1.0_STABLE NetBSD 2.1.0_STABLE (sdf) #0: Tue Mar 14 07:50:31 UTC 2006  root@sverige:/var/src/src/sys/arch/alpha/compile/sdf alpha
>Description:
The bash shell allows you to write builtins and store them in a shared object, which are then loaded using the enable command. On NetBSD, this doesnt work as symbols that bash exports, such as make_builtin_argv() and last_pid_created are not available. This works on three linux systems I tested.
>How-To-Repeat:

#include <stdio.h>
#include <stdlib.h>

/* This file is also available here http://dev.gentoo.org/~taviso/builtin.c if the formatting does not survive
 * $ gcc -shared -o builtin.so builtin.c 
 * $ enable -f ./builtin.so btest
 * $ btest
 * bash: enable: cannot open shared object ./builtin.so: ./builtin.so: Undefined symbol "make_builtin_argv" (symnum = 21)
 */

typedef struct word_desc { char *word; int flags;} WORD_DESC;
typedef struct word_list { struct word_list *next; WORD_DESC *word;}  WORD_LIST;
typedef int sh_builtin_func_t (WORD_LIST *);
int btest(WORD_LIST *list);
char **make_builtin_argv (WORD_LIST *list, int *argc);

struct builtin { 
    char *name;
    sh_builtin_func_t *function;
    int flags;
    char * const *doc;
    const char *shortdoc;
    char *handle;
};

char *btestusage[] = { "btest prints hello and exits", 0x00 };
struct builtin btest_struct = { "btest", btest, 1, btestusage, "btest", 0x00 };

int btest(WORD_LIST *list){ 
    int argc;
    char **argv;

    if (!(argv = (char **) make_builtin_argv (list, &argc)))
        return 1;

    fprintf(stdout, "hello from %s\n", argv[0]);

    free(argv);

    return 42;
}

>Fix:

>Release-Note:

>Audit-Trail:
From: joerg@britannica.bec.de
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/33220: bash builtins cannot access bash symbols
Date: Sat, 8 Apr 2006 21:13:34 +0200

 --FL5UXtIhxfXey3p5
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 On Sat, Apr 08, 2006 at 06:30:00PM +0000, taviso@sdf.lonestar.org wrote:
 > >Description:
 > The bash shell allows you to write builtins and store them in a shared
 > object, which are then loaded using the enable command. On NetBSD, this
 > doesnt work as symbols that bash exports, such as make_builtin_argv()
 > and last_pid_created are not available. This works on three linux systems
 > I tested.

 I don't know what the Linux systems do, but bash on NetBSD gives exactly
 the results the default build systems create. It does *not* export the
 symbols at all.

 Try the attached patch.

 Joerg

 --FL5UXtIhxfXey3p5
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="bash-export.diff"

 Index: Makefile
 ===================================================================
 RCS file: /cvsroot/pkgsrc/shells/bash/Makefile,v
 retrieving revision 1.20
 diff -u -r1.20 Makefile
 --- Makefile	5 Mar 2006 16:27:28 -0000	1.20
 +++ Makefile	8 Apr 2006 19:13:22 -0000
 @@ -22,6 +22,7 @@
  USE_PKGLOCALEDIR=	yes
  GNU_CONFIGURE=		yes
  MAKE_ENV+=		INSTALL_SCRIPT=${INSTALL_SCRIPT:Q}
 +MAKE_ENV+=		LOCAL_LDFLAGS=-Wl,-export-dynamic
  CPPFLAGS+=		-DDEFAULT_PATH_VALUE="\"/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin\""
  TEST_TARGET=		test


 --FL5UXtIhxfXey3p5--

Responsible-Changed-From-To: pkg-manager->joerg
Responsible-Changed-By: cube@netbsd.org
Responsible-Changed-When: Sun, 09 Apr 2006 18:17:50 +0000
Responsible-Changed-Why:
joerg proposed a patch.


From: Joerg Sonnenberger <joerg@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: PR/33220 CVS commit: pkgsrc/shells/bash
Date: Fri, 26 May 2006 14:12:01 +0000 (UTC)

 Module Name:	pkgsrc
 Committed By:	joerg
 Date:		Fri May 26 14:12:01 UTC 2006

 Modified Files:
 	pkgsrc/shells/bash: Makefile

 Log Message:
 Export dynamic symbols for plugins. Fixes PR 33220.


 To generate a diff of this commit:
 cvs rdiff -r1.23 -r1.24 pkgsrc/shells/bash/Makefile

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: joerg@netbsd.org
State-Changed-When: Fri, 26 May 2006 14:17:10 +0000
State-Changed-Why:
Fix committed.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.