* static functions appearing in the symbol table
@ 2015-08-23 13:16 Martin Faltesek
2015-08-23 20:36 ` Martin Sebor
2015-08-24 8:37 ` Nicholas Mc Guire
0 siblings, 2 replies; 3+ messages in thread
From: Martin Faltesek @ 2015-08-23 13:16 UTC (permalink / raw)
To: gcc-help
While using gcc, I've noticed that some static functions appear in the
symbol table while others do not. What are the conditions that control
when a static function's symbol appears? I would have thought all
statics would not be included.
This observation arose while debugging stack traces in the linux
kernel. (and using ftrace).
Using arm-linux-gcc 4.9.1.
Thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: static functions appearing in the symbol table
2015-08-23 13:16 static functions appearing in the symbol table Martin Faltesek
@ 2015-08-23 20:36 ` Martin Sebor
2015-08-24 8:37 ` Nicholas Mc Guire
1 sibling, 0 replies; 3+ messages in thread
From: Martin Sebor @ 2015-08-23 20:36 UTC (permalink / raw)
To: Martin Faltesek, gcc-help
On 08/23/2015 07:15 AM, Martin Faltesek wrote:
> While using gcc, I've noticed that some static functions appear in the
> symbol table while others do not. What are the conditions that control
> when a static function's symbol appears? I would have thought all
> statics would not be included.
At a high level, a static function whose calls in a program are all
inlined will not have an entry in the symbol table. A static function
that's not completely inlined will. What is and isn't inlined depends
on optimizations in effect and on attributes (e.g., function with the
always_inline attribute will likely not a have a symbol even at -O0,
while a trivial static function that's declared with attribute
noinline will even at -O1 and higher).
Martin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: static functions appearing in the symbol table
2015-08-23 13:16 static functions appearing in the symbol table Martin Faltesek
2015-08-23 20:36 ` Martin Sebor
@ 2015-08-24 8:37 ` Nicholas Mc Guire
1 sibling, 0 replies; 3+ messages in thread
From: Nicholas Mc Guire @ 2015-08-24 8:37 UTC (permalink / raw)
To: Martin Faltesek; +Cc: gcc-help
On Sun, 23 Aug 2015, Martin Faltesek wrote:
> While using gcc, I've noticed that some static functions appear in the
> symbol table while others do not. What are the conditions that control
> when a static function's symbol appears? I would have thought all
> statics would not be included.
>
> This observation arose while debugging stack traces in the linux
> kernel. (and using ftrace).
>
> Using arm-linux-gcc 4.9.1.
>
check your kernel config - the linux kernel has a config option
in kernel hacking called CONFIG_OPTIMIZE_INLINING:
Kernel hacking --->
...
[*] Allow gcc to uninline functions marked 'inline'
<snip - form the help text>
This option determines if the kernel forces gcc to inline the functions
developers have marked 'inline'. Doing so takes away freedom from gcc to
do what it thinks is best, which is desirable for the gcc 3.x series of
compilers. The gcc 4.x series have a rewritten inlining algorithm and
enabling this option will generate a smaller kernel there. Hopefully
this algorithm is so good that allowing gcc 4.x and above to make the
decision will become the default in the future. Until then this option
is there to test gcc for this.
<snip>
so I suspect that this is what is causing the discrepencey between functions
marked inline in the code and actually being compiled in. This is though
linux kernel specific and not actually a gcc issue.
also check out "3.10 Options That Control Optimization" on -finline-limit=N
and the way it is used to automatically control inlining.
thx!
hofrat
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-08-24 8:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-23 13:16 static functions appearing in the symbol table Martin Faltesek
2015-08-23 20:36 ` Martin Sebor
2015-08-24 8:37 ` Nicholas Mc Guire
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).