gnucap-devel
[Top][All Lists]
Advanced

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

Re: [Gnucap-devel] mingw DLL problem


From: Thomas Sailer
Subject: Re: [Gnucap-devel] mingw DLL problem
Date: Sat, 03 Nov 2007 22:46:06 +0100

On Sat, 2007-11-03 at 15:46 -0400, al davis wrote:

> MS-Windows????????????

Now you have three "x" variables, one in the main program and two in
their respective DLL.

Under windows, access to a variable in the main program and access to a
global variable in a DLL is done by different code sequences, see below.
Given these differences, it's easy to see why the DLL "x" cannot just
replace the main program "x".

But why do you do the - IMO ugly - global variable trick? Why can't you
just use dlsym / GetProcAddress to get the address of y? Or a factory
static function, that allocates the respective object and returns its
address?

Tom

x.c:
extern int x1;
extern int x2 __attribute__((dllimport));

int g1(void) { return x1; }
int g2(void) { return x2; }

        .file   "x.c"
        .text
        .align 2
        .p2align 4,,15
.globl _g1
        .def    _g1;    .scl    2;      .type   32;     .endef
_g1:
        pushl   %ebp
        movl    %esp, %ebp
        movl    _x1, %eax
        popl    %ebp
        ret
        .align 2
        .p2align 4,,15
.globl _g2
        .def    _g2;    .scl    2;      .type   32;     .endef
_g2:
        pushl   %ebp
        movl    __imp__x2, %eax
        movl    %esp, %ebp
        popl    %ebp
        movl    (%eax), %eax
        ret






reply via email to

[Prev in Thread] Current Thread [Next in Thread]