mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-28 13:22:48 +00:00
- 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:
parent
7d4774d0ab
commit
39f2a9e2db
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=28434
@ -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))
|
||||
{
|
||||
|
@ -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))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user