summaryrefslogtreecommitdiffstats
path: root/crypto/dso/dso_lib.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2016-10-15 17:01:40 +0200
committerMatt Caswell <matt@openssl.org>2016-11-03 00:32:50 +0100
commitb39eda7ee69a9277c722f8789736e00dc680cda6 (patch)
treeb1ac9b808c0389199750c785bd5c1b5a3189d4c7 /crypto/dso/dso_lib.c
parentPartial revert of 3d8b2ec42 to add back DSO_pathbyaddr (diff)
downloadopenssl-b39eda7ee69a9277c722f8789736e00dc680cda6.tar.xz
openssl-b39eda7ee69a9277c722f8789736e00dc680cda6.zip
Add a DSO_dsobyaddr() function
This works the same way as DSO_pathbyaddr() but instead returns a ptr to the DSO that contains the provided symbol. Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'crypto/dso/dso_lib.c')
-rw-r--r--crypto/dso/dso_lib.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/crypto/dso/dso_lib.c b/crypto/dso/dso_lib.c
index 2dac20082c..52816dfb9d 100644
--- a/crypto/dso/dso_lib.c
+++ b/crypto/dso/dso_lib.c
@@ -73,9 +73,11 @@ int DSO_free(DSO *dso)
return 1;
REF_ASSERT_ISNT(i < 0);
- if ((dso->meth->dso_unload != NULL) && !dso->meth->dso_unload(dso)) {
- DSOerr(DSO_F_DSO_FREE, DSO_R_UNLOAD_FAILED);
- return 0;
+ if ((dso->flags & DSO_FLAG_NO_UNLOAD_ON_FREE) == 0) {
+ if ((dso->meth->dso_unload != NULL) && !dso->meth->dso_unload(dso)) {
+ DSOerr(DSO_F_DSO_FREE, DSO_R_UNLOAD_FAILED);
+ return 0;
+ }
}
if ((dso->meth->finish != NULL) && !dso->meth->finish(dso)) {
@@ -316,6 +318,21 @@ int DSO_pathbyaddr(void *addr, char *path, int sz)
return (*meth->pathbyaddr) (addr, path, sz);
}
+DSO *DSO_dsobyaddr(void *addr, int flags)
+{
+ DSO *ret = NULL;
+ char *filename = NULL;
+ int len = DSO_pathbyaddr(addr, NULL, 0);
+
+ filename = OPENSSL_malloc(len);
+ if (filename != NULL
+ && DSO_pathbyaddr(addr, filename, len) == len)
+ ret = DSO_load(NULL, filename, NULL, flags);
+
+ OPENSSL_free(filename);
+ return ret;
+}
+
void *DSO_global_lookup(const char *name)
{
DSO_METHOD *meth = default_DSO_meth;