Date: Sat, 20 Feb 1999 21:54:19 +0000 (GMT) From: Terry Lambert <tlambert@primenet.com> To: jdp@polstra.com (John Polstra) Cc: tlambert@primenet.com, hackers@FreeBSD.ORG Subject: Interesting ld.so bug Message-ID: <199902202154.OAA18160@usr08.primenet.com> In-Reply-To: <XFMail.990219163650.jdp@polstra.com> from "John Polstra" at Feb 19, 99 04:36:50 pm
next in thread | previous in thread | raw e-mail | index | archive | help
There appears to be a bug with ld.so. The following steps illustrate
the bug:
Create a shared library A, containing two functions, one dependent on
the other:
int
A( int i)
{
int r;
i++;
r = B( i);
return( r);
}
int
B( int i)
{
int r;
r = i + 2;
return( r);
}
Create a shared library F, containing a function that calls the dependent
function A from the shared library:
int
F( int i)
{
int r;
i++;
r = A( i);
return( r);
}
Link shared library F against shared library A, such that you see
it in the output of:
objdump --all-headers libF.so.1 | grep NEEDS
Create a shared object X; in it, call function F:
void
X( void)
{
int i;
i = F( 5);
printf( "F( 5) is %d\n", i);
}
Link the shared object X against the shared library F, such that you
see it in the output of:
objdump --all-headers X.So | grep NEEDS
Now the fun part:
o create a program that dlopen's X.So, and calls X()
o gdb it
o breakpoint dlopen
o run
o step through until A is called, and note that A is called
correctly
o step until just prior to calling B
o note prior to the call to B that the jump table contains
the correct fixup data; verify this by examining library
libA.so.1 with ``objdump''
o attempt to step through the call to B
o SIGSEGV
Apparently, symbols in indirectly dependent libraries which are
used by the indirectly dependent libraries are not fixed up
correctly. It appears to be a failure to recurse on the leaf
library so that it can self-reference its own symbols.
This was noticed while attempting to implement a JNI in KAFFE,
which uses dlopen's of shared objects to implement JNI.
Terry Lambert
terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199902202154.OAA18160>
