[HN Gopher] My Own Private Binary: An Idiosyncratic Introduction...
       ___________________________________________________________________
        
       My Own Private Binary: An Idiosyncratic Introduction to Linux
       Kernel Modules
        
       Author : spudlyo
       Score  : 65 points
       Date   : 2025-04-10 19:29 UTC (3 hours ago)
        
 (HTM) web link (www.muppetlabs.com)
 (TXT) w3m dump (www.muppetlabs.com)
        
       | spudlyo wrote:
       | This is a long essay, and here is my pitch as to why you should
       | read the whole thing if you have any interest in subjects like C
       | programming, binary formats, kernel modules, or assembler.
       | 
       | Breadbox, the author, wants to make smaller binary executables.
       | He explains about ELF binaries, a.out binaries, old MSDOS .COM
       | binaries, and how the later had no metadata, and could be very
       | small. He then explains how you can dynamically load code that
       | deals with new executable binary formats into the Linux kernel,
       | and how this process works. He walks through some sample C for
       | building a "Hello World" kernel module. He then walks you through
       | ~1 page of code for a kernel module that registers a new binary
       | format, sets up some callbacks, and if conditions are right, will
       | vm_mmap() the code into memory and call start_thread() on it.
       | 
       | Yay, it works! He has a tiny binary. This is where most articles
       | would end, but Breadbox goes deeper. What if you want a stack and
       | a heap? What if you want to access argc, argv, and envp? What if
       | you want to append code at the end that automatically calls the
       | exit syscall? All these details are covered, and I think it's
       | glorious.
       | 
       | While this all may seem like pretty dry stuff, there is humor
       | sprinkled throughout, which makes it more fun to read.
        
         | out-of-ideas wrote:
         | i truly appreciate your tl;dr!
        
       | setheron wrote:
       | This is amazing and I wish I had access to this resource months
       | ago when I explored a new binary format as well.
        
       ___________________________________________________________________
       (page generated 2025-04-10 23:00 UTC)