[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gcl-devel] [PATCH 09/11] Avoid looking up dynamic symbols in the execut
From: |
Will Newton |
Subject: |
[Gcl-devel] [PATCH 09/11] Avoid looking up dynamic symbols in the executable |
Date: |
Wed, 11 Jun 2014 17:27:22 +0100 |
From: Will Newton <address@hidden>
Currently it is possible to have failures where package libgmp
or package saved_pre_gcl is not found. The reason for this is that
dlsym will return the address of a PLT entry in the executable
if the executable has an undefined reference to that symbol.
This patch attempts to fix the problem in two ways. First,
avoid dlopening the empty string as this returns a handle for
the executable and starts the search there. Second, start the
search in the next object in the list using RTLD_NEXT.
---
gcl/lsp/gcl_dl.lsp | 4 ++--
gcl/o/cfun.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/gcl/lsp/gcl_dl.lsp b/gcl/lsp/gcl_dl.lsp
index 0c108cb..b8ae3b5 100644
--- a/gcl/lsp/gcl_dl.lsp
+++ b/gcl/lsp/gcl_dl.lsp
@@ -13,9 +13,9 @@
(dladdr-set adp ad)
(dllist-push %memory sym adp)))
-(defun mdlsym (str &optional (n "" np))
+(defun mdlsym (str &optional (n ""))
(let* ((pk (or (find-package "LIB") (make-package "LIB")))
- (k (if np (dlopen n) 0))
+ (k (if (string/= n "") (dlopen n) 0))
(ad (dlsym k str))
(p (or (pathname-name (dladdr ad)) ""))
(psym (intern p pk))
diff --git a/gcl/o/cfun.c b/gcl/o/cfun.c
index 593ee92..794ea81 100644
--- a/gcl/o/cfun.c
+++ b/gcl/o/cfun.c
@@ -88,7 +88,7 @@ DEFUN("DLSYM",object,fSdlsym,SI,2,2,NONE,OI,OO,OO,OO,(fixnum
h,object name),"")
RETURN1(make_fixnum((fixnum)ad));
}
}
- ad=dlsym(RTLD_DEFAULT,name->st.st_self);
+ ad=dlsym(RTLD_NEXT,name->st.st_self);
if ((er=dlerror()))
FEerror("dlsym lookup failure on ~s: ~s",2,name,make_simple_string(er));
name->st.st_self[name->st.st_fillp]=ch;
--
1.9.3
- [Gcl-devel] [PATCH 00/11] Add support for AArch64, Will Newton, 2014/06/11
- [Gcl-devel] [PATCH 01/11] config.{sub, guess}: Update to latest versions of GNU config, Will Newton, 2014/06/11
- [Gcl-devel] [PATCH 03/11] Add support for AArch64, Will Newton, 2014/06/11
- [Gcl-devel] [PATCH 04/11] Reorder code to avoid problems with dis-asm.h defining DEFUN., Will Newton, 2014/06/11
- [Gcl-devel] [PATCH 02/11] o/main.c: Ensure cs_org is always pointer aligned, Will Newton, 2014/06/11
- [Gcl-devel] [PATCH 06/11] Check for preceding NULL in find_init_name1, Will Newton, 2014/06/11
- [Gcl-devel] [PATCH 07/11] Fix handling of varargs in sSuniversal_error_handler, Will Newton, 2014/06/11
- [Gcl-devel] [PATCH 05/11] Always pass a va_list as the last arg of call_proc_new, Will Newton, 2014/06/11
- [Gcl-devel] [PATCH 10/11] Reduce threshold for increasing maxpage, Will Newton, 2014/06/11
- [Gcl-devel] [PATCH 09/11] Avoid looking up dynamic symbols in the executable,
Will Newton <=
- [Gcl-devel] [PATCH 08/11] Handle dladdr failure correctly, Will Newton, 2014/06/11
- [Gcl-devel] [PATCH 11/11] Hack to disable x86 floating point code, Will Newton, 2014/06/11
- Re: [Gcl-devel] [PATCH 00/11] Add support for AArch64, Camm Maguire, 2014/06/11