All of lore.kernel.org
 help / color / mirror / Atom feed
* why a static function is in kernel symbol table
@ 2014-06-12 23:23 Ji Li
  2014-06-13  3:47 ` Valdis.Kletnieks at vt.edu
  0 siblings, 1 reply; 4+ messages in thread
From: Ji Li @ 2014-06-12 23:23 UTC (permalink / raw)
  To: kernelnewbies

Hi all,

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

 static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,

                            int push_one, gfp_t gfp);

I feel puzzled. The only difference between this function with other
static functions in net/ipv4/tcp_output.c is that tcp_write_xmit is
declared at the very beginning of the file. However, I tried putting
declaration of another static function in front of tcp_write_xmit, but
it still did not show up in newly compiled vmlinux.

Could anyone kindly cast some light?

Thanks
Ji

^ permalink raw reply	[flat|nested] 4+ messages in thread

* why a static function is in kernel symbol table
  2014-06-12 23:23 why a static function is in kernel symbol table Ji Li
@ 2014-06-13  3:47 ` Valdis.Kletnieks at vt.edu
  0 siblings, 0 replies; 4+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2014-06-13  3:47 UTC (permalink / raw)
  To: kernelnewbies

On Thu, 12 Jun 2014 16:23:58 -0700, Ji Li said:

> 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 --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140612/50516a03/attachment.bin 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* why a static function is in kernel symbol table
  2014-06-13  7:10 Ji
@ 2014-06-14  2:54 ` Ji Li
  0 siblings, 0 replies; 4+ messages in thread
From: Ji Li @ 2014-06-14  2:54 UTC (permalink / raw)
  To: kernelnewbies

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

On Fri, Jun 13, 2014 at 12:10 AM, Ji <lijimlee@gmail.com> wrote:
> 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
>
> On Thu, 12 Jun 2014 16:23:58 -0700, Ji Li said:
>
>> 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...
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* why a static function is in kernel symbol table
@ 2014-06-13  7:10 Ji
  2014-06-14  2:54 ` Ji Li
  0 siblings, 1 reply; 4+ messages in thread
From: Ji @ 2014-06-13  7:10 UTC (permalink / raw)
  To: kernelnewbies

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: "Valdis.Kletnieks@vt.edu" <Valdis.Kletnieks@vt.edu>
Sent: ?6/?12/?2014 8:47 PM
To: "Ji Li" <lijimlee@gmail.com>
Cc: "Kernelnewbies at kernelnewbies.org" <Kernelnewbies@kernelnewbies.org>
Subject: Re: why a static function is in kernel symbol table

On Thu, 12 Jun 2014 16:23:58 -0700, Ji Li said:

> 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 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-14  2:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-12 23:23 why a static function is in kernel symbol table Ji Li
2014-06-13  3:47 ` Valdis.Kletnieks at vt.edu
2014-06-13  7:10 Ji
2014-06-14  2:54 ` Ji Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.