We devoted most of this lecture to chasing down the technical details of runtime (aka user-space dynamic) linking. The data structures involved in this process are similar to those used by both compiler toolchain linkers and the kernel's linker-loader. I highly recommend John Levine's book. Its draft is available on the web: http://www.iecc.com/linker/ Please read: http://www.iecc.com/linker/linker01.html -- all of this intro http://www.iecc.com/linker/linker03.html -- the ELF- and PE- related parts http://www.iecc.com/linker/linker05.html -- the description of symbol tables http://www.iecc.com/linker/linker10.html -- what we discussed in class For the curious: debugging information (created by gcc -g by newer versions of gcc) is in DWARF format. A sketch of this complex format is here: http://dwarfstd.org/Debugging%20using%20DWARF.pdf I learned the ins and outs of (ab)using dynamic linking from http://althing.cs.dartmouth.edu/local/subversiveld.pdf Another source: http://greek0.net/elf.html When showing the different kinds of relocations, I got confused about the gcc options to use for creating a shared object. In my defence, such confusion is not uncommon: the GNU libtool was written to make it simpler between platforms (all of which differ in options): http://www.gnu.org/software/libtool/manual/libtool.html#Motivation A brief but very useful refresher for creating libs: http://www.ibm.com/developerworks/library/l-shobj/ Another useful one I just googled: http://www.adp-gmbh.ch/cpp/gcc/create_lib.html === A start on spinlocks === We will first look at Linux spinlocks, because they are "pure" spinlocks. In effort to improve efficincy, OpenSolaris introduced "adaptive" locks that choose between spin locking and queue-based locking dynamically. This is a very cool idea, but it makes the implementation more complex. Core Linux spinlock implementation: http://lxr.linux.no/#linux-bk+v2.6.11.5/include/asm-i386/spinlock.h Explanations of various syntactic and instruction-level details in the above spinlock implementation: http://c2.com/cgi/wiki?TrivialDoWhileLoop http://faydoc.tripod.com/cpu/xchg.htm http://faydoc.tripod.com/cpu/lock.htm http://en.wikipedia.org/wiki/IF_%28x86_flag%29 === Spin locks and the actual x86 memory architecture === Watch the talk about modern x86 hardware (starts around 4 minutes into the recording). The second half of the talk gives detailed examples of cache coherency logic in action, similar to what a spinlock would actually involve: http://www.infoq.com/presentations/click-crash-course-modern-hardware