4 ms·
The Teensy Files: Creating teensy ELF executables for Linux
- yourad_io 12y agoGreat read. This bit from part 3 cracked me up: When this program is executed, what will happen? (Deep breath.) The kernel will map it into memory, whereupon it will see the entry in the program segment header table marked PT_INTERP. It will hand the image of our process-to-be over to the program named in that segment, which is the dynamic linker. The dynamic linker will refer to the dynamic section (thanks to it also having an entry in the program segment header table) to find the relocation table. The relocation table's one entry tells it to obtain the absolute address of the first symbol in the symbol table, the location for which is also retrieved from the dynamic section. The first entry in the symbol table provides a position in the string table (and again, the location for the string table comes from the dynamic section) where the symbol's name is stored, namely "_exit". To find that address the dynamic linker starts going down the list of shared-object libraries that our program has requested; this list contains only a single library, namely "libc.so.6". The dynamic linker will now shift its attention to that library's ELF structures instead of ours. It will compute the hash value of "_exit", and consult libc's hash table, symbol table, and string table in order to find an entry for that symbol. (If it failed to find this symbol, it would then try the next library mapped into our process space. Since there are no other such libraries, the dynamic linker would display an error message and quit the process.) The symbol table entry, once found, provides a value for the symbol, which the dynamic linker adjusts to match the address of the shared-object in our process space, and finally stores a relative version of that value at the address specified in our relocation table entry. (Phew.)
- paulannesley 12y agoI was thinking this would either be about running a tiny subset of linux on a Teensy, or running a Teensy binary on ARM linux. https://www.pjrc.com/teensy/ https://www.pjrc.com/teensy/ Interesting anyway.
- bcl 12y agoI saw Brian's presentation at SEAGL[1] this year, it was excellent! He's a very dynamic and expressive speaker and takes something that could be dry and boring and makes it interesting for all experience levels. [1] http://lanyrd.com/2014/seagl/sdfgdw/ http://lanyrd.com/2014/seagl/sdfgdw/
- voltagex_ 12y agoHas anyone got something similar for Windows? I'm trying to teach myself x86 assembler but the executables produced out of gcc/VS2013 are massive.
- userbinator 12y agoThere's a ton of info on creating tiny executables for Windows' PE file format; here are a few examples: http://www.phreedom.org/research/tinype/ http://www.phreedom.org/research/tinype/ https://code.google.com/p/corkami/wiki/PE#minimal_sizes https://code.google.com/p/corkami/wiki/PE#minimal_sizes http://hugi.scene.org/online/hugi21/cosmalpe.htm http://hugi.scene.org/online/hugi21/cosmalpe.htm I don't know how much of it can be attributed to the popularity of the platform or its culture, but I've noticed the amount of information on making tiny executables for *nix systems (including OS X's MachO) is much less in comparison.
- tomcam 12y agoA wonderful educational tool for anyone interested in writing an in-memory compiler or who just wants to get a feel for the ELF format documentation, which can be... deep.
- ekr 12y agoFor anyone looking for more ASM related information, http://asm.sourceforge.net/resources.html#docs http://asm.sourceforge.net/resources.html#docs. That's where I've first seen this site.