Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It depends if your implementation is using <em>C</em> interface for low level utilities or not.</p> <p>If your language gives direct access to syscalls without going thru the <em>C</em> wrapper you don't need to use VDSO (you could for instance generate the appropriate <code>SYSENTER</code> machine instruction to do the syscall). In that case, your language don't even need to follow the all the ABI conventions, just the conventions of the kernel. (for instance, you don't need the ABI provided caller-safe calle-safe distinguo on registers, and you could even avoid using any stacks).</p> <p>My understanding of the VDSO is that it is an abstraction, provided by the kernel, to abstract away the various small differences (related to user-land -> kernel transitions) in implementing syscalls, between various families of x86 processors. If you have chosen a particular processor target, you don't need VDSO, and you can always avoid it.</p> <p>AFAIU, the VDSO is an ELF shared object, sitting (on my Debian/AMD64 with a recently compiled 3.8.3 kernel) in the segment <code>ffffffffff600000-ffffffffff601000</code>; check exactly with <code>cat /proc/self/maps</code> where it is). So you just need to understand the organization of ELF shared objects and retrieve the symbols from it. See <a href="http://blogs.igalia.com/aperez/2009/01/13/the-story-of-linux-gatevdsoso/" rel="nofollow noreferrer">this</a> &amp; <a href="http://www.trilithium.com/johan/2005/08/linux-gate/" rel="nofollow noreferrer">that</a> links. The VDSO uses the C conventions for calling documented in the x86-64 ABI specification.</p> <p><sup>That is, if you extract from your process space the VDSO and write it on a disk file, the result is a well formed ELF shared object</sup></p> <p><a href="http://en.wikipedia.org/wiki/Executable_and_Linkable_Format" rel="nofollow noreferrer">ELF</a> is a well documented format. And so is the <a href="http://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI" rel="nofollow noreferrer">x86-64 ABI conventions</a> (which defines precisely the C calling conventions, and how exactly a process' image starts. See also <a href="http://man7.org/linux/man-pages/man2/execve.2.html" rel="nofollow noreferrer">execve(2)</a>) man page, and of course the kernel documentation, so I don't understand what is your issue. I agree that understanding ELF takes time (I did that 10 years ago, but my memory is rusty). Read also the <code>&lt;elf.h&gt;</code> header file on your machine.</p> <p>For instance; running (under <code>zsh</code> on 64 bits Debian x86-64)</p> <pre><code> % file $(which sash) /bin/sash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, for GNU/Linux 2.6.26, BuildID[sha1]=0x0347fcc08fba2f811f58af99f26111d0f579a9f6, stripped % ldd $(which sash) not a dynamic executable % sash Stand-alone shell (version 3.7) &gt; ps |grep sash 21635 pts/3 00:00:00 sash &gt; cat /proc/21635/maps 00400000-004da000 r-xp 00000000 08:01 4985590 /bin/sash 006da000-006dc000 rw-p 000da000 08:01 4985590 /bin/sash 006dc000-006e1000 rw-p 00000000 00:00 0 017e3000-01806000 rw-p 00000000 00:00 0 [heap] 7fe4950e5000-7fe4950e7000 rw-p 00000000 00:00 0 7fff3f130000-7fff3f151000 rw-p 00000000 00:00 0 [stack] 7fff3f173000-7fff3f175000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] </code></pre> <p>See also <a href="https://stackoverflow.com/a/15471044/841108">this answer</a>.</p> <p>You probably want inside your runtime a minimal version of a dynamic linker able to simply parse the VDSO. You certainly want to understand the exact state in which a process is started, and in particular the role of <code>auxv</code>, the auxiliary vector (I really forget these details, but I remember that they are important). See e.g. <a href="http://lwn.net/Articles/519085/" rel="nofollow noreferrer">this article</a></p> <p>Actually, starting reliably your runtime is probably harder than the VDSO issue.</p> <p>You may also want to read the <a href="http://asm.sourceforge.net/howto/Assembly-HOWTO.html" rel="nofollow noreferrer">linux assembly howto</a> which also explains some things (but more about x86 than x86-64)</p> <p>BTW,the code of <a href="http://musl-libc.org/" rel="nofollow noreferrer">http://musl-libc.org/</a> (which is an alternative libc) is much easier to read and understand (and you'll learn easily how they do dynamic linking, pthreads, etc..)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload