From owner-freebsd-hackers Mon Aug 18 15:46:39 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id PAA22975 for hackers-outgoing; Mon, 18 Aug 1997 15:46:39 -0700 (PDT) Received: from austin.polstra.com (austin.polstra.com [206.213.73.10]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id PAA22964 for ; Mon, 18 Aug 1997 15:46:32 -0700 (PDT) Received: from austin.polstra.com (jdp@localhost) by austin.polstra.com (8.8.7/8.8.5) with ESMTP id PAA04812 for ; Mon, 18 Aug 1997 15:46:31 -0700 (PDT) Message-Id: <199708182246.PAA04812@austin.polstra.com> To: hackers@freebsd.org Subject: Re: [Fwd: Re: Please Help Me Understand dlopen()] In-Reply-To: <33F869F3.446B9B3D@FreeBSD.org> References: <33F869F3.446B9B3D@FreeBSD.org> Organization: Polstra & Co., Seattle, WA Date: Mon, 18 Aug 1997 15:46:31 -0700 From: John Polstra Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > Hmmm - any comments, ld hackers? I didn't see it in the newsgroup until Joerg brought it to my attention today. (I don't follow the newsgroups, since I already have all the FREE XXX SEX SITE PASSWORDS and FANTASTIC MEGA-INCOME OPPORTUNITIES that I need at the moment.) I agree that it's a bug, and I followed up there saying I planned to fix it. One fix would be switching to ELF, of course ... ;-) I think the fix should assume that the application most likely wants to look up a normal C symbol. So it should do something like this: /* * First try: look for a normal C symbol like (in assembly * language) "_foo". */ if (sym starts with "_") /* Assume caller already added "_" */ trysym = sym; else /* Add "_" for caller */ trysym = concat("_", sym); /* Not C, but you get the idea */ if (lookup(trysym)) return success; /* * Second try: look for a strange C symbol like (in assembly * language) "__foo", or an assembly language symbol "foo" with no * underscore at all. */ if (sym starts with "_") /* Assume C symbol really starts with "_" */ trysym = concat("_", sym); else /* Assume caller wants assembly symbol */ trysym = sym; if (lookup(trysym)) return success; /* * Give up. */ return failure; No matter what heuristic is used, it could do the wrong thing in some cases. John -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Self-knowledge is always bad news." -- John Barth