https://blogs.oracle.com/ksplice/entry/hello_from_a_libc_free
By jesstess on Mar 16, 2010
As an exercise, I want to write a Hello World program in C simple enough that I can disassemble it and be able to explain all of the assembly to myself.
This should be easy, right?
This adventure assumes compilation and execution on a Linux machine. Some familiarity with reading assembly is helpful.
Here's our basic Hello World program:
jesstess@kid-charlemagne:~/c$ cat hello.c
int main()
{
printf("Hello World\n");
return 0;
}
The problem is that gcc
is still using standard library startup files when linking. Want proof? We'll compile with -nostdlib
, which according to the gcc
man page won't "use the standard system libraries and startup files when linking. Only the files you specify will be passed to the linker".