2011年1月10日 星期一

Get Glibc source code form gnu web site

You can follow here
http://www.gnu.org/software/libc/#CurrentStatus

get source code

git clone git://sourceware.org/git/glibc.git


do branch

cd glibc
git checkout --track -b glibc-2_11-branch origin/release/2.11/master

From here and here
得知glibc是使用wrapper routines ( user level)
ap -> system call -> system call handler( kernel level) -> service rountine


androoid bionic 則是使用 system call stub去call system call

android bionic system function:


int
system(const char *command)
{
  pid_t pid;
sig_t intsave, quitsave;
sigset_t mask, omask;
int pstat;
char *argp[] = {"sh", "-c", NULL, NULL};

if (!command) /* just checking... */
return(1);

argp[2] = (char *)command;

sigemptyset(&mask);
sigaddset(&mask, SIGCHLD);
sigprocmask(SIG_BLOCK, &mask, &omask);
switch (pid = vfork()) {
case -1: /* error */
sigprocmask(SIG_SETMASK, &omask, NULL);
return(-1);
case 0: /* child */
sigprocmask(SIG_SETMASK, &omask, NULL);
execve(_PATH_BSHELL, argp, environ);
    _exit(127);
  }

intsave = (sig_t)  bsd_signal(SIGINT, SIG_IGN);
quitsave = (sig_t) bsd_signal(SIGQUIT, SIG_IGN);
pid = waitpid(pid, (int *)&pstat, 0);
sigprocmask(SIG_SETMASK, &omask, NULL);
(void)bsd_signal(SIGINT, intsave);
(void)bsd_signal(SIGQUIT, quitsave);
return (pid == -1 ? -1 : pstat);
}


glibc system 

/* Execute LINE as a shell command.  */
int
__libc_system (line)
     const char *line;
{
  if (line == NULL)
    return 0; /* This indicates no command processor.  */

  __set_errno (ENOSYS);
  return -1;
}
weak_alias (__libc_system, system)


stub_warning (system)
#include


It's a big difference.

透過Facebook分享

沒有留言: