## Notes

If you want to hack the selfie.c library, create a file
named .dev in this directory. It will instruct the Makefile
that you want to fiddle around, pass useful arguments to GCC,
and create a selfie binary performing some basic tests.

vDSO is not properly preserved by snapshots, this means that
syscalls like gettimeofday and getcpu might segfault in
snapshots. If you want those to work you can disable ASLR
for both the original program and the snapshot:
  
    $ setarch x86_64 -R ./my-program-or-snapshot

When programming, I found it helpful to disable ASLR. This
lets you debug the snapshot in gdb and interpret the locations
you see with another gdb session on the original program.

    $ echo 0 > /proc/sys/kernel/randomize_va_space  # disable
    $ echo 2 > /proc/sys/kernel/randomize_va_space  # enable

There might be a nicer way to tell gdb that the debug
info is available in another file.

## Reading material

  - GCC constraints of x86; it's so annoying to google!
    https://github.com/gcc-mirror/gcc/blob/master/gcc/config/i386/constraints.md
  - How programs get run: ELF binaries
    https://lwn.net/Articles/631631/
  - QCC can generate nice ELF binaries
    https://c9x.me/qcc/
  - There are special cases for vDSO maps (see noread())
    https://lwn.net/Articles/446528/
    https://lwn.net/Articles/615809/
  - setup_arg_pages() initializes the stack kernel data structures
    http://lxr.linux.no/linux+v3.0/fs/exec.c#L738
  - ELF loading in kernel
    https://elixir.bootlin.com/linux/latest/source/fs/binfmt_elf.c#L870
  - Glibc's __brk()
    https://github.com/bminor/glibc/blob/bc2eb9321ec0d17d41596933617b2522c9aa5e0b/sysdeps/unix/sysv/linux/i386/brk.c#L37
