Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>I would like to be able to set the path to the interpreter with environment variable similar to LD_LIBRARY_PATH, maybe LD_INTERPRETER_PATH. </p> </blockquote> <p>This is simply not possible. Read carefully (and several times) the <a href="http://man7.org/linux/man-pages/man2/execve.2.html" rel="nofollow noreferrer">execve(2)</a>, <a href="http://man7.org/linux/man-pages/man5/elf.5.html" rel="nofollow noreferrer">elf(5)</a> &amp; <a href="http://man7.org/linux/man-pages/man8/ld.so.8.html" rel="nofollow noreferrer">ld.so(8)</a> man pages and the Linux <a href="http://en.wikipedia.org/wiki/Application_binary_interface" rel="nofollow noreferrer">ABI</a> &amp; <a href="http://en.wikipedia.org/wiki/Executable_and_Linkable_Format" rel="nofollow noreferrer">ELF</a> specifications. And also the kernel code doing <code>execve</code>.</p> <p>The ELF interpreter is responsible for dynamic linking. It has to be a file (technically a statically linked ELF shared library) at some <em>fixed</em> location in the file hierarchy (often <code>/lib/ld.so.2</code> or <code>/lib/ld-linux.so.2</code> or <code>/lib64/ld-linux-x86-64.so.2</code>)</p> <p><sup>The old <code>a.out</code> format from the 1990s had a builtin dynamic linker, partly implemented in old Linux 1.x kernel. It was much less flexible, and much less powerful.</sup></p> <p>The kernel enables, by such (in principle) arbitrary dynamic linker path, to have various dynamic linkers. But most systems have only one. This is a good way to parameterize the dynamic linker. If you want to try another one, install it in the file system and generate ELF executables mentioning that path.</p> <p><sup>With great pain and effort, you might make your own <code>ld.so</code>-like dynamic linker implementing your <code>LD_INTERPRETER_PATH</code> wish, but that linker still has to be an ELF shared library sitting at some <em>fixed</em> location in the file tree.</sup></p> <p>If you want a system not needing any files (at some predefined, and wired locations, like <code>/lib/ld.so</code>, <code>/dev/null</code>, <code>/sbin/init</code> ...), you'll need to build all its executable binaries statically. You may want (but current Linux distributions usually don't do that) to have a few statically linked executables (like <code>/sbin/init</code>, <code>/bin/sash</code>...) that will enable you to repair a system broken to the point of not having any dynamic linker.</p> <p><sup>BTW, the <code>/sbin/init</code> -or <code>/bin/sh</code> - path is wired <em>inside the kernel</em> itself. You may pass some argument to the kernel at boot load time -e.g. with GRUB- to overwrite the default. So even the kernel wants some files to be here!</sup></p> <p>As I commented, you might look into <a href="http://musl-libc.org/" rel="nofollow noreferrer">MUSL-Libc</a> for an alternative Libc implementation (providing its own dynamic linker). Read also about <a href="http://en.wikipedia.org/wiki/VDSO" rel="nofollow noreferrer">VDSO</a> and <a href="http://en.wikipedia.org/wiki/ASLR" rel="nofollow noreferrer">ASLR</a> and <a href="http://en.wikipedia.org/wiki/Initrd" rel="nofollow noreferrer">initrd</a>.</p> <p>In practice, accept the fact that modern Linuxes and Unixes are expecting some non-empty file system ... Notice that dynamic linking and shared libraries are a huge progress (it was much more painful in the 1990s Linux kernels and distributions).</p> <p>Alternatively, define your own binary format, then make a kernel module or a <a href="https://www.kernel.org/doc/Documentation/binfmt_misc.txt" rel="nofollow noreferrer">binfmt_misc</a> entry to handle it.</p> <p>BTW, most (or all) of Linux is <a href="http://en.wikipedia.org/wiki/Free_software" rel="nofollow noreferrer">free software</a>, so you can improve it (but this will take months -or many years- of work to you). Please share your improvements by publishing them.</p> <p>Read also <a href="http://software.intel.com/sites/default/files/m/a/1/e/dsohowto.pdf" rel="nofollow noreferrer">Drepper's Hwo to Write Shared Libraries</a> paper; and <a href="https://stackoverflow.com/q/4757121/841108">this question</a>.</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. 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