Creating and running executable by hand-Collection of common programming errors

Since you said simplest program, here is a real hack.

This is for Ubuntu 12.04, running x86_64. If you have something else, then this might give you a hint what to do.

mkdir hack_code
cd hack_code
cp /usr/lib/ldscripts/elf_x86_64.x ldsimple.x

Now modify ldsimple.x to say ENTRY(main) instead of ENTRY(_start) in the beginning.

Create this mymain.c:

int main(void)
{
    __asm__ __volatile__ (
        "movq $60, %rax\n"  /* call sys_exit */
        "movq $2,  %rdi\n"  /* return code   */
        "syscall"           /* call kernel to exit program */
    );
    return 0;
}

And then:

gcc -c mymain.c
ld -o mymain -T./ldsimple.x mymain.o

Voila: You now have got a program which does not use any library etc.