What does “ENTRY” mean in a linker script?

2019-07-14 02:50发布

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?

2条回答
走好不送
2楼-- · 2019-07-14 03:45

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.

查看更多
成全新的幸福
3楼-- · 2019-07-14 03:52

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.

查看更多
登录 后发表回答