This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [patch bfd]: Fix boostrap of binutils with gcc 4.8
On Mon, Oct 15, 2012 at 12:10:15PM +0200, Kai Tietz wrote:
> Ping
>
> 2012/10/10 Kai Tietz <ktietz70@googlemail.com>:
> > Hi,
> >
> > this patch fixes a hidden bug which got detected by new 4.8
> > warning-check about sizeof-argument (really useful one - much kudos!)
> >
> > ChangeLog
> >
> > 2012-10-10 Kai Tietz
> >
> > * elf32-xtensa.c (clear_section_cache): Zero
> > complete memory-region.
> > (section_cache_section): Likewise.
A similar patch was posted prior to yours
http://sourceware.org/ml/binutils/2012-10/msg00059.html and since Jan
hasn't applied his as he said he would, I took a look and decided to
tidy the code.
* elf32-xtensa.c (free_section_cache): Renamed from
clear_section_cache. Don't zero cache.
(section_cache_section): Remove ineffectual zero of cache.
Call init_section_cache instead.
Index: bfd/elf32-xtensa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-xtensa.c,v
retrieving revision 1.135
diff -u -p -r1.135 elf32-xtensa.c
--- bfd/elf32-xtensa.c 2 Sep 2012 12:17:26 -0000 1.135
+++ bfd/elf32-xtensa.c 16 Oct 2012 00:53:35 -0000
@@ -6067,7 +6067,7 @@ init_section_cache (section_cache_t *sec
static void
-clear_section_cache (section_cache_t *sec_cache)
+free_section_cache (section_cache_t *sec_cache)
{
if (sec_cache->sec)
{
@@ -6075,7 +6075,6 @@ clear_section_cache (section_cache_t *se
release_internal_relocs (sec_cache->sec, sec_cache->relocs);
if (sec_cache->ptbl)
free (sec_cache->ptbl);
- memset (sec_cache, 0, sizeof (sec_cache));
}
}
@@ -6116,8 +6115,8 @@ section_cache_section (section_cache_t *
goto err;
/* Fill in the new section cache. */
- clear_section_cache (sec_cache);
- memset (sec_cache, 0, sizeof (sec_cache));
+ free_section_cache (sec_cache);
+ init_section_cache (sec_cache);
sec_cache->sec = sec;
sec_cache->contents = contents;
@@ -8272,8 +8271,9 @@ compute_removed_literals (bfd *abfd,
#endif /* DEBUG */
error_return:
- if (prop_table) free (prop_table);
- clear_section_cache (&target_sec_cache);
+ if (prop_table)
+ free (prop_table);
+ free_section_cache (&target_sec_cache);
release_contents (sec, contents);
release_internal_relocs (sec, internal_relocs);
--
Alan Modra
Australia Development Lab, IBM