summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/ld
diff options
context:
space:
mode:
authornate <nate@FreeBSD.org>1997-08-19 23:33:45 +0000
committernate <nate@FreeBSD.org>1997-08-19 23:33:45 +0000
commit33a318e8321005bc36fe75eb60cb59af809c8b38 (patch)
treec666b371dff6e57cd585a9b4e594c4252050475c /gnu/usr.bin/ld
parent4113dc3c024f6b9aef1de27e6fcaefef324a3676 (diff)
downloadFreeBSD-src-33a318e8321005bc36fe75eb60cb59af809c8b38.zip
FreeBSD-src-33a318e8321005bc36fe75eb60cb59af809c8b38.tar.gz
- In dlsym(), if the lookup fails using the original symbol, prepend an
underscore and try looking it up again. This is a non-issue if we switch to ELF. Reviewed by: sef, jdp
Diffstat (limited to 'gnu/usr.bin/ld')
-rw-r--r--gnu/usr.bin/ld/rtld/rtld.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/gnu/usr.bin/ld/rtld/rtld.c b/gnu/usr.bin/ld/rtld/rtld.c
index ea33fe8..452e6ff 100644
--- a/gnu/usr.bin/ld/rtld/rtld.c
+++ b/gnu/usr.bin/ld/rtld/rtld.c
@@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: rtld.c,v 1.46 1997/02/22 15:46:48 peter Exp $
+ * $Id: rtld.c,v 1.47 1997/08/02 04:56:44 jdp Exp $
*/
#include <sys/param.h>
@@ -1916,7 +1916,7 @@ __dlsym(fd, sym)
}
static void *
-__dlsym3(fd, sym, retaddr)
+resolvesym(fd, sym, retaddr)
void *fd;
char *sym;
void *retaddr;
@@ -1975,6 +1975,34 @@ __dlsym3(fd, sym, retaddr)
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. We assume that most of the time the error is a
+ * undefined symbol error from above, so we try again. If it's
+ * not an undefined symbol we end up getting the same error twice,
+ * but that's acceptable.
+ */
+ if (result == NULL) {
+ /* Prepend an underscore and try again */
+ char *newsym = malloc(strlen(sym) + 2);
+
+ newsym[0] = '_';
+ strcpy(&newsym[1], sym);
+ result = resolvesym(fd, newsym, retaddr);
+ free(newsym);
+ }
+ return result;
+}
+
static char *
__dlerror __P((void))
{
OpenPOWER on IntegriCloud