Hi,
when using linker scripts, how can you check if the various sections actually fit into the specified memory regions ?
Thanks,
Tom
Hi,
when using linker scripts, how can you check if the various sections actually fit into the specified memory regions ?
Thanks,
Tom
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 =.);
}
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
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).
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.