public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Hide/export symbols in static library
@ 2005-05-31 11:14 Jyotirmoy Sharma
       [not found] ` <45A1F95BB9D7D84FAB0A1EB4D67EEF96016B7F29@is01ex01.ittiam.c om>
  0 siblings, 1 reply; 3+ messages in thread
From: Jyotirmoy Sharma @ 2005-05-31 11:14 UTC (permalink / raw)
  To: gcc-help

Hi,

Can anyone tell me how I can hide all the global symbols except
for few (i.e. export only selected symbols) while building a static library?

I have tried using "ld -r f1.o f2.o -o lib.a", but this exposes all the global
symbols.

Regards,
Jyotirmoy

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Hide/export symbols in static library
       [not found] ` <45A1F95BB9D7D84FAB0A1EB4D67EEF96016B7F29@is01ex01.ittiam.c om>
@ 2005-05-31 11:58   ` Eljay Love-Jensen
  0 siblings, 0 replies; 3+ messages in thread
From: Eljay Love-Jensen @ 2005-05-31 11:58 UTC (permalink / raw)
  To: Jyotirmoy Sharma, gcc-help

Hi Jyotirmoy,

I not sure what you are trying to do.  It appears to me that you are using ld to create an executable called "lib.a", which is not an archive library (.a).  Since the -r (also -i or --relocatable) creates an OMAGIC file that can be consumed by ld, maybe it serves a similar purpose.

I think you should use the ar command to create an archive library (.a).

As I understand it, the ld command consumes archive libraries (.a), as well as shared object libraries (.so) and object files (.o), to produce executables (no extension, chmod a+x) or shared object libraries (.so).

Whether or not a symbol has external linkage depends outside the translation unit depends on whether or not you've specified that the translation scope identifier is static or not (in C and C++).

NOTE (as I understand it):  C++ anonymous namespace does not mean the identifier is internally linked only.  Still need to specific static.  Unfortunately?  Perhaps.

Using ld to create a shared object library (.so) in ELF format, you can use a --version-script=FILE command.

Using ld to create a shared object library (.DLL) in i386 PE format, there are several ld flags available to control symbol exposure.

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Hide/export symbols in static library
@ 2005-05-31 13:06 Jyotirmoy Sharma
  0 siblings, 0 replies; 3+ messages in thread
From: Jyotirmoy Sharma @ 2005-05-31 13:06 UTC (permalink / raw)
  To: Eljay Love-Jensen, gcc-help

Hi Eljay,

Thanks for your reply. Actually what I want to do is to
create an archive library (.a) with only few global symbols
exposed (or exported) and all other global symbols being
hidden. 

I cannot use "static" directive in "C" files as
my functions are used across files. 

If I archive several .o files using ar, all the global 
symbols remain exposed . So, I tried to do "partial linking" 
of the .o files using ld as I am not aware of any other
method of hiding global symbols in a static library. 

Thanks and regards,
Jyotirmoy



-----Original Message-----
From: Eljay Love-Jensen [mailto:eljay@adobe.com]
Sent: Tuesday, May 31, 2005 5:31 PM
To: Jyotirmoy Sharma; gcc-help@gcc.gnu.org
Subject: Re: Hide/export symbols in static library


Hi Jyotirmoy,

I not sure what you are trying to do.  It appears to me that you are using ld to create an executable called "lib.a", which is not an archive library (.a).  Since the -r (also -i or --relocatable) creates an OMAGIC file that can be consumed by ld, maybe it serves a similar purpose.

I think you should use the ar command to create an archive library (.a).

As I understand it, the ld command consumes archive libraries (.a), as well as shared object libraries (.so) and object files (.o), to produce executables (no extension, chmod a+x) or shared object libraries (.so).

Whether or not a symbol has external linkage depends outside the translation unit depends on whether or not you've specified that the translation scope identifier is static or not (in C and C++).

NOTE (as I understand it):  C++ anonymous namespace does not mean the identifier is internally linked only.  Still need to specific static.  Unfortunately?  Perhaps.

Using ld to create a shared object library (.so) in ELF format, you can use a --version-script=FILE command.

Using ld to create a shared object library (.DLL) in i386 PE format, there are several ld flags available to control symbol exposure.

HTH,
--Eljay


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-05-31 13:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-31 11:14 Hide/export symbols in static library Jyotirmoy Sharma
     [not found] ` <45A1F95BB9D7D84FAB0A1EB4D67EEF96016B7F29@is01ex01.ittiam.c om>
2005-05-31 11:58   ` Eljay Love-Jensen
2005-05-31 13:06 Jyotirmoy Sharma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).