Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any hand-on exercise to understand how a program is loaded into memory and get executed

I am curious about the things happend before main() is called , such like load the executable into memory , dynamic load of shared library. Do you have any suggestions how to understand these things by a hand-on exercise?

The tools amd things I know of ,and using now, includes:

  • strace
  • disassemble
  • readelf
  • /proc/pid/map

NOTES: I know the great book linkers and loaders, but hands-on exercise may teach me better than reading the book.

like image 960
pierrotlefou Avatar asked Jul 31 '09 03:07

pierrotlefou


1 Answers

  • The ld.so man page documents several environment variables that may be set to either tweak the dynamic linking process or provide additional details.

e.g.

LD_DEBUG=all cat </dev/null
  • You can easily obtain the source code for each and every piece involved - Linux kernel, dynamic linker, C library, startup code (crt0.o or similar). You could start by studying the code and making experimental modifications.
like image 125
sigjuice Avatar answered Sep 28 '22 18:09

sigjuice