[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: BUG: probs with resolving functions in shared library



Hi Eric !

> thanks for the tip; unfortunately, we *do* need to use the -export-dynamic
> flag with our main executable, so this helps but doesn't solve the problem
> sufficiently to get Applixware for Linux/Alpha any closer to running.  :)

I think the problem is in your head. ;-}
The solution is easy (correct me if not...).
You only must make shure that the main program does **not** need -export-dynamic.
That's really easy (at least here, maybe not for you...)

a) make the main-program a shared library (this step needs (here) no code changes, only
   affects linking stage).

b) use a stub (linked without -export-dynamic) to start the main program (library).

c) run the stub.

Here a sample stub:

/* start stub.c */

#include <stdio.h>
#include <dlfcn.h>

int main(int argc, char **argv) {
	void *handle;
	int (*real_main)(int, char **);
	int rc;

	if((handle = dlopen("./libapplix.so", RTLD_NOW)) == NULL) {
	  fprintf(stderr, "error dlopen: %s\n", dlerror());
	  exit(1);
	}
	if((real_main = dlsym(handle, "main")) == NULL) {
	  fprintf(stderr, "error dlsym: %s\n", dlerror());
	  exit(1);
	}
	rc = (*real_main)(argc, argv);
	dlclose(handle);
	return(rc);
}

/* end stub.c */

Hope it helps (maybe this time...)


> 
> Eric
> 
> Quant-X Alpha Linux Support <stefan@sime.com> writes:
> 
> > I don't know if it helps:
> > 
> > ld -shared -Bdynamic --noinhibit-exec -o libtest2.so test2.o test3.o
> > 
> > works here as expected. (The difference is only that I'm using
> > -Bdynamic instead of -Bsymbolic) 
> > 
> > It is a bug. But ok so.
> > If you want -Bdynamic work as the specs say, you need to compile the main
> > program (!) with -Xlinker -export-dynamic. If you do this, you
> > get the "OOPS!".
> -- 
> Software Development Engineer / ericding@applix.com               <><
> Applix, Inc. / 112 Turnpike Road / Westboro MA 01581-2842
> TEL: (508) 870-0300 x284 / FAX: (508) 366-4873
> 
> -- 
> To unsubscribe: send e-mail to axp-list-request@redhat.com with
> 'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com
> 

  ciao -
    Stefan

-- 

Quant-X Service &                         Ph:  (+43) 4212 6004-0
Consulting Ges.m.b.H.                     Fax: (+43) 4212 600420
http://www.quant-x.com                    Email: support@quant-x.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []