1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

reset code and ENTRY in linker script

Discussion in 'Embedded' started by Carlo Caione, Jun 10, 2011.

  1. Carlo Caione

    Carlo Caione Guest

    Hi,
    Why do we specify in linker scripts the entry point using ENTRY(symbol) when 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 bootloader sources)

    OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
    OUTPUT_ARCH(arm)
    ENTRY(exception_vectors)
    SECTIONS
    {
    . = TEXT_BASE;

    PRE_IMAGE

    . = ALIGN(4);
    .text :
    {
    _stext = .;
    _text = .;
    *(.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 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)..
    Is there memory aliasing in this case or the ENTRY is used for this purpose?

    Thank you,
     
    Carlo Caione, Jun 10, 2011
    #1
    1. Advertisements

  2. Carlo Caione

    Arlet Ottens Guest

    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.
     
    Arlet Ottens, Jun 10, 2011
    #2
    1. Advertisements

  3. 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.
     
    Hans-Bernhard Bröker, Jun 11, 2011
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.