Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7626167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:17:23+00:00 2026-05-31T05:17:23+00:00

For VC, I can write a DEF file and use the ‘NONAME’ directive to

  • 0

For VC, I can write a DEF file and use the ‘NONAME’ directive to leaving only the ordinal number in dll’s export table.

How could I do the same thing with gcc and ELF format shared library?

Or, is there something equivalent in ELF shared library like the ordinal number in a PE format DLL? If not, how could I hide the exported symbol’s name within a shared library?

======================================

UPDATE: Some additional descriptions:

In Windows, you can export a function by only place a integer ID (the ordinal) with an empty name.

To show it, the normal layout for a dll’s export table looks like this: http://home.hiwaay.net/~georgech/WhitePapers/Exporting/HowTo22.gif.

the “NONAME” one looks like this: http://home.hiwaay.net/~georgech/WhitePapers/Exporting/HowTo23.gif.

Notice the functions name are “N/A” in the second picture. Here is a full explaination of it: hxxp://home.hiwaay.net/~georgech/WhitePapers/Exporting/Exp.htm.

======================================

UPDATE: A lot of thanks for everyone who make me advice. Finally, I decide to keeping use static library on linux/posix platforms. But extract the small “special part” (which is using some features not suitable for static lib, e.g: TLS Slot, etc.) to a normal shared-library. Because the small normal shared-library only doing few things, and these work are totally insensitive, so there is no need to obscure/hide its APIs.

I think it’s the simplest way to solve my problem 😀

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:17:23+00:00Added an answer on May 31, 2026 at 5:17 am

    The previous answers regarding attribute ((visibility ("hidden"))) is good when you want to maintain the code long term, but if you only have a few symbols that you want visible and want a quick fix… On the symbols that you want to export use, add

    __attribute__ ((visibility ("default"))) 
    

    Then you can pass -fvisibility=hidden to the compiler

    There is a thorough explanation here:

    http://gcc.gnu.org/wiki/Visibility

    Edit: An alternative would be to build a static library/archive (make .a archive with ar -cru mylib.a *.o) or combine the objects into a single object file according to this combine two GCC compiled .o object files into a third .o file

    If you are asking "Why combine object files instead of just making a static library?" … because the linker will treat .o files differently than .a files (I don’t know why, just that it does), specifically it will allow you to link a .o file into a shared library or a binary even if all of the symbols are hidden (even the ones you are using) This has the added benefit of reducing startup times (one less DSO and a lot less symbols to look up) and binary size (the symbols typically make up ~20% of the size and stripping only takes care of about half of that – just the externally visible parts)

    for binaries strip --strip-all -R .note -R .comment mybinary

    for libraries strip --strip-unneeded -R .note -R .comment mylib.so

    More on the benefits of static linking here: http://sta.li/faq but they don’t discuss licensing issues which are the main reason not to use a static library and since you are wanting to hide your API, that may be an issue

    Now that we know have an object that is "symbol clean", it is possible to use our combined object to build a libpublic.so by linking private.o and public.c (which aliases/exports only what you want public) into a shared library.

    This method lends itself well to finding the "extra code" that is unneeded in your public API as well. If you add -fdata-sections -ffunction-sections to your object builds, when you link with -Wl,--gc-sections,--print-gc-sections , it will eliminate unused sections and print an output of what was removed.

    Edit 2 – or you could hide the whole API and alias only the functions you want to export

    alias ("target")
    

    The alias attribute causes the declaration to be emitted as an alias for another symbol, which must be specified. For instance,

    void __f () { /* Do something. */; }
    void f () __attribute__ ((weak, alias ("__f")));
    

    defines f' to be a weak alias for __f’. In C++, the mangled name for the target must be used. It is an error if `__f’ is not defined in the same translation unit.

    Not all target machines support this attribute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have encountered a very strange issue: i use json.dump to write a file
Following is the method used to write an entry to xml file def write_entry(entry)
I used to use ERB templates everywhere using the following technique: def create_from_template(file, template,
I can write an assertion message one of two ways. Stating success: assertEquals( objects
We can write CSS as the following types: Inline CSS Embedded CSS External CSS
I can write something, I'm asking if something is already built into jQuery.
I can write my code in both the ways to achieve my objective, but
Can someone please explain how you can write a url pattern and view that
In C++ one can write any of the following statements: 10; true; someConstant; //if
In perl I can write ($var1, $var2, $var3) = split(/:/, foo:bar:blarg) to split a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.