From: "Gilles Depeyrot" <Gilles.Depeyrot@wanadoo.fr>
To: "linuxppc-user" <linuxppc-user@lists.linuxppc.org>,
"linuxppc-dev" <linuxppc-dev@lists.linuxppc.org>
Subject: LinuxPPC1999: shared libraries and dlopen not working ?
Date: Sun, 20 Jun 1999 15:22:25 +0200 [thread overview]
Message-ID: <199906201323.PAA19742@wanadoo.fr> (raw)
[-- Attachment #1: Type: text/plain, Size: 714 bytes --]
Hi,
I'm having trouble getting shared libraries and dlopen to work under
LinuxPPC1999.
I have attached three small files dltest.c, lib1.c and lib2.c. lib1 and
lib2 must be built as shared libraries and dltest as an executable.
The test does the following:
/* dltest
* test functionality of dlopen(), dlsym() and dladdr()
*
* dlopen() test, w/ and w/o .init function
* dlsym() test, can we retrieve address from symbol
* dladdr() test, given an address, can we find where its from
*/
It fails on the first dlopen...
Any help appreciated,
Thanks,
Gilles
--
Gilles Depeyrot <mailto:Gilles.Depeyrot@wanadoo.fr>
<http://perso.wanadoo.fr/gilles.depeyrot>
[-- Attachment #2: lib2.c --]
[-- Type: application/octet-stream, Size: 340 bytes --]
#include "stdio.h"
#define TWIN_GCCINIT
#define LIBENTRY_DECL(entry) void entry() __attribute__ ((constructor))
LIBENTRY_DECL(TWIN_LibEntry_lib2);
int hInstance = 2;
void
TWIN_LibEntry_lib2()
{
printf("lib2 .init function called\n");
return;
}
void
TWIN_LibEntry_common()
{
printf("lib2 TWIN_LibEntry_common function called\n");
}
[-- Attachment #3: lib1.c --]
[-- Type: application/octet-stream, Size: 200 bytes --]
#include "stdio.h"
int hInstance = 1;
void
TWIN_LibEntry_lib1()
{
printf("lib1 .init function called\n");
}
void
TWIN_LibEntry_common()
{
printf("lib1 TWIN_LibEntry_common function called\n");
}
[-- Attachment #4: dltest.c --]
[-- Type: application/octet-stream, Size: 1446 bytes --]
#include "stdio.h"
#include "dlfcn.h"
typedef void (*f)();
/* dltest
* test functionality of dlopen(), dlsym() and dladdr()
*
* dlopen() test, w/ and w/o .init function
* dlsym() test, can we retrieve address from symbol
* dladdr() test, given an address, can we find where its from
*/
int
main(int argc,char **argv)
{
void *hso;
f fp;
int *p;
Dl_info d;
printf("dlopen tests\n");
hso = dlopen("./lib1.so", RTLD_GLOBAL);
if(hso) {
char *entry = "TWIN_LibEntry_lib1";
fp = (f) dlsym(hso, entry);
printf("test1: passed: dlopen(library): no .init function\n");
if(fp) {
(*fp)();
printf("test 2: passed?: dlsym().init function called\n");
} else
printf("test 2 failed\n");
dlclose(hso);
} else
printf("test 1 failed\n");
hso = dlopen("./lib2.so",RTLD_GLOBAL);
if(hso) {
char *entry = "TWIN_LibEntry_common";
printf("test3: passed?: verify lib2 .init function called\n");
fp = (f) dlsym(hso, entry);
if(fp) {
(*fp)();
printf("test4: passed?: verify lib2 common function called\n");
} else
printf("test 4 failed\n");
entry = "hInstance";
p = (int *) dlsym(hso, entry);
printf("test5: passed?: verify %d == 2\n",*p);
memset(&d,0,sizeof(Dl_info));
dladdr(p,&d);
printf("test6: passed?: verify %s == hInstance\n",
d.dli_sname);
printf("file=%s dladdr=%p address=%p\n",
d.dli_fname,d.dli_saddr,p);
dlclose(hso);
}
return 0;
}
next reply other threads:[~1999-06-20 13:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-06-20 13:22 Gilles Depeyrot [this message]
1999-06-20 13:51 ` LinuxPPC1999: shared libraries and dlopen not working ? Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199906201323.PAA19742@wanadoo.fr \
--to=gilles.depeyrot@wanadoo.fr \
--cc=linuxppc-dev@lists.linuxppc.org \
--cc=linuxppc-user@lists.linuxppc.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).