public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* How to check if .data section is loaded properly in LMA
@ 2011-11-08  5:33 chandru1248
  2011-11-08  5:59 ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: chandru1248 @ 2011-11-08  5:33 UTC (permalink / raw)
  To: gcc-help


Hi,

I am new to the embedded software and GCC.

Currently I am porting the compiler to GCC from diab.

I have created a linker script and the compilation is successful.

When I load the image using the debugger I am not getting the .data section
properly loaded in to the LMA.

Is there anyway I could check if the .data section is loaded in LMA or not.

Kindly help me.

Thanks in Advance.
-- 
View this message in context: http://old.nabble.com/How-to-check-if-.data-section-is-loaded-properly-in-LMA-tp32801216p32801216.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to check if .data section is loaded properly in LMA
  2011-11-08  5:33 How to check if .data section is loaded properly in LMA chandru1248
@ 2011-11-08  5:59 ` Ian Lance Taylor
  2011-11-08  6:51   ` chandru1248
  0 siblings, 1 reply; 10+ messages in thread
From: Ian Lance Taylor @ 2011-11-08  5:59 UTC (permalink / raw)
  To: chandru1248; +Cc: gcc-help

chandru1248 <chandru1248@gmail.com> writes:

> When I load the image using the debugger I am not getting the .data section
> properly loaded in to the LMA.
>
> Is there anyway I could check if the .data section is loaded in LMA or not.

First use readelf to see if the data is present in your executable as
you expect.  E.g., look at readelf -l and readelf -S output.

If that all looks fine you are going to have to examine your loader and
see why it is not doing what you expect.

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to check if .data section is loaded properly in LMA
  2011-11-08  5:59 ` Ian Lance Taylor
@ 2011-11-08  6:51   ` chandru1248
  2011-11-08  6:58     ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: chandru1248 @ 2011-11-08  6:51 UTC (permalink / raw)
  To: gcc-help


Hi Ian,

Thanks for your quick reply.

I verified the .data section in the executable using readelf as  you
mentioned. It is properly showing it. 

Can you please guide me on how to examine the loader.

Do I need to check the crt0.s file or anything else has to be check.

Please guide me.

Chandru,

Ian Lance Taylor-3 wrote:
> 
> chandru1248 <chandru1248@gmail.com> writes:
> 
>> When I load the image using the debugger I am not getting the .data
>> section
>> properly loaded in to the LMA.
>>
>> Is there anyway I could check if the .data section is loaded in LMA or
>> not.
> 
> First use readelf to see if the data is present in your executable as
> you expect.  E.g., look at readelf -l and readelf -S output.
> 
> If that all looks fine you are going to have to examine your loader and
> see why it is not doing what you expect.
> 
> Ian
> 
> 

-- 
View this message in context: http://old.nabble.com/How-to-check-if-.data-section-is-loaded-properly-in-LMA-tp32801216p32801410.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to check if .data section is loaded properly in LMA
  2011-11-08  6:51   ` chandru1248
@ 2011-11-08  6:58     ` Ian Lance Taylor
  2011-11-08  7:07       ` chandru1248
  0 siblings, 1 reply; 10+ messages in thread
From: Ian Lance Taylor @ 2011-11-08  6:58 UTC (permalink / raw)
  To: chandru1248; +Cc: gcc-help

chandru1248 <chandru1248@gmail.com> writes:

> Can you please guide me on how to examine the loader.

Your loader is something you are using with your embedded system.  I
don't know anything about it.  There are many different kinds of
loaders.


> Do I need to check the crt0.s file or anything else has to be check.

The crt0.s file is relevant if the file is loading, but is not working
after it is loaded.

You originally said that the .data section was not properly loaded into
the LMA.  What did you mean, precisely?

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to check if .data section is loaded properly in LMA
  2011-11-08  6:58     ` Ian Lance Taylor
@ 2011-11-08  7:07       ` chandru1248
  2011-11-09  3:50         ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: chandru1248 @ 2011-11-08  7:07 UTC (permalink / raw)
  To: gcc-help


Hi Ian,

> You originally said that the .data section was not properly loaded into
> the LMA.  What did you mean, precisely?

I am loading the image using debugger.

My VMA and LMA addresses are different. When I checked a global initialized
variable, the value is 0 and did not contain the value that is initialized.

Below is the snapshot of the linker script for the .data section

.data ORIGIN(rtarea) : AT (__code_ram_end)
{
__data_ram = .;
*(.data)
*(.sdata)
SORT(CONSTRUCTORS)
__data_end = .;
} > rtarea

I got the VMA as 0x600000 and LMA as 0x28ef294.

Please if anything is wrong in the above.

Chandru
-- 
View this message in context: http://old.nabble.com/How-to-check-if-.data-section-is-loaded-properly-in-LMA-tp32801216p32801452.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to check if .data section is loaded properly in LMA
  2011-11-08  7:07       ` chandru1248
@ 2011-11-09  3:50         ` Ian Lance Taylor
  2011-11-09  5:33           ` chandru1248
  0 siblings, 1 reply; 10+ messages in thread
From: Ian Lance Taylor @ 2011-11-09  3:50 UTC (permalink / raw)
  To: chandru1248; +Cc: gcc-help

chandru1248 <chandru1248@gmail.com> writes:

>> You originally said that the .data section was not properly loaded into
>> the LMA.  What did you mean, precisely?
>
> I am loading the image using debugger.
>
> My VMA and LMA addresses are different. When I checked a global initialized
> variable, the value is 0 and did not contain the value that is initialized.
>
> Below is the snapshot of the linker script for the .data section
>
> .data ORIGIN(rtarea) : AT (__code_ram_end)
> {
> __data_ram = .;
> *(.data)
> *(.sdata)
> SORT(CONSTRUCTORS)
> __data_end = .;
> } > rtarea
>
> I got the VMA as 0x600000 and LMA as 0x28ef294.

Normally when you do this kind of thing, your startup code needs to copy
the data from the LMA to the VMA.  See the last part of

http://sourceware.org/binutils/docs-2.21/ld/Output-Section-LMA.html

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to check if .data section is loaded properly in LMA
  2011-11-09  3:50         ` Ian Lance Taylor
@ 2011-11-09  5:33           ` chandru1248
  2011-11-09  8:22             ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: chandru1248 @ 2011-11-09  5:33 UTC (permalink / raw)
  To: gcc-help


Hi Ian,

> Normally when you do this kind of thing, your startup code needs to copy
> the data from the LMA to the VMA.  See the last part of

I have already written the code to copy the data from LMA to VMA. Problem
here is that LMA itself does not have the initialized values. It contains
the global varibles but all of them have the value 0. I am not sure if the
LMA is corrupted or if it is properly loaded.

Please guide me if anything can be checked for the above.

Chandru
-- 
View this message in context: http://old.nabble.com/How-to-check-if-.data-section-is-loaded-properly-in-LMA-tp32801216p32808536.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to check if .data section is loaded properly in LMA
  2011-11-09  5:33           ` chandru1248
@ 2011-11-09  8:22             ` Ian Lance Taylor
  2011-11-09 15:20               ` chandru1248
  0 siblings, 1 reply; 10+ messages in thread
From: Ian Lance Taylor @ 2011-11-09  8:22 UTC (permalink / raw)
  To: chandru1248; +Cc: gcc-help

chandru1248 <chandru1248@gmail.com> writes:

>> Normally when you do this kind of thing, your startup code needs to copy
>> the data from the LMA to the VMA.  See the last part of
>
> I have already written the code to copy the data from LMA to VMA. Problem
> here is that LMA itself does not have the initialized values. It contains
> the global varibles but all of them have the value 0. I am not sure if the
> LMA is corrupted or if it is properly loaded.

Ah, I see.  I also do not know why that is not working.  You said that
readelf shows that the section is at the correct address.  You could use
objdump -s -j SECTIONNAME to check that the section has the right
contents.  If those all look correct, then you will need to look at your
loader to see what it is doing and why it is not working as expected.

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to check if .data section is loaded properly in LMA
  2011-11-09  8:22             ` Ian Lance Taylor
@ 2011-11-09 15:20               ` chandru1248
  2011-11-09 17:09                 ` Ian Lance Taylor
  0 siblings, 1 reply; 10+ messages in thread
From: chandru1248 @ 2011-11-09 15:20 UTC (permalink / raw)
  To: gcc-help


Hi Ian,

> You could use objdump -s -j SECTIONNAME to check that the section has the
> right
> contents.  If those all look correct, then you will need to look at your
> loader to see what it is doing and why it is not working as expected.

Thanks for the info. 

As you mentioned I checked the data section and the values are correct in
the symbol table. So I think there is something wrong with the loader.

Apart from that I have noticed one thing in diab. I have a function called
__init() which is actually initializing the varibles in case of diab. But in
case of GCC it is not happening properly. 

Is that anything has to be done for GCC to make it work. Can you please tell
me your suggestion on this.

Chandru
-- 
View this message in context: http://old.nabble.com/How-to-check-if-.data-section-is-loaded-properly-in-LMA-tp32801216p32809426.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: How to check if .data section is loaded properly in LMA
  2011-11-09 15:20               ` chandru1248
@ 2011-11-09 17:09                 ` Ian Lance Taylor
  0 siblings, 0 replies; 10+ messages in thread
From: Ian Lance Taylor @ 2011-11-09 17:09 UTC (permalink / raw)
  To: chandru1248; +Cc: gcc-help

chandru1248 <chandru1248@gmail.com> writes:

>> You could use objdump -s -j SECTIONNAME to check that the section has the
>> right
>> contents.  If those all look correct, then you will need to look at your
>> loader to see what it is doing and why it is not working as expected.
>
> Thanks for the info. 
>
> As you mentioned I checked the data section and the values are correct in
> the symbol table. So I think there is something wrong with the loader.
>
> Apart from that I have noticed one thing in diab. I have a function called
> __init() which is actually initializing the varibles in case of diab. But in
> case of GCC it is not happening properly. 
>
> Is that anything has to be done for GCC to make it work. Can you please tell
> me your suggestion on this.

As far as I can tell all your issues are about your loader and perhaps
your library startup code.  Neither is part of GCC.  I don't think there
is a GCC answer to your question.

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-11-09 15:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-08  5:33 How to check if .data section is loaded properly in LMA chandru1248
2011-11-08  5:59 ` Ian Lance Taylor
2011-11-08  6:51   ` chandru1248
2011-11-08  6:58     ` Ian Lance Taylor
2011-11-08  7:07       ` chandru1248
2011-11-09  3:50         ` Ian Lance Taylor
2011-11-09  5:33           ` chandru1248
2011-11-09  8:22             ` Ian Lance Taylor
2011-11-09 15:20               ` chandru1248
2011-11-09 17:09                 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).