public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Brian Dessent <brian@dessent.net>
To: "Chen(?) Jun(?)" <chjfth@gmail.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: How to assign which symbols/functions to export from a .so file
Date: Thu, 13 Dec 2007 09:39:00 -0000	[thread overview]
Message-ID: <4760FDCA.6B2E967F@dessent.net> (raw)
In-Reply-To: <4760F9A2.50802@gmail.com>

"Chen(?) Jun(?)" wrote:

> I'd like to know, when I generate a .so file with ``gcc -shared'', how
> can I assign which functions to export(visible by the  .so user).  This
> is important , because a .so author would probably like to hide his
> private functions so that the private symbols will not conflict with
> that of .so from other programmers.
> 
> Microsoft compiler use a .def to describe what symbols to export from a
> DLL, or, __declspec(dllexport) can easily export functions of a whole
> C++ class. Does the gcc world support this feature.

What platform are you talking about?  gcc uses whatever the underlying
platform supports, but that can vary considerably.  You have to remember
that gcc targets dozens and dozens of various combinations of operating
systems and architectures so don't assume that gcc=linux.

On PE platforms, gcc works similarly to the MS toolchain: __declspec
and/or a .def file, but also with the choice of using the auto-export
feature of the GNU linker if neither of the former are used.

On ELF platforms you use symbol visibility, either with
__attribute__((visibility)) or -fvisibility.  Read the fine manual: 

<http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#index-g_t_0040code_007bvisibility_007d-attribute-2100>
<http://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fvisibility-1837>

Brian

  parent reply	other threads:[~2007-12-13  9:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-13  9:22 "Chen(陈) Jun(军)"
2007-12-13  9:35 ` 龙海涛
2007-12-13  9:39 ` Brian Dessent [this message]
2007-12-14 13:23   ` "Chen(陈) Jun(军)"

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4760FDCA.6B2E967F@dessent.net \
    --to=brian@dessent.net \
    --cc=chjfth@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).