public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richards@transitive.com>
To: binutils@sourceware.org
Subject: [20/21] Fix free() of in-use memory when handling archives
Date: Tue, 10 Mar 2009 14:51:00 -0000	[thread overview]
Message-ID: <g4k56x4ej3.fsf@richards-desktop.transitives.com> (raw)
In-Reply-To: <g4y6vd7a4x.fsf@richards-desktop.transitives.com> (Richard 	Sandiford's message of "Tue\, 10 Mar 2009 13\:58\:06 +0000")

xcoff_link_check_archive_element tries to be a good citizen and free
symbol tables for unneeded archive members.  The problem is that it
can be called twice for the same member (if the same library is listed
twice on the command line).  The second call can then end up freeing
information that was entered into the hash table by the first call.

OK to install?

Richard


bfd/
	* xcofflink.c (xcoff_link_check_archive_element): Only free the
	symbol table if it was created by the current call.

Index: bfd/xcofflink.c
===================================================================
--- bfd/xcofflink.c	2009-03-10 13:54:27.000000000 +0000
+++ bfd/xcofflink.c	2009-03-10 13:54:49.000000000 +0000
@@ -2149,6 +2149,9 @@ xcoff_link_check_archive_element (bfd *a
 				  struct bfd_link_info *info,
 				  bfd_boolean *pneeded)
 {
+  bfd_boolean keep_syms_p;
+
+  keep_syms_p = (obj_coff_external_syms (abfd) != NULL);
   if (! _bfd_coff_get_external_symbols (abfd))
     return FALSE;
 
@@ -2159,9 +2162,11 @@ xcoff_link_check_archive_element (bfd *a
     {
       if (! xcoff_link_add_symbols (abfd, info))
 	return FALSE;
+      if (info->keep_memory)
+	keep_syms_p = TRUE;
     }
 
-  if (! info->keep_memory || ! *pneeded)
+  if (!keep_syms_p)
     {
       if (! _bfd_coff_free_symbols (abfd))
 	return FALSE;

  parent reply	other threads:[~2009-03-10 14:51 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-10 13:58 [0/21] Add support for AIX 6 Richard Sandiford
2009-03-10 14:00 ` [1/21] Fix handling of archive tests Richard Sandiford
2009-03-12 16:15   ` Nick Clifton
2009-03-10 14:01 ` [2/21] Add support for AIX 6 Richard Sandiford
2009-03-12 16:17   ` Nick Clifton
2009-03-10 14:04 ` [3/21] Keep .text, .data and .bss on AIX Richard Sandiford
2009-03-12 16:36   ` Nick Clifton
2009-03-13  9:43     ` Richard Sandiford
2009-03-13 11:42       ` Nick Clifton
2009-03-14  9:42         ` Richard Sandiford
2009-03-10 14:05 ` [4/21] Fix o_cputype for 64-bit XCOFF objects Richard Sandiford
2009-03-12 16:38   ` Nick Clifton
2009-03-10 14:07 ` [5/21] Set config.dynamic_link for AIX Richard Sandiford
2009-03-12 16:39   ` Nick Clifton
2009-03-10 14:08 ` [6/21] XCOFF R_POS and R_NEG relocations against absolute symbols Richard Sandiford
2009-03-13 14:33   ` Nick Clifton
2009-03-10 14:13 ` [7/21] Handle relative branches to absolute addresses Richard Sandiford
2009-03-13 14:37   ` Nick Clifton
2009-03-10 14:13 ` [0/21] Add support for AIX 6 Ian Lance Taylor
2009-03-10 15:22   ` Richard Sandiford
2009-03-10 15:45   ` Michael Haubenwallner
2009-03-10 16:30     ` Ian Lance Taylor
2009-03-10 14:15 ` [8/21] bfd_install_relocation strikes again Richard Sandiford
2009-03-13 14:48   ` Nick Clifton
2009-03-10 14:22 ` [9/21] Implicitly import undefined symbols Richard Sandiford
2009-03-13 14:55   ` Nick Clifton
2009-03-10 14:25 ` [10/21] Fix the csect handling of XTY_ER symbols Richard Sandiford
2009-03-13 14:57   ` Nick Clifton
2009-03-10 14:29 ` [11/21] Cope with TOCs bigger than 32k, and other TC0 fixes Richard Sandiford
2009-03-13 14:59   ` Nick Clifton
2009-03-10 14:34 ` [12/21] Trim XCOFF symbols earlier in the link process Richard Sandiford
2009-03-13 15:01   ` Nick Clifton
2009-03-10 14:36 ` [13/21] Fix counting of line-number entries Richard Sandiford
2009-03-13 15:04   ` Nick Clifton
2009-03-10 14:38 ` [14/21] Treat absolute imports as XTY_ER/XMC_XO Richard Sandiford
2009-03-13 15:11   ` Nick Clifton
2009-03-10 14:40 ` [15/21] Avoid writing duplicate XCOFF symbols Richard Sandiford
2009-03-13 15:12   ` Nick Clifton
2009-03-10 14:45 ` [16/21] Add AIX weak support Richard Sandiford
2009-03-13 15:17   ` Nick Clifton
2009-03-10 14:46 ` [17/21] Suppor garbage collection without an entry point Richard Sandiford
2009-03-13 15:22   ` Nick Clifton
2009-03-10 14:49 ` [18/21] Add -bexpall and -bexpfull Richard Sandiford
2009-03-13 15:21   ` Nick Clifton
2009-03-10 14:50 ` [19/21] Give imported function descriptors class XMC_DS Richard Sandiford
2009-03-13 15:24   ` Nick Clifton
2009-03-10 14:51 ` Richard Sandiford [this message]
2009-03-13 15:24   ` [20/21] Fix free() of in-use memory when handling archives Nick Clifton
2009-03-10 14:53 ` [21/21] GAS testsuite fix Richard Sandiford
2009-03-13 15:25   ` Nick Clifton

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=g4k56x4ej3.fsf@richards-desktop.transitives.com \
    --to=richards@transitive.com \
    --cc=binutils@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).