This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Get the real system call wrappers



On 19/08/2017 11:34, Yubin Ruan wrote:
> Hi,
> How can I get the complete glibc system call wrappers?
> I know that glibc implement most system call wrappers but they are not
> exposed explicitly in the glibc source. Rather, the complete system
> call wrappers are generated on the fly when glibc is built, probably
> using some scripts. For example, the "open(2)" system call is now
> defined in io/open.c:
> 
>     29 __libc_open (const char *file, int oflag)
>     30 {
>     31  int mode;
>     32
>     33  if (file == NULL)
>     34  {
>     35  __set_errno (EINVAL);
>     36  return -1;
>     37  }
>     38
>     39  if (__OPEN_NEEDS_MODE (oflag))
>     40  {
>     41  va_list arg;
>     42  va_start(arg, oflag);
>     43  mode = va_arg(arg, int);
>     44  va_end(arg);
>     45  }
>     46
>     47  __set_errno (ENOSYS);
>     48  return -1;
>     49 }
>     50 libc_hidden_def (__libc_open)
>     51 weak_alias (__libc_open, __open)
>     52 libc_hidden_weak (__open)
>     53 weak_alias (__libc_open, open)
>     54
>     55 stub_warning (open)
>     56
>     57 /* __open_2 is a generic wrapper that calls __open.
>     58  So give a stub warning for that symbol too. */
>     59 stub_warning (__open_2)
> 
> After some replacement (I guess), we will get a complete open(2)
> system call wrapper.
> 
> But all methods I found on the web to generate the complete wrappers
> seem to be obsolete (can't find those scripts). Do I have to built the
> whole glibc completely to obtain those? Or is there any lightweight
> method?

The syscall generation mechanism is described in this wiki entry [1],
and although it would require some updates (which I intend to do after
I finish my sysdep-cancel.h cleanup) it holds for current version.

[1] https://sourceware.org/glibc/wiki/SyscallWrappers


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]