reset code and ENTRY in linker script

Hi, Why do we specify in linker scripts the entry point using ENTRY(symbol) whe= n for example the ARM architecture always starts its reset code at address =

0x0000000?

I have a snippet of a linker script as following (taken from barebox bootlo= ader sources)

OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") OUTPUT_ARCH(arm) ENTRY(exception_vectors) SECTIONS { . =3D TEXT_BASE; =20 PRE_IMAGE =20 . =3D ALIGN(4); .text : { _stext =3D .; _text =3D .; *(.text_entry*) ...

With the code for reset handler in .text_entry section:

void __naked __section(.text_entry) exception_vectors(void) { __asm__ __volatile__ ( "b reset\n" /* reset */ ...

Now, since TEXT_BASE is different from 0x00000000, how can reset be at loca= tion 0x00000000 where it is expected to be? (i.e. if TEXT_BASE is 0x8000000=

0, then reset is at 0x80000000 according to the linker script whereas the f= irst instruction to be executed by the CPU should be located at 0x00000000)= . Is there memory aliasing in this case or the ENTRY is used for this purpose= ?

Thank you,

-- Carlo

Reply to
Carlo Caione
Loading thread data ...

for example the ARM architecture always starts its reset code at address

0x0000000?

bootloader sources)

location 0x00000000 where it is expected to be? (i.e. if TEXT_BASE is

0x80000000, then reset is at 0x80000000 according to the linker script whereas the first instruction to be executed by the CPU should be located at 0x00000000)..

Even though a bare ARM core always starts at 0, it could be that a SoC has hardware to modify the reset vector on the fly. It could also be that there's already another bootloader that gets executed first, e.g. a bootloader inside a ROM, which loads additional code in RAM that's not mapped at 0.

Reply to
Arlet Ottens

Because a major aspect of the linker's job is to map names to numbers.

0x0 is just a number, but how is the linker to know which named symbol should go there?

And then there's the possibility that not every program you link may be meant to run directly off the hardware's default reset vector.

Reply to
Hans-Bernhard Bröker

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.