This is the mail archive of the binutils@sourceware.org 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]

too many open files


GNU ld wasn't closing script files after parsing, which can easily
cause a "too many open files" error.  Also, scripts get parsed
multiple times when the script is inside a group, and that can lead to
all sorts of mayhem.

	* ldlang.c (load_symbols): Close file and set flags.loaded
	after parsing script file.
	(open_input_bfds): Don't segv on closed script.

Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.393
diff -u -p -r1.393 ldlang.c
--- ld/ldlang.c	21 Jun 2012 03:32:59 -0000	1.393
+++ ld/ldlang.c	25 Jun 2012 01:43:33 -0000
@@ -2668,6 +2668,7 @@ load_symbols (lang_input_statement_type 
     {
       bfd_error_type err;
       struct lang_input_statement_flags save_flags;
+      extern FILE *yyin;
 
       err = bfd_get_error ();
 
@@ -2715,6 +2716,9 @@ load_symbols (lang_input_statement_type 
       save_flags.missing_file |= input_flags.missing_file;
       input_flags = save_flags;
       pop_stat_ptr ();
+      fclose (yyin);
+      yyin = NULL;
+      entry->flags.loaded = TRUE;
 
       return TRUE;
     }
@@ -3224,6 +3228,7 @@ open_input_bfds (lang_statement_union_ty
 #endif
 		  && !s->input_statement.flags.whole_archive
 		  && s->input_statement.flags.loaded
+		  && s->input_statement.the_bfd != NULL
 		  && bfd_check_format (s->input_statement.the_bfd,
 				       bfd_archive))
 		s->input_statement.flags.loaded = FALSE;
@@ -3233,6 +3238,7 @@ open_input_bfds (lang_statement_union_ty
 		       && plugin_insert == NULL
 		       && s->input_statement.flags.loaded
 		       && s->input_statement.flags.add_DT_NEEDED_for_regular
+		       && s->input_statement.the_bfd != NULL
 		       && ((s->input_statement.the_bfd->flags) & DYNAMIC) != 0
 		       && plugin_should_reload (s->input_statement.the_bfd))
 		{

-- 
Alan Modra
Australia Development Lab, IBM


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