RE: where is the printf source for busybox?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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


From : "Mohan L" <l.mohanphy@xxxxxxxxx>
Sent : 2014-03-12 11:07:45 ( +09:00 )
To : Kim Chan <ckim@xxxxxxxxxx>
Cc : kernelnewbies@xxxxxxxxxxxxxxxxx <kernelnewbies@xxxxxxxxxxxxxxxxx>
Subject : Re: where is the printf source for busybox?

On Wed, Mar 12, 2014 at 7:14 AM, Kim Chan <ckim@xxxxxxxxxx> 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
 
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux