export symbols from dll

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

export symbols from dll

Slava
Hi people,

I seem to miss a very basic piece of the puzzle concerning exporting the  
symbols from dll.

I use latest mingw-w64 (gcc i686-4.9.1-posix-dwarf-rt_v3-rev0, binutils  
2.24).

Here is the simple example:

lib.cpp:
int libfunction()
{
        return 123;
}

Note I do deliberately omit __declspec(dllexport) here. If I compile it:
g++ -g -shared -fvisibility=hidden lib.cpp -o lib.dll  
-Wl,--out-implib,liblib.dll.a

The symbol libfunction() is exported in lib.dll!

> objdump -x lib.dll | grep -A30 export
There is an export table in .edata at 0x61fc7000
...
[Ordinal/Name Pointer] Table
         [   0] _Z11libfunctionv


Or with gendef:
> gendef - lib.dll | c++filt -n
  * [lib.dll] Found PE image
;
; Definition file of lib.dll
; Automatic generated by gendef
; written by Kai Tietz 2008
;
LIBRARY "lib.dll"
EXPORTS
libfunction()

Why the symbol is exported in the dll, although it is not marked for  
dllexport?

Regards, Slava


------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: export symbols from dll

Keith Marshall
On 07/08/14 13:56, Slava wrote:
> Hi people,
>
> I seem to miss a very basic piece of the puzzle concerning exporting the  
> symbols from dll.
>
> I use latest mingw-w64 (gcc i686-4.9.1-posix-dwarf-rt_v3-rev0, binutils  
> 2.24).

So, maybe you should ask on their mailing list, rather than ours.  This
is the list for MinGW.org; we don't (explicitly) support mingw-w64.

> Here is the simple example:
>
> lib.cpp:
> int libfunction()
> {
> return 123;
> }
>
> Note I do deliberately omit __declspec(dllexport) here. If I compile it:
> g++ -g -shared -fvisibility=hidden lib.cpp -o lib.dll  
> -Wl,--out-implib,liblib.dll.a
>
> The symbol libfunction() is exported in lib.dll!

As it should be, according to ld documentation.

> Why the symbol is exported in the dll, although it is not marked for  
> dllexport?

Please search our list archives, or google online ld documentation;
essentially, this is documented behaviour, and I seem to recall having
already answered an almost identical question.

--
Regards,
Keith.

------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: export symbols from dll

David Gressett
In reply to this post by Slava

>I seem to miss a very basic piece of the puzzle concerning exporting the
>symbols from dll.

>I use latest mingw-w64 (gcc i686-4.9.1-posix-dwarf-rt_v3-rev0, binutils
>2.24).

... snip ...

This is the wrong place for your question - mingw-w64 support is a different mailing list.
Look at http://sourceforge.net/p/mingw-w64/mailman/?source=navbar to connect to the right list.

------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: export symbols from dll

Slava
In reply to this post by Keith Marshall
On Thu, 07 Aug 2014 16:18:06 +0200, Keith Marshall  
<[hidden email]> wrote:

>>
>> Note I do deliberately omit __declspec(dllexport) here. If I compile it:
>> g++ -g -shared -fvisibility=hidden lib.cpp -o lib.dll
>> -Wl,--out-implib,liblib.dll.a
>>
>> The symbol libfunction() is exported in lib.dll!
>
> As it should be, according to ld documentation.
>
>> Why the symbol is exported in the dll, although it is not marked for
>> dllexport?
>
> Please search our list archives, or google online ld documentation;
> essentially, this is documented behaviour, and I seem to recall having
> already answered an almost identical question.
>

Ou, thanks you, found the documentation for the linker, which explains the  
behavior
https://sourceware.org/binutils/docs-2.24/ld/WIN32.html#WIN32

// sorry, for mistakenly placed in the wrong mailing list :)

Regards, Slava


------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe