LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-01-2009, 04:18 AM   #1
noble_curious
LQ Newbie
 
Registered: Nov 2007
Location: MARS
Distribution: Fedora 6
Posts: 14

Rep: Reputation: 0
Query related to Hiding symbol in Shared Library


Hi,

I have a question:

Suppose i have a source code file as

test.c
------------
Code:
...
...
...
#include <stdio.h>
void __attribute__ (( visibility ("hidden") )) sayHello (void)
{
   printf("hello");
}
....
i compile this file and make shared library using gcc say named as libhello.so

now although the function sayHello is not exported to the libhello.so
but when i run this command:

Code:
shell> nm libhello.so
the resultant display shows one of the symbol there as sayHello

Is this possible that I completely hide this symbol so that nm doesnt read this local function in the library.

Kind Regards
 
Old 01-01-2009, 04:53 AM   #2
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 179Reputation: 179
There are two ways to do this.

One way is to use program strip. Do this at the command line:
Code:
man strip
Another way is to do it at compile time by declaring the function as static. But you probably knew this.
 
Old 01-01-2009, 05:07 AM   #3
noble_curious
LQ Newbie
 
Registered: Nov 2007
Location: MARS
Distribution: Fedora 6
Posts: 14

Original Poster
Rep: Reputation: 0
@wje_lq

Thank you sir. You really solved my issue. I really had noknowledge about the 'strip' utility. It is really wonderfull. I removed all the unnecessary symbols and there is no effect on my application.

Thankyou again and Kind Regards
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gcc link shared library against another shared library qcp Linux - Newbie 1 07-25-2008 11:15 AM
undefined symbol, compiler version? shared library troubles? thewtex Programming 6 02-25-2007 04:32 PM
Hiding global symbols in a shared/static library jineshkj Programming 16 08-30-2006 12:45 AM
Forcing extern declaration symbol generation in shared library ta0kira Programming 6 03-26-2006 03:49 PM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration