All symbols exported from shared library?

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

All symbols exported from shared library?

Stephen Kelly
Hi there,

After reading

  http://www.mingw.org/wiki/sampleDLL

I tried to create a dll and use it, cross compiling on ubuntu. I simplified
the example code somewhat.


$ cat lib.h

#ifdef BUILDING_EXAMPLE_DLL
#define EXAMPLE_DLL __declspec(dllexport)
#else
#define EXAMPLE_DLL __declspec(dllimport)
#endif

int myveryeasymethod(void);

$ cat lib.c

#include "lib.h"

int myveryeasymethod(void)
{ return 42; }

$ cat main.c

#include <stdio.h>

#include "lib.h"

int main()
{
   printf("HELLO %d\n", myveryeasymethod());
   return 0;
}

$ i686-w64-mingw32-gcc-4.6 -c lib.c

$ i686-w64-mingw32-gcc-4.6  -shared -o example_dll.dll lib.o -Wl,--out-
implib,libexample_dll.a

$ i686-w64-mingw32-gcc-4.6  -c main.c

$ i686-w64-mingw32-gcc-4.6  -o example.exe main.o example_dll.dll

$ wine example.exe
HELLO 42


Note that I did not actually dllexport the symbol from the library, so I
expect linking errors when building the executable, and I expect it not to
run.

Does mingw export everything by default? Can that be turned off? Or is
something else going on?

Thanks,

Steve.


------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
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: All symbols exported from shared library?

Pau Garcia i Quiles
Hi,

Check this:


The KDE export headers already implement such logic, using one of them as the reference would be a good idea :-)


On Sun, May 19, 2013 at 10:36 PM, Stephen Kelly <[hidden email]> wrote:
Hi there,

After reading

  http://www.mingw.org/wiki/sampleDLL

I tried to create a dll and use it, cross compiling on ubuntu. I simplified
the example code somewhat.


$ cat lib.h

#ifdef BUILDING_EXAMPLE_DLL
#define EXAMPLE_DLL __declspec(dllexport)
#else
#define EXAMPLE_DLL __declspec(dllimport)
#endif

int myveryeasymethod(void);

$ cat lib.c

#include "lib.h"

int myveryeasymethod(void)
{ return 42; }

$ cat main.c

#include <stdio.h>

#include "lib.h"

int main()
{
   printf("HELLO %d\n", myveryeasymethod());
   return 0;
}

$ i686-w64-mingw32-gcc-4.6 -c lib.c

$ i686-w64-mingw32-gcc-4.6  -shared -o example_dll.dll lib.o -Wl,--out-
implib,libexample_dll.a

$ i686-w64-mingw32-gcc-4.6  -c main.c

$ i686-w64-mingw32-gcc-4.6  -o example.exe main.o example_dll.dll

$ wine example.exe
HELLO 42


Note that I did not actually dllexport the symbol from the library, so I
expect linking errors when building the executable, and I expect it not to
run.

Does mingw export everything by default? Can that be turned off? Or is
something else going on?

Thanks,

Steve.


------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
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



--
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)

------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
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: All symbols exported from shared library?

Keith Marshall
In reply to this post by Stephen Kelly
On 19/05/13 21:36, Stephen Kelly wrote:
> Does mingw export everything by default?

Yes, if you don't qualify *any* symbol with the dllexport attribute,
this is exactly what happens.

> Can that be turned off?

As soon as you so qualify just *one* symbol, then only those which are
qualified with the dllexport attribute will be exposed.

--
Regards,
Keith.

------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
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: All symbols exported from shared library?

lrn-2
In reply to this post by Pau Garcia i Quiles
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 20.05.2013 00:40, Pau Garcia i Quiles wrote:

> On Sun, May 19, 2013 at 10:36 PM, Stephen Kelly wrote:
>> Does mingw export everything by default? Can that be turned off? Or is
>> something else going on?
>
> Check this:
>
> http://gcc.gnu.org/wiki/Visibility
>
> The KDE export headers already implement such logic, using one of
> them as the reference would be a good idea :-)
>
GTK+ also recently switched to explicit symbol visibility (check git
master HEAD). That allowed GTK to completely remove .def files from the
source tree.

- --
O< ascii ribbon - stop html email! - www.asciiribbon.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)

iQEcBAEBAgAGBQJRmVKYAAoJEOs4Jb6SI2CwbfkIALC4+xMBDa7Q/Cx4H+mjaW9E
yR4BSHFrTRNSMQzvQqdWrrmS4ZnMg9wvGnJXSxShrtN34v8i8ZKqtmKvtArQpWTv
lCzXU5xH4sPzULYvMgMGklzwweeFZc7otp+IV0pqtLKGRIDkQDT4tn+fXOqFqHDb
Je5BnSI+306DGYrHpjrSYyNTMvu22UypVDBeUGoPUMmj6svqOC5IIl84WxATU5+u
sPienzYyrtxrWSPyTwiMH1nqT1TBRYa6EbuJCgFtDRDV/wgTuSLyI1AnzBwW03IY
omxjuOe5avAuyYohDXrNFwKpPfITP6ktXhkRX5cohcRozn0OkRbfQ5QZ5eLLdUo=
=d+dI
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
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: All symbols exported from shared library?

Stephen Kelly
In reply to this post by Stephen Kelly
Keith Marshall wrote:

 > On 19/05/13 21:36, Stephen Kelly wrote:
 >> Does mingw export everything by default?
 >
 > Yes, if you don't qualify *any* symbol with the dllexport attribute,
 > this is exactly what happens.
 >
 >> Can that be turned off?
 >
 > As soon as you so qualify just *one* symbol, then only those which are
 > qualified with the dllexport attribute will be exposed.
 >

Great, thanks!

Maybe a note could be added to the docs page with that information.

Thanks,

Steve.

------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
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: All symbols exported from shared library?

Earnie Boyd
On Mon, May 20, 2013 at 3:33 AM, Stephen Kelly wrote:
>
> Maybe a note could be added to the docs page with that information.
>

It is documented already in the binutils documentation.

--
Earnie
-- https://sites.google.com/site/earnieboyd

------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
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