[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dlsym() and C++
Pierre Phaneuf wrote:
> coredumper1.patch is one way to fix it, that was found by simply using
> coredumper2.patch shows how to do it properly (it has to be applied
Oops! By the way, here's the patches!
--
Pierre Phaneuf
Ludus Design, http://ludusdesign.com/
diff -ruN coredumper.orig/coredumper.cpp coredumper/coredumper.cpp
--- coredumper.orig/coredumper.cpp Tue Dec 29 09:21:51 1998
+++ coredumper/coredumper.cpp Sun Jan 17 19:34:17 1999
@@ -3,15 +3,17 @@
#include <dlfcn.h>
#include <iostream.h>
+typedef void (*tsymbol) ();
+
void main()
{
void *handle = dlopen("./libcore.so", RTLD_NOW | RTLD_GLOBAL);
if (handle == NULL) cout << "DAMN" << endl;
- void (*symbol)();
+ tsymbol symbol;
- symbol = dlsym(handle, "ugga");
- (*symbol)();
+ symbol = (tsymbol)dlsym(handle, "ugga__Fv");
+ symbol();
if (handle != NULL) dlclose(handle);
}
diff -ruN coredumper.orig/makeit coredumper/makeit
--- coredumper.orig/makeit Tue Dec 29 09:21:51 1998
+++ coredumper/makeit Sun Jan 17 19:44:57 1999
@@ -7,7 +7,7 @@
echo "C style corelib comp"
-gcc -shared corelib.c -o libcore1.so -export-dynamic -x
+gcc -shared corelib.c -o libcore1.so -export-dynamic -Xlinker -x
echo "C style core dumper comp"
gcc coredumper.c -o coredumper1 -ldl -export-dynamic
diff -ruN coredumper.orig/coredumper.cpp coredumper/coredumper.cpp
--- coredumper.orig/coredumper.cpp Sun Jan 17 19:34:17 1999
+++ coredumper/coredumper.cpp Sun Jan 17 19:46:34 1999
@@ -12,7 +12,7 @@
tsymbol symbol;
- symbol = (tsymbol)dlsym(handle, "ugga__Fv");
+ symbol = (tsymbol)dlsym(handle, "ugga");
symbol();
if (handle != NULL) dlclose(handle);
diff -ruN coredumper.orig/corelib.cpp coredumper/corelib.cpp
--- coredumper.orig/corelib.cpp Tue Dec 29 09:21:51 1998
+++ coredumper/corelib.cpp Sun Jan 17 19:56:50 1999
@@ -4,6 +4,8 @@
void ugga7(int);
void ugga7(int,int);
+extern "C" void ugga();
+
//extern "C"
//{
void ugga()