- 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
This commit is contained in:
Nate Williams 1997-08-19 23:33:45 +00:00
parent 7d4774d0ab
commit 39f2a9e2db
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=28434
2 changed files with 60 additions and 4 deletions

View File

@ -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))
{

View File

@ -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))
{