This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to split memory in linker script to get the lower address as start of .text?




Ian Lance Taylor-3 wrote:
> 
> "Jeffi Edward.J" <j.jeffi@yahoo.co.in> writes:
> 
>> I have a doubt in linker script MEMORY command.
>>
>> I have divided my available memory area into 3 regions as follows:
>>
>> MEMORY
>> {
>>    stack(w): org = 0x8000000, len = 0x50000
>>    runtime(w) : org = 0x8050010, len = 0x400000
>>    swimage(wx): org = 0x8450020, len = 0x30000
>> }
>>
>> The swimage region contains text section as well as copy of .data,
>> .bss(LMA).
>> The runtime region contains .data, .bss sections (VMA).
>>
>> When I use objdump -p command to dump the program header for the .out
>> generated with the above linker script MEMORY split, the lower address is
>> interpreted as 0x8000000. The higher and execution addresses are dumped
>> as
>> expected. However, I would like to get the lower address of memory region
>> as
>> the start address of swimage region i.e 0x8450020.
> 
> I'm not sure what you mean.  If you mean that you want to adjust the
> memory range based on the size of the your program, then the answer is
> that you can not do that using the MEMORY command.  The MEMORY command
> is intended for a system with different types of memory at different
> addresses.  If all your memory is the same, use a linker script
> without the MEMORY command.
> 
> Ian
> 
> 


Thanks Ian.
I have only one memory and thus I removed MEMORY command now.
Still am struggling to get rid of the problem.

My memory organization is as follows:

   stack -> org = 0x8000000, len = 0x50000
   runtime area -> org = 0x8050010, len = 0x400000 ( VMA of .data and .bss)
   image area -> 0x8450020, len = 0x30000 (.text, .rodata, etc and LMA of
.data)

I give the skeleton of my linker script.

SECTIONS
{
   . = 0x8050010;
   rt_area_start = .;
   .bss : { *(.bss) }
   ram_data_start = .;
   .data : AT(0x8450020) { *(.data) }
   ram_data_end = . ;
   data_size = ram_data_end - ram_data_start ;
   rt_area_end = .;

   . = 0x8450020;
   image_start = .;
   image_data_start = .;
   . = image_data_start + data_size;
   image_data_end = .;
   code_start = image_data_end ;
   .text : { *(.text) }
   .rodata : { *(.rodata) }
   ...
   ...
   code_end = .;
   image_end = code_end ;

   heap_start = rt_area_end ;
   heap_end = 0x8450010;
   stack_end = 0x8000000;
   stack_start = 0x8000000;
}

I generated image file from the .out generated using the above linker
script.
I'm supposed to get the start address of image as 0x8450020 (start of LMA of
.data) and the end address of image as the value of image_end symbol.

But I get the start address of image as VMA of .data (i.e the value of
symbol ram_data_start), which is wrong.

Have I missed anything in the linker script?
Please help me to solve the problem.
Thanks in advance.

-- 
View this message in context: http://old.nabble.com/How-to-split-memory-in-linker-script-to-get-the-lower-address-as-start-of-.text--tp28251238p28378457.html
Sent from the gcc - Help mailing list archive at Nabble.com.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]