Skip to contentSkip to conversation

why a static function is in kernel symbol table

DISCUSSION Ji 1 participant 2 messages Jun 13, 2014 – Jun 14, 2014

lore
Share & tools
lore

Ji

author
#0 lore raw

Thank you very much for replying.

I actually notice that there are many static functions in that file. However, some of them show up in symbol table, the rest do not. So what you are saying is that there is no connection between being a static function and showing up in kernel symbol table. Then what causes the difference appearing in symbol table or not? In other word, if i add a new static function and like it in kallsyms, what should I do?

Thanks,
Ji

-----Original Message-----
From: "[email protected]" <[email protected]>
Sent: ?6/?12/?2014 8:47 PM
To: "Ji Li" <[email protected]>
Cc: "Kernelnewbies at kernelnewbies.org" <[email protected]>
Subject: Re: why a static function is in kernel symbol table

Quoted 3 lines · Ji Li

I happened to find that a static function show up in kernel symbol table:

Could anyone kindly cast some light?

Hint: 'static' prevents code in other compilation units (basically, other .c files) from referencing it directly (though they can still access it via a function pointer variable or other similar tricks). That does *not* mean that other code in the *same* compilation unit can't reference the static function in a way that requires a symbol table entry...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140613/9732cc25/attachment.html

author
#1 lore raw

I think I found the cause. After GCC optimization, those static functions are not visible any more in the object file (not sure because of function inlining?). Thus, they don't show up in vmlinux or /proc/kallsyms.

I tried changing it to -O0, they all show up.

Thanks,
Ji

Quoted 32 lines · Ji

Thank you very much for replying.

I actually notice that there are many static functions in that file. However, some of them show up in symbol table, the rest do not. So what you are saying is that there is no connection between being a static function and showing up in kernel symbol table. Then what causes the difference appearing in symbol table or not? In other word, if i add a new static function and like it in kallsyms, what should I do?

Thanks,
Ji
________________________________
From: Valdis.Kletnieks at vt.edu
Sent: ?6/?12/?2014 8:47 PM
To: Ji Li
Cc: Kernelnewbies at kernelnewbies.org
Subject: Re: why a static function is in kernel symbol table

Quoted 3 lines · Ji Li

I happened to find that a static function show up in kernel symbol table:

Could anyone kindly cast some light?

Hint: 'static' prevents code in other compilation units (basically, other .c files) from referencing it directly (though they can still access it via a function pointer variable or other similar tricks). That does *not* mean that
other code in the *same* compilation unit can't reference the static function
in a way that requires a symbol table entry...