linker script

Hi,

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

Thanks,

Tom

Reply to
Tom
Loading thread data ...

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 =.);

}
Reply to
Simon Berry

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

Reply to
Tauno Voipio

  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.

  1. If the linker won't generate a link map, use a different linker.

Reply to
John R. Strohm

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).

Reply to
Lewin A.R.W. Edwards

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.