public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Re: Does GDB use VMA addresses when uploading an image to debug in a remote target?
@ 2006-02-22 19:21 Fabrício de Novaes
  2006-02-22 19:23 ` Daniel Jacobowitz
  0 siblings, 1 reply; 7+ messages in thread
From: Fabrício de Novaes @ 2006-02-22 19:21 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb

[-- Attachment #1: Type: text/plain, Size: 2835 bytes --]

Hello Daniel, what a quick answer! Thank you!

About your doubt:

> I'm not sure that what you're suggesting makes sense.  How could
> GDB send the text section to its LMA, if that's a ROM address?
> The stub will be unable to write to ROM, unless (for example)
> it is transparently rewriting a flash device or shadowing it with
> RAM.

Perhaps I didn't make myself clear.

I'm using a simulator so GDB can put the sections in any address, ROM or RAM.

My .boot section, for example, is loaded into the ROM area (starting at 0x00). I'd like to do the same with the .text section, but the VMA and LMA are different, and, as you just confirmed, GDB uses VMA.

I can't make VMA and LMA the same, or the program will not run in RAM. So the question is: there's a way to tell GDB to use LMA instead of VMA when loading a program?

Regards,


Fabrício.


Daniel Jacobowitz wrote ..
> On Wed, Feb 22, 2006 at 03:12:43PM -0300, Fabrício de Novaes wrote:
> > Hi all,
> >
> >
> > I have a GCC application that will run in a board with an ERC32
> > (SPARC) processor. For many reasons, this app has to run in RAM, not
> > ROM.
> >
> > So, the ELF32 image has a ".boot" section which starts the board and
> > copies the main program from a ".text" section to RAM. This .text
> > section has different LMA (pointing to ROM) and VMA (RAM) addresses,
> > as you can see below:
> >
> > Idx Name          Size      VMA       LMA       File off  Algn
> >   0 .boot         00001320  00000000  00000000  000000b4  2**0
> >                   CONTENTS, ALLOC, LOAD, READONLY, CODE
> >   1 .text         0001d1b0  02001000  00001320  000013d8  2**3
> >                   CONTENTS, ALLOC, LOAD, CODE
> > [...]
> >
> >
> > I'm trying to debug this app using GDB and a simulator. My problem is
> > that, when I load the image to debug, the .text section is already in
> > the 0x2001000 address (VMA), and the LMA area (starting from 0x1320)
> > is empty - so I can't debug appropriately the routine that copies the
> > .text section to RAM.
> >
> > I'd like to know if GDB loads sections from an ELF file to a target
> > using the VMA addresses and, if yes, if it's possible to change this
> > behavior and tell it to send my .text section to its LMA address.
>
> GDB does use the VMA, as you've surmised.
>
> I'm not sure that what you're suggesting makes sense.  How could
> GDB send the text section to its LMA, if that's a ROM address?
> The stub will be unable to write to ROM, unless (for example)
> it is transparently rewriting a flash device or shadowing it with
> RAM.
>
> I recently encountered this problem in another context, where the stub
> did support reflashing; so maybe GDB needs to be more flexible about
> it.  I'm not sure.
>
> --
> Daniel Jacobowitz
> CodeSourcery

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

* Re: Does GDB use VMA addresses when uploading an image to debug in a remote target?
  2006-02-22 19:21 Does GDB use VMA addresses when uploading an image to debug in a remote target? Fabrício de Novaes
@ 2006-02-22 19:23 ` Daniel Jacobowitz
  2006-02-25  4:39   ` RES: " Fabrício de Novaes Kucinskis
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Jacobowitz @ 2006-02-22 19:23 UTC (permalink / raw)
  To: Fabrício de Novaes; +Cc: gdb

On Wed, Feb 22, 2006 at 03:30:20PM -0300, Fabrício de Novaes wrote:
> I can't make VMA and LMA the same, or the program will not run in
> RAM. So the question is: there's a way to tell GDB to use LMA instead
> of VMA when loading a program?

No, today there is not.  You might be able to accomplish this by using
objcopy to create a copy of the program with different VMAs, and
loading that.

-- 
Daniel Jacobowitz
CodeSourcery

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

* RES: Does GDB use VMA addresses when uploading an image to debug in a remote target?
  2006-02-22 19:23 ` Daniel Jacobowitz
@ 2006-02-25  4:39   ` Fabrício de Novaes Kucinskis
  0 siblings, 0 replies; 7+ messages in thread
From: Fabrício de Novaes Kucinskis @ 2006-02-25  4:39 UTC (permalink / raw)
  To: Daniel Jacobowitz, pkoning; +Cc: gdb

Ok, knowing that I'll change my program to test the routines I want.

Daniel, Paul, thank you very much for the help!
Best regards,


Fabrício.


-----Mensagem original-----
De: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org]Em nome de
Daniel Jacobowitz
Enviada em: quarta-feira, 22 de fevereiro de 2006 15:38
Para: Fabrício de Novaes
Cc: gdb@sourceware.org
Assunto: Re: Does GDB use VMA addresses when uploading an image to debug
in a remote target?


On Wed, Feb 22, 2006 at 03:30:20PM -0300, Fabrício de Novaes wrote:
> I can't make VMA and LMA the same, or the program will not run in
> RAM. So the question is: there's a way to tell GDB to use LMA instead
> of VMA when loading a program?

No, today there is not.  You might be able to accomplish this by using
objcopy to create a copy of the program with different VMAs, and
loading that.

--
Daniel Jacobowitz
CodeSourcery

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

* Re: Does GDB use VMA addresses when uploading an image to debug in a remote target?
  2006-02-22 18:18 Fabrício de Novaes
  2006-02-22 18:23 ` Daniel Jacobowitz
@ 2006-09-01 16:04 ` Daniel Jacobowitz
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Jacobowitz @ 2006-09-01 16:04 UTC (permalink / raw)
  To: Fabrício de Novaes, Paul Koning; +Cc: gdb

On Wed, Feb 22, 2006 at 03:12:43PM -0300, Fabrício de Novaes wrote:
> Hi all,
> 
> 
> I have a GCC application that will run in a board with an ERC32
> (SPARC) processor. For many reasons, this app has to run in RAM, not
> ROM.
> 
> So, the ELF32 image has a ".boot" section which starts the board and
> copies the main program from a ".text" section to RAM. This .text
> section has different LMA (pointing to ROM) and VMA (RAM) addresses,
> as you can see below:
> 
> Idx Name          Size      VMA       LMA       File off  Algn
>   0 .boot         00001320  00000000  00000000  000000b4  2**0
>                   CONTENTS, ALLOC, LOAD, READONLY, CODE
>   1 .text         0001d1b0  02001000  00001320  000013d8  2**3
>                   CONTENTS, ALLOC, LOAD, CODE
> [...]
> 
> 
> I'm trying to debug this app using GDB and a simulator. My problem is
> that, when I load the image to debug, the .text section is already in
> the 0x2001000 address (VMA), and the LMA area (starting from 0x1320)
> is empty - so I can't debug appropriately the routine that copies the
> .text section to RAM.
> 
> I'd like to know if GDB loads sections from an ELF file to a target
> using the VMA addresses and, if yes, if it's possible to change this
> behavior and tell it to send my .text section to its LMA address.
> 
> Any answer or comment will be very appreciated.

Replying to this old report again...

I was absolutely convinced for a long time that GDB's "load" wrote to
the VMA, a very confusing behavior.  I remember another bug being
reported that seemed to illustrate this also, but I can't find it.
However, today I actually tried it, and it did exactly the right thing:
wrote to the LMA!

Fabrício, if you still can reproduce this problem, could you send me
the output of "load" and tell me what version of GDB you were using?

-- 
Daniel Jacobowitz
CodeSourcery

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

* Re: Does GDB use VMA addresses when uploading an image to debug in a remote target?
  2006-02-22 18:23 ` Daniel Jacobowitz
@ 2006-02-22 18:38   ` Paul Koning
  0 siblings, 0 replies; 7+ messages in thread
From: Paul Koning @ 2006-02-22 18:38 UTC (permalink / raw)
  To: drow; +Cc: gdb

>>>>> "Daniel" == Daniel Jacobowitz <drow@false.org> writes:

 Daniel> I recently encountered this problem in another context, where
 Daniel> the stub did support reflashing; so maybe GDB needs to be
 Daniel> more flexible about it.  I'm not sure.

Yes, that would be useful.  There are other examples for LMA != VMA
where LMA is the correct load address.  For example:

1. LMA is an available memory area, VMA is "low memory", and a bit of
   initialization code moves the loaded code to low memory.  It can't
   be loaded directly there because there is currently running code
   already there, and loading on top of it will crash the system.

2. LMA is an unmapped address, VMA is a mapped address.  The loader
   doesn't know about mapping.  The init code turns on the mapping, at
   which point execution continues via VMA.

We do #2 in our embedded system.  

So this suggests that an option to load at LMA would be useful.  

   paul

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

* Re: Does GDB use VMA addresses when uploading an image to debug in a remote target?
  2006-02-22 18:18 Fabrício de Novaes
@ 2006-02-22 18:23 ` Daniel Jacobowitz
  2006-02-22 18:38   ` Paul Koning
  2006-09-01 16:04 ` Daniel Jacobowitz
  1 sibling, 1 reply; 7+ messages in thread
From: Daniel Jacobowitz @ 2006-02-22 18:23 UTC (permalink / raw)
  To: Fabrício de Novaes; +Cc: gdb

On Wed, Feb 22, 2006 at 03:12:43PM -0300, Fabrício de Novaes wrote:
> Hi all,
> 
> 
> I have a GCC application that will run in a board with an ERC32
> (SPARC) processor. For many reasons, this app has to run in RAM, not
> ROM.
> 
> So, the ELF32 image has a ".boot" section which starts the board and
> copies the main program from a ".text" section to RAM. This .text
> section has different LMA (pointing to ROM) and VMA (RAM) addresses,
> as you can see below:
> 
> Idx Name          Size      VMA       LMA       File off  Algn
>   0 .boot         00001320  00000000  00000000  000000b4  2**0
>                   CONTENTS, ALLOC, LOAD, READONLY, CODE
>   1 .text         0001d1b0  02001000  00001320  000013d8  2**3
>                   CONTENTS, ALLOC, LOAD, CODE
> [...]
> 
> 
> I'm trying to debug this app using GDB and a simulator. My problem is
> that, when I load the image to debug, the .text section is already in
> the 0x2001000 address (VMA), and the LMA area (starting from 0x1320)
> is empty - so I can't debug appropriately the routine that copies the
> .text section to RAM.
> 
> I'd like to know if GDB loads sections from an ELF file to a target
> using the VMA addresses and, if yes, if it's possible to change this
> behavior and tell it to send my .text section to its LMA address.

GDB does use the VMA, as you've surmised.

I'm not sure that what you're suggesting makes sense.  How could
GDB send the text section to its LMA, if that's a ROM address?
The stub will be unable to write to ROM, unless (for example)
it is transparently rewriting a flash device or shadowing it with
RAM.

I recently encountered this problem in another context, where the stub
did support reflashing; so maybe GDB needs to be more flexible about
it.  I'm not sure.

-- 
Daniel Jacobowitz
CodeSourcery

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

* Does GDB use VMA addresses when uploading an image to debug in a remote target?
@ 2006-02-22 18:18 Fabrício de Novaes
  2006-02-22 18:23 ` Daniel Jacobowitz
  2006-09-01 16:04 ` Daniel Jacobowitz
  0 siblings, 2 replies; 7+ messages in thread
From: Fabrício de Novaes @ 2006-02-22 18:18 UTC (permalink / raw)
  To: gdb

[-- Attachment #1: Type: text/plain, Size: 1324 bytes --]

Hi all,


I have a GCC application that will run in a board with an ERC32 (SPARC) processor. For many reasons, this app has to run in RAM, not ROM.

So, the ELF32 image has a ".boot" section which starts the board and copies the main program from a ".text" section to RAM. This .text section has different LMA (pointing to ROM) and VMA (RAM) addresses, as you can see below:

Idx Name          Size      VMA       LMA       File off  Algn
  0 .boot         00001320  00000000  00000000  000000b4  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .text         0001d1b0  02001000  00001320  000013d8  2**3
                  CONTENTS, ALLOC, LOAD, CODE
[...]


I'm trying to debug this app using GDB and a simulator. My problem is that, when I load the image to debug, the .text section is already in the 0x2001000 address (VMA), and the LMA area (starting from 0x1320) is empty - so I can't debug appropriately the routine that copies the .text section to RAM.

I'd like to know if GDB loads sections from an ELF file to a target using the VMA addresses and, if yes, if it's possible to change this behavior and tell it to send my .text section to its LMA address.

Any answer or comment will be very appreciated.
Thank you in advance and best regards,


Fabrício de Novaes Kucinskis.

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

end of thread, other threads:[~2006-09-01 16:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-22 19:21 Does GDB use VMA addresses when uploading an image to debug in a remote target? Fabrício de Novaes
2006-02-22 19:23 ` Daniel Jacobowitz
2006-02-25  4:39   ` RES: " Fabrício de Novaes Kucinskis
  -- strict thread matches above, loose matches on Subject: below --
2006-02-22 18:18 Fabrício de Novaes
2006-02-22 18:23 ` Daniel Jacobowitz
2006-02-22 18:38   ` Paul Koning
2006-09-01 16:04 ` Daniel Jacobowitz

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