Search code examples
linkermicrocontrollerelfentry-point

What does "ENTRY" mean in a linker script?


I am beginning to learn to write some low-level software for micro-controllers, and I've started studying linker scripts.

I don't really get the meaning of the ENTRY command in this context. Since most micro-controllers start execution at a predetermined address, what difference does it make which entry point we choose in the linker script?


Solution

  • ENTRY() is an ELF feature that basically just sets the program entry address in the ELF header of your executable. This address may differ from the start address of the first executable segment of your binary (which would be the default execution address if you didn't define ENTRY()).

    Whether this information is used (i.e. whether start of execution happens at the first code segment address or at ENTRY()) is out of control of the linker as it entirely depends on the availability and features of your ELF loader.

    As you usually do not have such thing on a microcontroller, ENTRY() is practically useless there and you might as well omit the statement at no consequence.