This is the mail archive of the
cygwin-xfree@cygwin.com
mailing list for the Cygwin XFree86 project.
RE: [XFree86-4.2.0] Now that we have an improved ld, please makelibXt a shared library.
- From: Alexander Gottwald <Alexander dot Gottwald at s1999 dot tu-chemnitz dot de>
- To: cygwin-xfree at cygwin dot com
- Date: Mon, 28 Jul 2003 23:16:12 +0200 (MEST)
- Subject: RE: [XFree86-4.2.0] Now that we have an improved ld, please makelibXt a shared library.
- References: <003401c35538$eaebfe50$0a1c440a@BRAMSCHE>
- Reply-to: cygwin-xfree at cygwin dot com
Ralf Habacker wrote:
> Hi Alexander,
>
> >
> > for libXt it uses the direct address. For every other library using
> > the libXt.dll it uses the address from the stub.
>
> I see, this is another case. Please take a look into xc/lib/xt/Initialize.c and
> xc/lib/xt/sharedlib.c which provides such a case for another os. I don't
> understand the xfree build system very well, so I can't provide a working
> solution for this, but in fact _XtInherit() should be located in the xt import
> library, which references __XtInherit() which is located in the real xt dll.
I played with this too.
What we need is a possibility to
- link libXt that _XtInherit is taken from the import lib
-> impossible (AFAIK). The import lib is created _after_ all symbols got
resolved (hen-egg-problem)
- use everywhere the same pointer. The shared lib could get the pointer via
a function call.
typedef void (*func)(void);
func __XtInheritFunc() { return _XtInherit(); }
#define _XtInherit __XtInheritFunc()
This works until someone uses
struct x {
func foo = _XtInherit;
}
The linker would normally resolve the symbol. But with the function call
we have a situation where the static structure requires a dynamic call.
Maybe I've missed something. But it seems to me that
we need the real address of _XtInherit at linktime which is not known to
the linker when building the shared library because libXt might get
relocated.
I've found a working solution
--test.h--
typedef void (*func)(void);
extern func f;
extern int test(func f);
extern int test1(void);
extern int test2(void);
--test1.c--
#include "test.h"
#include <stdio.h>
void __f(void) { printf("f\n"); return; }
func f = __f;
int test(func f2) { return f == f2; }
int test1(void) { f(); return test(f); }
--test2.c--
#include "test.h"
#include <stdio.h>
int test2(void) { f(); return test(f); }
int main() {
printf("test1: %d\n", test1());
printf("test2: %d\n", test2());
}
----------
$ gcc --shared -out-implib=test1.dll.a -Wl,--enable-auto-import,--enable-runtime-pseudo-reloc -o test1.dll test1.c
Creating library file: test1.dll.a
$ gcc -o test2.exe test2.c test1.dll test1.dll.a
Info: resolving _f by linking to __imp__f (auto-import)
$ ./test2.exe
f
test1: 1
f
test2: 1
I'll try this with libXt
bye
ago
NP: Deine Lakaien - Return
--
Alexander.Gottwald@informatik.tu-chemnitz.de
http://www.gotti.org ICQ: 126018723