Is ENTRY(_Reset) redundant here?

OP (Company: ss) #5015260
Rate this post
• ▲ useful
▼ not useful
I read a code somewhere:

startup.s:
=========================================
.section INTERRUPT_VECTOR, "x"
.global _Reset
_Reset:
    B Reset_Handler /* Reset */
    B.
    ...

Reset_Handler:
    LDR sp, =stack_top
    ...

test.ld:
=========================================
ENTRY(_Reset)
SECTIONS
{
    . = 0x0;
    .text: {
    startup.o (INTERRUPT_VECTOR)
    *(.text)
    }
    ...
}

I understand that ENTRY(_Reset) set the program entry point to _Reset.

Q1. What if .text does not start from 0x0? Will the first instruction to 
be executed still be "B Reset_Handler"?

Q2. In the original test.ld, is ENTRY(_Reset) still necessary, or is it 
redundant? Since we already set startup.o (INTERRUPT_VECTOR) to start 
from 0x0 already.
#5015292
Rate this post
• ▲ useful
▼ not useful
Splee S. wrote:
> I understand that ENTRY(_Reset) set the program entry point to _Reset.

Basically the only thing ENTRY(...) does is to place the information 
about this entry point into the header of your executable, provided such 
thing (header) is available and can hold such information (which is the 
case for ELF, for example).

This will only have any effect if you have a loader (i.e., an ELF 
loader, in our case) that will use this information at runtime. In 
embedded coding, more often than not you won't have such luxury, i.e. 
there isn't any header since you basically convert your ELF file into a 
flat binary during the flash process.

Bottom line: in most use cases, the ENTRY() statement is basically 
useless for embedded development.

Reply

A question of your own? This thread is over 9 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.