From owner-freebsd-hackers Mon Aug 18 15:50:54 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id PAA23266 for hackers-outgoing; Mon, 18 Aug 1997 15:50:54 -0700 (PDT) Received: from rocky.mt.sri.com (rocky.mt.sri.com [206.127.76.100]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id PAA23261; Mon, 18 Aug 1997 15:50:47 -0700 (PDT) Received: (from nate@localhost) by rocky.mt.sri.com (8.7.5/8.7.3) id QAA03442; Mon, 18 Aug 1997 16:50:44 -0600 (MDT) Date: Mon, 18 Aug 1997 16:50:44 -0600 (MDT) Message-Id: <199708182250.QAA03442@rocky.mt.sri.com> From: Nate Williams MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: Nate Williams Cc: "Jordan K. Hubbard" , hackers@freebsd.org Subject: Re: [Fwd: Re: Please Help Me Understand dlopen()] In-Reply-To: <199708182158.PAA03256@rocky.mt.sri.com> References: <33F869F3.446B9B3D@FreeBSD.org> <199708182158.PAA03256@rocky.mt.sri.com> X-Mailer: VM 6.29 under 19.15 XEmacs Lucid Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > > > The freeBSD dlsym() is - as far as I know - the only dlsym() > > implementation that doesn't search for _funktion() ... > > Here's a quick and dirty patch that implements it. I tested it locally > w/out any problems, but it has lots of possible problems. > > 1) If fails to prepend another underscore if the symbol already is > underscored. > 2) I haven't tested it enough on the entire system. > 3) It might not be the correct solution. > I didn't even send out the original patch, but in any case here's the next version of it, which avoids problem 1 above. Again, it's been lightly tested, but seems to work. The patch is against 2.2-stable. Nate ---------- =================================================================== RCS file: /home/CVS/src/gnu/usr.bin/ld/rtld/rtld.c,v retrieving revision 1.40.2.3 diff -c -r1.40.2.3 rtld.c *** rtld.c 1997/08/08 02:18:14 1.40.2.3 --- rtld.c 1997/08/18 22:48:58 *************** *** 1916,1922 **** } static void * ! __dlsym3(fd, sym, retaddr) void *fd; char *sym; void *retaddr; --- 1916,1922 ---- } static void * ! __resolvesym_(fd, sym, retaddr) void *fd; char *sym; void *retaddr; *************** *** 1973,1978 **** --- 1973,2002 ---- addr += (long)src_map->som_addr; return (void *)addr; + } + + static void * + __dlsym3(fd, sym, retaddr) + void *fd; + char *sym; + void *retaddr; + { + void *result; + + result = __resolvesym_(fd, sym, retaddr); + /* + * XXX - Ugly, but it makes the least impact on the run-time loader + * sources. + */ + if (result == NULL && !strcmp(dlerror_msg, "Undefined symbol")) { + /* Prepend an underscore and try again */ + char *newsym = malloc(strlen(sym) + 1); + + newsym[0] = '_'; + strcpy(&newsym[1], sym); + result = __resolvesym_(fd, newsym, retaddr); + } + return result; } static char * Index: rtld.c