title: Where are syscalls located in glibc source
body: <p>So I was looking through the linux glibc source and I don't see where it actually does anything.  The following is from <code>io/chdir.c</code> but it is indicative of many of the source files.  What's going on here?  Obviously I am missing something.  What's the secret, where does it make a system call or actually do something?</p>
  
  <p><code>stub_warning</code> is some legacy craziness.  <code>__set_errno</code> seems to be a simple macro that sets <code>errno</code>.  And while I find a million usages of <code>weak_alias</code> I don't see it defined anywhere.</p>
  
  <p>Is there a helpful guide to understanding how glibc works somewhere? </p>
  
  <pre><code>#include &lt;errno.h&gt;
  #include &lt;stddef.h&gt;
  #include &lt;unistd.h&gt;
  
  /* Change the current directory to PATH.  */
  int
  __chdir (path)
       const char *path;
  {
    if (path == NULL)
      {
        __set_errno (EINVAL);
        return -1;
      }
  
    __set_errno (ENOSYS);
    return -1;
  }
  stub_warning (chdir)
  
  weak_alias (__chdir, chdir)
  #include &lt;stub-tag.h&gt; 
  </code></pre>