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.

linker script

Discussion in 'Embedded' started by Tom, Nov 13, 2003.

  1. Tom

    Tom Guest

    Hi,

    when using linker scripts, how can you check if the various sections
    actually fit into the specified memory regions ?

    Thanks,

    Tom
     
    Tom, Nov 13, 2003
    #1
    1. Advertisements

  2. Tom

    Simon Berry Guest

    if you are talking about linker scripts under gnu c , then the following
    example (of a linker script) should help. The linker will complain f you
    exceed the allowable size...

    MEMORY {
    ram : ORIGIN = 0x200000, LENGTH = 0x3000
    rom : ORIGIN = 0x00000000, LENGTH = 0xf000
    }


    SECTIONS {
    .text : {
    PROVIDE(_stext = .);
    *(.text)
    . = ALIGN(4);
    PROVIDE(_etext = .);
    } > ram
    .data : {
    PROVIDE(_sdata = .);
    *(.data)
    *(.rodata)
    *(.glue_7*)
    . = ALIGN(4);
    PROVIDE(_edata = .);
    } > ram
    .bss : {
    PROVIDE(_sbss = .);
    *(.bss)
    . += 0x200;
    . = ALIGN(4);
    PROVIDE(_ebss = .);
    } > ram
    . += 0x1000;
    PROVIDE(_stack =.);
    PROVIDE(_end =.);

    }
     
    Simon Berry, Nov 13, 2003
    #2
    1. Advertisements

  3. Tom

    Tauno Voipio Guest

    If the question applies to the GNU linker (ld), a more appropriate group
    would be gnu.utils.help. The linker is a part of the binutils package.

    Normally, GCC uses the GNU assembler (as) and linker (ld) to build the
    executable image.

    The GNU linker complains if the sections do not fit into the memory regions
    specified to them, regardless whether the linker is using the default script
    or a custom one. The memory ranges are taken from the active linker script.

    HTH

    Tauno Voipio
    tauno voipio @ iki fi
     
    Tauno Voipio, Nov 13, 2003
    #3
  4. 1. RTFM. The linker documentation will tell you (a) how to generate a link
    map (b) how the linker barfs if you blow a section allocation.

    2. If the linker doesn't come with documentation, use a different linker.

    3. If the linker won't generate a link map, use a different linker.
     
    John R. Strohm, Nov 13, 2003
    #4
  5. The GNU linker complains if the sections do not fit into the memory regions
    Yes, but it is fairly common to see linker scripts that don't use
    named regions, they simply direct output to a starting address in the
    actual linker section. It can be a subtle art to convert scripts like
    that to named-region scripts.

    (I must confess to being trained this way, (a) because it makes the
    linker script read more like a linear assembly-language program, and
    (b) because my first real under-the-covers S&M sessions with the GNU
    tools dealt with thousands of lines of code from Winbond, which used
    this technique exclusively).
     
    Lewin A.R.W. Edwards, Nov 13, 2003
    #5
    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.