diff --git a/Makefile.am b/Makefile.am index 8af86fd3e..55eb3e687 100644 --- a/Makefile.am +++ b/Makefile.am @@ -318,6 +318,13 @@ tss2_HEADERS += $(srcdir)/include/tss2/tss2_tcti_device.h lib_LTLIBRARIES += $(libtss2_tcti_device) pkgconfig_DATA += lib/tss2-tcti-device.pc +# tcti library for swtpm +if ENABLE_TCTI_SWTPM +libtss2_tcti_swtpm = src/tss2-tcti/libtss2-tcti-swtpm.la +tss2_HEADERS += $(srcdir)/include/tss2/tss2_tcti_swtpm.h +lib_LTLIBRARIES += $(libtss2_tcti_swtpm) +pkgconfig_DATA += lib/tss2-tcti-swtpm.pc + if HAVE_LD_VERSION_SCRIPT src_tss2_tcti_libtss2_tcti_device_la_LDFLAGS = -Wl,--version-script=$(srcdir)/lib/tss2-tcti-device.map endif # HAVE_LD_VERSION_SCRIPT @@ -328,12 +335,6 @@ src_tss2_tcti_libtss2_tcti_device_la_SOURCES = \ endif # ENABLE_TCTI_DEVICE EXTRA_DIST += lib/tss2-tcti-device.map -# tcti library for swtpm -if ENABLE_TCTI_SWTPM -libtss2_tcti_swtpm = src/tss2-tcti/libtss2-tcti-swtpm.la -tss2_HEADERS += $(srcdir)/include/tss2/tss2_tcti_swtpm.h -lib_LTLIBRARIES += $(libtss2_tcti_swtpm) -pkgconfig_DATA += lib/tss2-tcti-swtpm.pc if HAVE_LD_VERSION_SCRIPT src_tss2_tcti_libtss2_tcti_swtpm_la_LDFLAGS = -Wl,--version-script=$(srcdir)/lib/tss2-tcti-swtpm.map diff --git a/src/tss2-tcti/tcti-libtpms.c b/src/tss2-tcti/tcti-libtpms.c index 9c63b777c..19f71b195 100644 --- a/src/tss2-tcti/tcti-libtpms.c +++ b/src/tss2-tcti/tcti-libtpms.c @@ -621,6 +621,7 @@ tcti_libtpms_dl(TSS2_TCTI_LIBTPMS_CONTEXT *tcti_libtpms) const char *names[] = {"libtpms.so", "libtpms.so.0"}; for (size_t i = 0; i < ARRAY_LEN(names); i++) { + LOG_ERROR("XXX 7 %s", names[i]); tcti_libtpms->libtpms = dlopen(names[i], RTLD_LAZY | RTLD_LOCAL); if (tcti_libtpms->libtpms != NULL) { break; diff --git a/src/tss2-tcti/tctildr-dl.c b/src/tss2-tcti/tctildr-dl.c index a2836cfde..6df1275c1 100644 --- a/src/tss2-tcti/tctildr-dl.c +++ b/src/tss2-tcti/tctildr-dl.c @@ -107,6 +107,7 @@ handle_from_name(const char *file, LOG_ERROR("TCTI name truncated in transform."); return TSS2_TCTI_RC_BAD_VALUE; } + LOG_ERROR("XXX 1 %s", file_xfrm); *handle = dlopen(file_xfrm, RTLD_NOW); if (*handle != NULL) { return TSS2_RC_SUCCESS; diff --git a/test-dlopen/dlopen-autotools/AUTHORS b/test-dlopen/dlopen-autotools/AUTHORS new file mode 100644 index 000000000..e69de29bb diff --git a/test-dlopen/dlopen-autotools/COPYING b/test-dlopen/dlopen-autotools/COPYING new file mode 100644 index 000000000..e69de29bb diff --git a/test-dlopen/dlopen-autotools/ChangeLog b/test-dlopen/dlopen-autotools/ChangeLog new file mode 100644 index 000000000..e69de29bb diff --git a/test-dlopen/dlopen-autotools/INSTALL b/test-dlopen/dlopen-autotools/INSTALL new file mode 100644 index 000000000..e69de29bb diff --git a/test-dlopen/dlopen-autotools/Makefile.am b/test-dlopen/dlopen-autotools/Makefile.am new file mode 100644 index 000000000..1dd8c92c0 --- /dev/null +++ b/test-dlopen/dlopen-autotools/Makefile.am @@ -0,0 +1,14 @@ +lib_LTLIBRARIES = libmyfu1.la +libmyfu1_la_SOURCES = myfu1.c +libmyfu1_la_CFLAGS = -fPIC +libmyfu1_la_LDFLAGS = -version-info 1:0:0 -rpath /usr/local/lib +lib_LTLIBRARIES += libmyfu2.la +libmyfu2_la_SOURCES = myfu2.c +libmyfu2_la_CFLAGS = -fPIC +libmyfu2_la_LDFLAGS = -version-info 1:0:0 -rpath /usr/local/lib + +main_LDADD = libmyfu1.la libmyfu2.la -ldl +bin_PROGRAMS = main +main_SOURCES = main.c +main_LDADD += libmyfu1.la +main_LDADD += libmyfu2.la diff --git a/test-dlopen/dlopen-autotools/NEWS b/test-dlopen/dlopen-autotools/NEWS new file mode 100644 index 000000000..e69de29bb diff --git a/test-dlopen/dlopen-autotools/README b/test-dlopen/dlopen-autotools/README new file mode 100644 index 000000000..e69de29bb diff --git a/test-dlopen/dlopen-autotools/configure.ac b/test-dlopen/dlopen-autotools/configure.ac new file mode 100644 index 000000000..993ce0026 --- /dev/null +++ b/test-dlopen/dlopen-autotools/configure.ac @@ -0,0 +1,6 @@ +AC_INIT([MyLib], [1.0], [juergen_repp@web.de]) +AM_INIT_AUTOMAKE +AC_PROG_CC +LT_INIT +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/test-dlopen/dlopen-autotools/main.c b/test-dlopen/dlopen-autotools/main.c new file mode 100644 index 000000000..468b781d2 --- /dev/null +++ b/test-dlopen/dlopen-autotools/main.c @@ -0,0 +1,23 @@ +#include +#include + +void myfu() { + printf("Hello from main myfu!\n"); +} + + +int main() { + void *handle; + handle = dlopen("libmyfu2.so", RTLD_NOW); + myfu(); + void (*myfu)() = (void (*)()) dlsym(handle, "myfu"); + char *error = dlerror(); + if (error) { + fprintf(stderr, "Error finding symbol 'myfu': %s\n", error); + dlclose(handle); + return 1; + } + printf("Calling myfu:\n"); + myfu(); + return 0; +} diff --git a/test-dlopen/dlopen-autotools/myfu.c b/test-dlopen/dlopen-autotools/myfu.c new file mode 100644 index 000000000..0d0f7aa3f --- /dev/null +++ b/test-dlopen/dlopen-autotools/myfu.c @@ -0,0 +1,6 @@ +#include + +// Define the external function +void myfu() { + printf("Hello from so myfu!\n"); +} diff --git a/test-dlopen/dlopen-autotools/myfu1.c b/test-dlopen/dlopen-autotools/myfu1.c new file mode 100644 index 000000000..90c94f4c1 --- /dev/null +++ b/test-dlopen/dlopen-autotools/myfu1.c @@ -0,0 +1,6 @@ +#include + +// Define the external function +void myfu() { + printf("Hello from so1 myfu!\n"); +} diff --git a/test-dlopen/dlopen-autotools/myfu2.c b/test-dlopen/dlopen-autotools/myfu2.c new file mode 100644 index 000000000..a2304c843 --- /dev/null +++ b/test-dlopen/dlopen-autotools/myfu2.c @@ -0,0 +1,6 @@ +#include + +// Define the external function +void myfu() { + printf("Hello from so2 myfu!\n"); +} diff --git a/test-dlopen/dlopen-autotools/run.sh b/test-dlopen/dlopen-autotools/run.sh new file mode 100644 index 000000000..f163f8536 --- /dev/null +++ b/test-dlopen/dlopen-autotools/run.sh @@ -0,0 +1,8 @@ +git clean -xdf +aclocal +libtoolize +autoconf +automake --add-missing +./configure --disable-dependency-tracking +gmake -j +./main diff --git a/test-dlopen/simple-test/main.c b/test-dlopen/simple-test/main.c new file mode 100644 index 000000000..17c4bbd0b --- /dev/null +++ b/test-dlopen/simple-test/main.c @@ -0,0 +1,23 @@ +#include +#include + +void myfu() { + printf("Hello from main myfu!\n"); +} + + +int main() { + void *handle; + handle = dlopen("./libmyfu.so", RTLD_NOW); + myfu(); + void (*myfu)() = (void (*)()) dlsym(handle, "myfu"); + char *error = dlerror(); + if (error) { + fprintf(stderr, "Error finding symbol 'myfu': %s\n", error); + dlclose(handle); + return 1; + } + printf("Calling myfu:\n"); + myfu(); + return 0; +} diff --git a/test-dlopen/simple-test/make.sh b/test-dlopen/simple-test/make.sh new file mode 100644 index 000000000..943de3bd9 --- /dev/null +++ b/test-dlopen/simple-test/make.sh @@ -0,0 +1,2 @@ +clang -fPIC -shared -o libmyfu.so myfu.c +clang -o main_program main.c -ldl diff --git a/test-dlopen/simple-test/myfu.c b/test-dlopen/simple-test/myfu.c new file mode 100644 index 000000000..0d0f7aa3f --- /dev/null +++ b/test-dlopen/simple-test/myfu.c @@ -0,0 +1,6 @@ +#include + +// Define the external function +void myfu() { + printf("Hello from so myfu!\n"); +} diff --git a/tss2-dlopen/tss2-dlopen-fapi.c b/tss2-dlopen/tss2-dlopen-fapi.c index 4d96fbd56..8a256643b 100644 --- a/tss2-dlopen/tss2-dlopen-fapi.c +++ b/tss2-dlopen/tss2-dlopen-fapi.c @@ -41,7 +41,7 @@ init_dlhandle(void) { if (dlhandle) return TSS2_RC_SUCCESS; - dlhandle = dlopen(LIB, RTLD_NOW | RTLD_LOCAL); + dlhandle = dlopen(LIB, RTLD_NOW | RTLD_LOCAL); if (!dlhandle) { WARN("Library " LIB " not found: %s.", dlerror()); return TSS2_FAPI_RC_NOT_IMPLEMENTED;