<div dir="ltr"><div class="gmail_extra">On Wed, Mar 12, 2014 at 7:14 AM, Kim Chan <span dir="ltr">&lt;<a href="mailto:ckim@etri.re.kr" target="_blank">ckim@etri.re.kr</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div>
<div style="font-family:Arial;font-size:10pt">
<div style="font-family:Arial">
<br><div>
<div style="line-height:15pt"><br>
Hi,</div>
<div style="line-height:15pt">I&#39;ve had this question for some time past and I would like to know the answer now..</div>
<div style="line-height:15pt">I wanted to follow a printf in busybox but couldn&#39;t find the source of the printf function.</div>
<div style="line-height:15pt">Then I throught probably the printf is provided by the system library where printf is connected to proper linux system call. (Is it printk?)</div>
<div style="line-height:15pt">So I checkd LD_LIBRARY_PATH of my shell and found libc.so under /lib. I could see by &#39;nm libc.so&#39; that printf is in the library.</div>
<div style="line-height:15pt">But where can I see the printf source? Is it under gcc source? in GNU sdk, under glibc-2.16.0, I tried
</div>
<div style="line-height:15pt"># grep &#39;int printf(&#39; * -r</div>
<div style="line-height:15pt">but nothing comes up.</div>
<div style="line-height:15pt">In linux kernel source doing the same gaves me</div>
<div style="line-height:15pt">        arch/x86/boot/boot.h:int printf(const char *fmt, ...);<br>
        arch/x86/boot/printf.c:int printf(const char *fmt, ...)<br>
        arch/um/include/shared/kern.h:extern int printf(const char *fmt, ...);<br>
        arch/um/os-Linux/user_syms.c:extern int printf(const char *, ...);<br>
        arch/powerpc/boot/stdio.h:extern int printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));</div>
<div style="line-height:15pt">so printf is defined only for x86 architecture?</div>
<div style="line-height:15pt">I understand printf is for user program not kernel, so I want to see how the printf is connected to kernel print function. (the system call, I know in sparc, linux system call is trap 0x90, function 59 when using assembly)</div>

<div style="line-height:15pt">Where can I find the printf (user program) source?</div>
<div style="line-height:15pt">Thanks in advance.</div><span class=""><font color="#888888">
<div style="line-height:15pt">Chan</div></font></span></div></div></div></div></blockquote><div><br><div class="gmail_default" style="font-family:courier new,monospace;font-size:small;display:inline">Hi Chan,<br> <br></div>
<div class="gmail_default" style="font-family:courier new,monospace;font-size:small;display:inline">Here is Glibc printf.c code:<br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small;display:inline">
<br>int<br>__printf (const char *format, ...)<br>{<br>  va_list arg;<br>  int done;<br><br>  va_start (arg, format);<br>  done = vfprintf (stdout, format, arg);<br>  va_end (arg);<br><br>  return done;<br>}<br><br>it in turn call vfprintf. You can see Glibc vfprintf.c (glibc-2.18/stdio-common/vfprintf.c)<br>
<br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small;display:inline">Correct me If my understanding is wrong.<br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small;display:inline">
<br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small;display:inline">Thanks<br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small;display:inline">
Mohan L<br></div><div class="gmail_default" style="font-family:courier new,monospace;font-size:small;display:inline"></div> </div></div></div></div>