Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Steven Johnson <sjohnson@neurizon.net>
To: gdb-patches@sources.redhat.com
Subject: Uninitialised Variable in symfile.c
Date: Mon, 16 May 2005 04:49:00 -0000	[thread overview]
Message-ID: <42890F82.8010005@neurizon.net> (raw)

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

There is a codepath is "load_section_callback" where the variable "err" 
will not end up being assigned a value, and hence will default to 
whatever happened to be on the stack at its location.  And in my case, 
it was defaulting to a vlaue which signaled an error, when none had occured.

This causes the following problem:

When attempting a "load" to a remote target, "load" fails after first 
packet is successfuly transfered to the target with:

Loading section .text, size 0xdc220 lma 0x0
Sending packet: $X0,400:.....
[$][O][K][#][9][a]Packet received: OK
remote:target_xfer_partial (2, (null), 0x0,  0x40ed9008,  0x0, 1024) = 
1024, bytes = 48 00 40 00 41 50 50 20 ...
Memory access error while loading section .text.

The call to "target_write_memory_partial" will not set "err" if it uses 
"target_xfer_partial" to do the memory transfer, as 
"target_xfer_partial" does not take "err" as a parameter.

The attached patch fixes this, by simply defaulting "err" to 0, the OK 
state. 

This is the subject of PR# 1944

Steven Johnson

[-- Attachment #2: gdb-6.3-load-remote-target-bug.patch --]
[-- Type: text/x-patch, Size: 469 bytes --]

diff -Naur gdb-6.3/gdb/symfile.c gdb-6.3-modified/gdb/symfile.c
--- gdb-6.3/gdb/symfile.c	2004-09-30 23:23:09.000000000 -1100
+++ gdb-6.3-modified/gdb/symfile.c	2005-05-14 21:01:18.959321653 -1100
@@ -1405,7 +1405,7 @@
 	  struct cleanup *old_chain;
 	  CORE_ADDR lma = bfd_section_lma (abfd, asec) + args->load_offset;
 	  bfd_size_type block_size;
-	  int err;
+	  int err = 0;
 	  const char *sect_name = bfd_get_section_name (abfd, asec);
 	  bfd_size_type sent;
 

             reply	other threads:[~2005-05-15 23:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-16  4:49 Steven Johnson [this message]
2005-05-16 10:21 ` Daniel Jacobowitz

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=42890F82.8010005@neurizon.net \
    --to=sjohnson@neurizon.net \
    --cc=gdb-patches@sources.redhat.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