bfd_link_hash_table_create using bfd_alloc

Alan Modra amodra@gmail.com
Mon Feb 11 02:07:00 GMT 2013


On Sun, Feb 10, 2013 at 02:32:59PM +1030, Alan Modra wrote:
> They would all bomb if ld called link_hash_table_free before exiting.

Now that the link_hash_table_create functions are fixed, we can free
before exit.  Only really of interest to people running valgrind or
other memory error detectors.

	* ldlang.c (get_init_priority): Comment typo.
	(lang_finish): Free link_info.hash and lang_definedness_table.
	(lang_end): Delete lang_definedness_table comment.

Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.403
diff -u -p -r1.403 ldlang.c
--- ld/ldlang.c	17 Dec 2012 00:16:49 -0000	1.403
+++ ld/ldlang.c	10 Feb 2013 04:36:56 -0000
@@ -387,7 +387,7 @@ get_init_priority (const char *name)
 	decimal numerical value of the init_priority attribute.
 	The order of execution in .init_array is forward and
 	.fini_array is backward.
-     2: .ctors.NNNN/.ctors.NNNN: Where NNNN is 65535 minus the
+     2: .ctors.NNNN/.dtors.NNNN: Where NNNN is 65535 minus the
 	decimal numerical value of the init_priority attribute.
 	The order of execution in .ctors is backward and .dtors
 	is forward.
@@ -1240,6 +1240,8 @@ lang_init (void)
 void
 lang_finish (void)
 {
+  bfd_link_hash_table_free (link_info.output_bfd, link_info.hash);
+  bfd_hash_table_free (&lang_definedness_table);
   output_section_statement_table_free ();
 }
 
@@ -5817,9 +5819,6 @@ lang_end (void)
 	    }
 	}
     }
-
-  /* Don't bfd_hash_table_free (&lang_definedness_table);
-     map file output may result in a call of lang_track_definedness.  */
 }
 
 /* This is a small function used when we want to ignore errors from

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list