This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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: $ prefix to addresses in symbolsrec file was dropped (by mistake during a code cleanup, as far as I can see) between binutils 2.12 and 2.12.1


On Tue, Dec 03, 2002 at 09:20:05PM -0000, Max Bowsher wrote:
> In cvs revision 1.16 of bfd/srec.c, the $ prefix to addresses in a
> symbolsrec file was dropped.
> 
> Based on the log message, it sounds like this was accidental, whilst the
> code was refactored to not use sprintf (because of the risk of buffer
> overruns).
> 
> The relevant section of code is the block of changes about 15 lines from the
> bottom of this patch:
> http://sources.redhat.com/ml/binutils/2002-04/msg00029.html

Oops.  Thanks for the time you took to track down where the problem
was introduced.

	* srec.c (srec_write_symbols): Restore '$' prefix to address
	accidentally removed in 2002-04-04 change.
	(srec_get_symtab): Use 0 instead of '(long) FALSE'.

Applying mainline and branch.

Index: bfd/srec.c
===================================================================
RCS file: /cvs/src/src/bfd/srec.c,v
retrieving revision 1.23
diff -u -p -r1.23 srec.c
--- bfd/srec.c	30 Nov 2002 08:39:40 -0000	1.23
+++ bfd/srec.c	3 Dec 2002 23:50:41 -0000
@@ -1095,24 +1095,25 @@ srec_write_symbols (abfd)
 	      && (s->flags & BSF_DEBUGGING) == 0)
 	    {
 	      /* Just dump out non debug symbols.  */
-	      char buf[42], *p;
+	      char buf[43], *p;
 
 	      len = strlen (s->name);
 	      if (bfd_bwrite ("  ", (bfd_size_type) 2, abfd) != 2
 		  || bfd_bwrite (s->name, len, abfd) != len)
 		return FALSE;
 
-	      sprintf_vma (buf + 1, (s->value
+	      sprintf_vma (buf + 2, (s->value
 				     + s->section->output_section->lma
 				     + s->section->output_offset));
-	      p = buf + 1;
+	      p = buf + 2;
 	      while (p[0] == '0' && p[1] != 0)
 		p++;
 	      len = strlen (p);
 	      p[len] = '\r';
 	      p[len + 1] = '\n';
+	      *--p = '$';
 	      *--p = ' ';
-	      len += 3;
+	      len += 4;
 	      if (bfd_bwrite (p, len, abfd) != len)
 		return FALSE;
 	    }
@@ -1203,7 +1204,7 @@ srec_get_symtab (abfd, alocation)
 
       csymbols = (asymbol *) bfd_alloc (abfd, symcount * sizeof (asymbol));
       if (csymbols == NULL && symcount != 0)
-	return (long) FALSE;
+	return 0;
       abfd->tdata.srec_data->csymbols = csymbols;
 
       for (s = abfd->tdata.srec_data->symbols, c = csymbols;

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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