LOGBOOK

HELP

Quiz Entry - updated: 2026.07.10

What is the entry point of a C program and what happens before main()?

The real entry point is _start; it and the C runtime (__libc_start_main, the init constructors) run first, then call your main.

Startup flow: _start calls __libc_start_main, which runs __libc_csu_init constructors, then main(argc, argv, envp), then __libc_csu_fini destructors, then _exit

* Your main sits in the middle of a runtime sandwich: _start and the CRT set things up and run constructors before it, and run destructors and _exit after. *

The C runtime (CRT) executes before your code:

_start (entry point)
    ↓
__libc_start_main()
    ↓
__libc_csu_init()
    ↓
    Calls constructors
    ↓
main(argc, argv, envp)  ← Your code starts here
    ↓
    exit() or return
    ↓
__libc_csu_fini()
    ↓
    Calls destructors
    ↓
_exit()

What _start does:

  1. Sets up the stack pointer
  2. Clears frame pointer (for stack traces)
  3. Calls __libc_start_main(main, argc, argv, ...)

View entry point:

$ readelf -h program | grep Entry
  Entry point address:               0x1040

$ objdump -d program | grep -A5 "<_start>"
0000000000001040 <_start>:
    1040: xor    %ebp,%ebp
    1042: mov    %rdx,%r9
    ...

Tip: You can change the entry point with gcc -e my_entry or ld --entry=my_entry, but you lose CRT initialization.

Go deeper:

From Quiz: REVE1 / Program Execution | Updated: Jul 10, 2026