Hi, I have a doubt in assigning LMA/VMA address for .data section in my linker script. My RAM is logically divided into image area and runtime area. Assume for example my RAM size is 10000(decimal). When I looked at the linker script written using other vendor tool chain, there was an easy way for dynamically allocating space for LMA of .data section. I give the skeleton of the script: SECTIONS { __ram_start = .; __sw_image_start = __ram_start ; __code_start = __sw_image_start ; .text : { *(.init) *(.text) *(.fini) ... } __code_end = .; __code_size = __code_end - __code_start ; __sw_data_start = __code_end ; __sw_data_end = __sw_data_start + __data_size; /* forward reference of __data_size which doesnt work with GNU linker script :( */ . = __sw_data_end ; __sw_image_end = .; __runtime_area_start = __sw_image_end ; __rt_data_start = __runtime_area_start ; .data : AT(__sw_data_start) { *(.data) } __rt_data_end = .; __data_size = __rt_data_end - __rt_data_start; /* this __data_size is used on the top */ .bss : { *(.bss) } /* allocation of space for heap/stack goes here ... */ __runtime_area_end = __ram_end ; /* forward reference of __ram_end */ __ram_end = 9999 ; } As written above, the run time memory area starts immediately after the image area without any hole. The LMA space for .data section is computed using forward reference __data_size. ----------------------- 0 (__sw_image_start/__ram_start) text ----------------------- 1000 data ----------------------- 1500 (__sw_image_end/__runtime_area_start) data ----------------------- 2000 bss ----------------------- 3000 heap ----------------------- 7000 stack ---------------------- 9999 (__ram_end/__runtime_area_end) software image area = 0 to 1500 run time area = 1500 to 9999 All code and initialized global data are placed into software image area. In GNU ld parlance, the area between __sw_data_start to __sw_data_end is called LMA of .data section and the area between __rt_data_start and __rt_data_end is called VMA of .data section. .data section from LMA to VMA is copied using memcpy() in my application. When it comes to GNU linker script, i observed 2 things while converting the above script to GNU ld script format. 1. GNU linker script doesnt allow forward reference of symbols in an expression in script file 2. Because of the above lacking property, there is no way to dynamically allocate space for LMA of .data section. SECTIONS { ... ... __sw_data_start = __code_end ; __sw_data_end = __sw_data_start + 1000; /* using constant size 1000 may leave hole or cause inadequate space (overlapping)for LMA of .data */ . = __sw_data_end ; __sw_image_end = .; __runtime_area_start = __sw_image_end ; __rt_data_start = __runtime_area_start ; .data : AT(__sw_data_start) { *(.data) } __rt_data_end = .; .bss : { *(.bss) } /* allocation of space for heap/stack goes here ... */ __runtime_area_end = __ram_end ; /* forward reference of __ram_end */ __ram_end = 9999 ; } Is my above understanding correct? If I lack in understanding w.r.t GNU ld script, please tell me who the dynamic size computation for LMA of .data section can be done? Please clarify my doubt. If the above explanation is not sufficient please acknowledge. -- View this message in context: http://old.nabble.com/How-to-dynamically-compute-space-for-LMA-of-.data-section-in-ld-script--tp27026793p27026793.html Sent from the gcc - Help mailing list archive at Nabble.com.