Date: Tue, 1 Sep 1998 07:33:33 -0400 (EDT) From: Brian Feldman <green@unixhelp.org> To: current@FreeBSD.ORG Subject: E-day problems: rtld-elf dlsym() broken? Message-ID: <Pine.BSD.4.00.9809010729170.18315-200000@feldman.dyn.ml.org>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
As a start, I'd like to say great job to John Birrell and everyone else
involved, going to ELF worked almost without a hitch, I'm impressed! But
there is a problem now: dlsym, for me, seems to have stopped working.
Entirely.... Returning NULL always it seems. I've attached a program (yes,
it's a start on a basic debugger, I'm implementing rtld functions first)
which should show the problem to anyone interested.
Brian Feldman
green@unixhelp.org
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCM/CS/SS d- s+:+ a--- C++(++++) UB++++ P---- L- E---(+) W+++ N@ o? K- W--- O M- V-- PS+ PE-() Y+ PGP(+) t+ 5-- X++ R+ mtv b++(+++) D+ D++ G e* h(+) r+(-) z-
-------END GEEK CODE BLOCK-----
[-- Attachment #2 --]
/*-
* Copyright (c) 1998 Brian Fundakowski Feldman
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
static const char copyright[] = "@(#) Copyright 1998 Brian Fundakowski Feldman.\
All rights reserved.";
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <readline/readline.h>
#include <readline/history.h>
void doline(char *);
void help(void *);
void copyrightf(void *);
void lookup(void *);
void quit(void *);
int
main(int argc, char **argv) {
char *line;
signal(SIGINT, (sig_t)&exit);
signal(SIGTERM, (sig_t)&exit);
while ((line = readline("(dl) ")) != NULL)
doline(line);
exit(0);
}
struct binds {
char *name;
void (*func)(void *);
char *desc;
};
struct binds bindz[] = {
{ "quit", &quit, "Quit this program." },
{ "help", &help, "Command help." },
{ "copyright", ©rightf, "Copyright info." },
{ "lookup", &lookup, "Look up a symbol." },
};
#define BINDS (sizeof(bindz) / sizeof(struct binds))
void
doline(char *line) {
char c, *d, *oline;
oline = strdup(line);
if ((d = index(oline, ' ')) != (char *)NULL)
*d = 0;
for (c = 0; c < BINDS; c++)
if (!strcmp(oline, bindz[c].name)) {
(*bindz[c].func)(line);
free(oline);
break;
}
if (c == BINDS) {
printf("%s: command unknown\n", line);
free(line);
}
}
void
lookup(void *line) {
void *lameptr;
char *baz;
if ((void *)index(line, '\0') < line + 8 ||
(lameptr = (void *)dlsym(NULL, baz = (char *)line + 7)) == NULL)
printf("%s: not found\n", *baz ? baz : "");
else
printf("%s: 0x%x\n", line + 7, lameptr);
free(line);
}
void
copyrightf(void *line) {
printf("%s\n", copyright + 5);
free(line);
}
void
help(void *line) {
char c;
printf("Help:\n");
for (c = 0; c < BINDS; c++)
printf("\t%s\t%s\n", bindz[c].name, bindz[c].desc);
free(line);
}
void
quit(void *line) {
free(line);
exit(0);
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSD.4.00.9809010729170.18315-200000>
