Date: Mon, 18 Aug 1997 16:50:44 -0600 (MDT) From: Nate Williams <nate@mt.sri.com> To: Nate Williams <nate@mt.sri.com> Cc: "Jordan K. Hubbard" <jkh@freebsd.org>, hackers@freebsd.org Subject: Re: [Fwd: Re: Please Help Me Understand dlopen()] Message-ID: <199708182250.QAA03442@rocky.mt.sri.com> In-Reply-To: <199708182158.PAA03256@rocky.mt.sri.com> References: <33F869F3.446B9B3D@FreeBSD.org> <199708182158.PAA03256@rocky.mt.sri.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> > > > 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199708182250.QAA03442>