where is the printf source for busybox?

Kim Chan ckim at etri.re.kr
Tue Mar 11 22:21:24 EDT 2014


Hi, Mohan,
Thanks!  so the printf is name chagned to _printf by the compiler. I missed that.
Chan

________________________________
From : "Mohan L" <l.mohanphy at gmail.com>
Sent : 2014-03-12 11:07:45 ( +09:00 )
To : Kim Chan <ckim at etri.re.kr>
Cc : kernelnewbies at kernelnewbies.org <kernelnewbies at kernelnewbies.org>
Subject : Re: where is the printf source for busybox?

On Wed, Mar 12, 2014 at 7:14 AM, Kim Chan <ckim at etri.re.kr<mailto:ckim at etri.re.kr>> wrote:


Hi,
I've had this question for some time past and I would like to know the answer now..
I wanted to follow a printf in busybox but couldn't find the source of the printf function.
Then I throught probably the printf is provided by the system library where printf is connected to proper linux system call. (Is it printk?)
So I checkd LD_LIBRARY_PATH of my shell and found libc.so under /lib. I could see by 'nm libc.so' that printf is in the library.
But where can I see the printf source? Is it under gcc source? in GNU sdk, under glibc-2.16.0, I tried
# grep 'int printf(' * -r
but nothing comes up.
In linux kernel source doing the same gaves me
        arch/x86/boot/boot.h:int printf(const char *fmt, ...);
        arch/x86/boot/printf.c:int printf(const char *fmt, ...)
        arch/um/include/shared/kern.h:extern int printf(const char *fmt, ...);
        arch/um/os-Linux/user_syms.c:extern int printf(const char *, ...);
        arch/powerpc/boot/stdio.h:extern int printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
so printf is defined only for x86 architecture?
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)
Where can I find the printf (user program) source?
Thanks in advance.
Chan

Hi Chan,

Here is Glibc printf.c code:

int
__printf (const char *format, ...)
{
  va_list arg;
  int done;

  va_start (arg, format);
  done = vfprintf (stdout, format, arg);
  va_end (arg);

  return done;
}

it in turn call vfprintf. You can see Glibc vfprintf.c (glibc-2.18/stdio-common/vfprintf.c)

Correct me If my understanding is wrong.

Thanks
Mohan L

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140312/0b899bc5/attachment.html 


More information about the Kernelnewbies mailing list