问题
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?
回答1:
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.
回答2:
The entry point defines the starting point of your program. This is of course very good information to have. This way flash tools know where to flash your code and also debug tools know where your symbols are at.
来源:https://stackoverflow.com/questions/40606700/what-does-entry-mean-in-a-linker-script