Subject: pkg/9481: shells/bash2 dlsym patch should be conditional on !__ELF__
To: None <gnats-bugs@gnats.netbsd.org>
From: None <John.P.Darrow@wheaton.edu>
List: netbsd-bugs
Date: 02/24/2000 14:07:06
>Number:         9481
>Category:       pkg
>Synopsis:       shells/bash2 dlsym patch should be conditional on !__ELF__
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager (NetBSD software packages system bug manager)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 24 14:06:01 2000
>Last-Modified:
>Originator:     John Darrow
>Organization:
	Computing Services
	Wheaton College, Wheaton, IL
>Release:        pkgsrc up to at least today (2000-02-24)
>Environment:
System: NetBSD jdarrowpiii.wheaton.edu 1.4T NetBSD 1.4T (JDARROW) #0: Thu Feb 24 13:51:53 CST 2000 jdarrow@jdarrowpiii.wheaton.edu:/var/src/sys/arch/i386/compile/JDARROW i386


>Description:
pkgsrc/shells/bash2/patches contains the following patch, patch-ae:

$NetBSD: patch-ae,v 1.3 1998/08/07 11:13:53 agc Exp $

--- builtins/enable.def.orig	Fri Jul 18 15:55:00 1997
+++ builtins/enable.def	Tue Aug  4 21:18:05 1998
@@ -290,9 +290,10 @@
       name = list->word->word;
 
       size = strlen (name);
-      struct_name = xmalloc (size + 8);
-      strcpy (struct_name, name);
-      strcpy (struct_name + size, "_struct");
+      struct_name = xmalloc (size + 9);
+      *struct_name = '_';
+      strcpy (struct_name + 1, name);
+      strcpy (struct_name + size + 1, "_struct");
 
       b = (struct builtin *)dlsym (handle, struct_name);
       if (b == 0)

This patch adds an underscore to the beginning of certain symbols
which are then fed to dlsym.  The patch comes all the way from the
initial import of the FreeBSD bash2 port.  While it is correct for
a.out systems, ELF does not use the initial underscore, and thus
the enable builtin's "load from shared library" function will not work.

(are there other old patches laying around which do the same sort of
thing for other packages?)

>How-To-Repeat:
Examine code.
>Fix:
Either
1. conditionalize the application of the patch on show-shlib-type, or
2. make a conditional within the patch itself, something like this:
(This assumes that anything !ELF requires the underscore... do we build
on anything other than a.out and ELF (e.g. COFF)?)

$NetBSD: patch-ae,v 1.3 1998/08/07 11:13:53 agc Exp $

--- builtins/enable.def.orig	Fri Jul 18 15:55:00 1997
+++ builtins/enable.def	Tue Aug  4 21:18:05 1998
@@ -290,9 +290,16 @@
       name = list->word->word;
 
       size = strlen (name);
+#ifdef __ELF__
       struct_name = xmalloc (size + 8);
       strcpy (struct_name, name);
       strcpy (struct_name + size, "_struct");
+#else
+      struct_name = xmalloc (size + 9);
+      *struct_name = '_';
+      strcpy (struct_name + 1, name);
+      strcpy (struct_name + size + 1, "_struct");
+#endif
 
       b = (struct builtin *)dlsym (handle, struct_name);
       if (b == 0)
>Audit-Trail:
>Unformatted: