Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: Michael Snyder <msnyder@specifix.com>
Cc: gdb@sourceware.org
Subject: Re: the "load" command and the .bss section
Date: Thu, 01 May 2008 00:11:00 -0000	[thread overview]
Message-ID: <200804302010.59482.vapier@gentoo.org> (raw)
In-Reply-To: <1209406914.4615.297.camel@localhost.localdomain>

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

On Monday 28 April 2008, Michael Snyder wrote:
> On Sun, 2008-04-27 at 05:09 -0400, Mike Frysinger wrote:
> > i was doing a new board port using jtag and so was leveraging the "load"
> > command to setup the initial ELF in the relevant memory regions.  things
> > kept crashing on me and then i realized that the loading process wasnt
> > actually zeroing out the bss.  is there a reason for this ?  i googled
> > and flipped through the manual, but the details on what exactly the
> > "load" command is supposed to do is a bit on sketchy side.  from what i
> > can tell from the gdb source code and the actual output from running the
> > command, it walks the section headers (rather than the program headers ?)
> > and loads up everything that is in the file.  since the bss section
> > doesnt actually exist in the file and is only allocated, that is why it
> > gets skipped ?
> >
> > once i adapted my habits to first load the ELF and then manually zero the
> > bss, life was so much saner :).
>
> In my understanding, it is not GDB's responsibility to zero the
> .bss section.  That is the responsibility of the C Runtime.
>
> Otherwise, how could the program run without gdb in the picture?
>
> The gdb load command only addresses sections with the loadable
> flag.  .bss is not loadable.

a fair point, but i think there is a valid use case for having an optional 
flag to tell gdb to do this.  you may want to load a bare metal application 
that itself would have normally been loaded by another application (say your 
typical bootloader), so the assumption is that certain aspects of the C 
runtime have been initialized before the bare metal application is executed.  
Daniel also indicated that i wouldnt be the first (and probably not the last) 
to experience this hiccup and ask for an optional (streamlined) method for 
accounting for this.
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 827 bytes --]

  reply	other threads:[~2008-05-01  0:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-28  8:02 Mike Frysinger
2008-04-28 13:48 ` Daniel Jacobowitz
2008-04-28 17:29   ` Mike Frysinger
2008-04-28 17:42     ` Daniel Jacobowitz
2008-04-29 18:04 ` Michael Snyder
2008-05-01  0:11   ` Mike Frysinger [this message]
2008-05-01  2:03     ` Michael Snyder
2008-05-01  3:32       ` Daniel Jacobowitz
2008-05-01 19:24         ` Michael Snyder
2008-05-01 19:32           ` Daniel Jacobowitz
2008-05-01 20:05             ` Michael Snyder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200804302010.59482.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gdb@sourceware.org \
    --cc=msnyder@specifix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox