This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
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
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Max Bowsher <maxb at ukf dot net>
- Cc: binutils at sources dot redhat dot com
- Date: Wed, 4 Dec 2002 10:24:05 +1030
- Subject: 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
- References: <023f01c29b11$bfc80020$78d96f83@pomello>
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