- To: Sam <samueldotj@xxxxxxxxx>
- Subject: Re: Nested function - Avoid it in symbol table
- From: Ian Lance Taylor <iant@xxxxxxxxxx>
- Date: Sun, 17 Jun 2012 21:36:52 -0700
- Cc: gcc-help@xxxxxxxxxxx
- Comment: DKIM? See http://www.dkim.org
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
- In-reply-to: <CA+1iFvcrFu=dxPpTXqnZR2VdmkKwRbK7pjSuO7+hnriAXNY+uQ@mail.gmail.com> (Sam's message of "Sat, 16 Jun 2012 13:03:54 -0700")
- User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Sam <samueldotj@xxxxxxxxx> writes:
> Is there any way to disable emitting nested function names in symbol table?
> I tried visibility(hidden) attribute and it is not working.
> The problem I have is I use nested function in a macro and which
> results in embedded in multiple places causing lot of unwanted entries
> symbol table increasing this of image.
>
> Sample program:
> $ cat test.c
> #include <stdio.h>
> int main()
> {
> __attribute__((visibility ("hidden")))
> int nested_function()
> {
> printf("Hello world\n");
> }
> nested_function();
> return 0;
> }
>
> $ readelf -s ./a.out | grep nest
> 50: 00000000004004a4 16 FUNC LOCAL DEFAULT 12 nested_function.2069
This is a local symbol. It increases the size of the a.out file, but it
does not increase the size of the program as loaded into memory.
There is no way to remove this local symbol from the object file. But
you could remove it from the final executable by using strip
--strip-unneeded. If you want other local symbols but not this one, use
--strip-symbol.
Ian
[Linux C Programming]
[Linux Kernel]
[eCos]
[Fedora Development]
[Fedora Announce]
[Autoconf]
[The DWARVES Debugging Tools]
[Yosemite Campsites]
[Yosemite News]
[Linux GCC]