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]

[PATCH, SPU] Make --auto-overlay always respect stack+heap reserved space


Hello,

I was trying to use --auto-overlay to run the Fortran test suite,
but it didn't really work as I expected.

The problem is that most of the tests come in at about 200K fixed
code + data size (due to pulling in the libgfortran library), but
then go on to do somewhat over 50 KB of heap memory allocation.

I thought that using something along the line of
   -Wl,--auto-overlay -Wl,--reserved-space=100000
should allow those tests to run.  But in fact this command line
has no effect at all, because the linker simply notices that the
fixed code + data sections (at about 200K) fit into local store,
and therefore completely ignores the --auto-overlay option.

This check neglects to ensure that in addition to code + data,
there is enough space for stack + heap as specified via the
--reserved-space option (or in its absence, automatically
discovered by stack analysis).

The patch below moves the check whether overlays are really
needed from spu_elf_check_vma into spu_elf_auto_overlay, and
takes stack + heap into consideration.  Do to so, I've had
to move stack analysis (if necessary) to a somewhat earlier
place -- as far as I can see, this should have no adverse
effects.

This gets the vast majority of Fortran test cases to run (except
for those that fail due to data size or unrelated issues).

Tested on spu-elf with no regressions.
OK for mainline?

Bye,
Ulrich


ChangeLog:

	* elf32-spu.c (spu_elf_check_vma): Do not reset auto_overlay
	parameter just because fixed sections fit into local store.
	(spu_elf_auto_overlay): Do not declare as "noreturn".  Skip
	generating overlays if fixed sections plus reserved stack
	and heap space fit into local store.


Index: bfd/elf32-spu.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-spu.c,v
retrieving revision 1.65
diff -u -p -r1.65 elf32-spu.c
--- bfd/elf32-spu.c	11 Mar 2009 00:18:02 -0000	1.65
+++ bfd/elf32-spu.c	13 Mar 2009 17:43:56 -0000
@@ -2062,9 +2062,6 @@ spu_elf_check_vma (struct bfd_link_info 
 		|| m->sections[i]->vma + m->sections[i]->size - 1 > hi))
 	  return m->sections[i];
 
-  /* No need for overlays if it all fits.  */
-  if (htab->params->ovly_flavour != ovly_soft_icache)
-    htab->params->auto_overlay = 0;
   return NULL;
 }
 
@@ -4035,9 +4032,6 @@ print_one_overlay_section (FILE *script,
 
 /* Handle --auto-overlay.  */
 
-static void spu_elf_auto_overlay (struct bfd_link_info *)
-     ATTRIBUTE_NORETURN;
-
 static void
 spu_elf_auto_overlay (struct bfd_link_info *info)
 {
@@ -4079,11 +4073,30 @@ spu_elf_auto_overlay (struct bfd_link_in
   if (!build_call_tree (info))
     goto err_exit;
 
+  htab = spu_hash_table (info);
+  if (htab->reserved == 0)
+    {
+      struct _sum_stack_param sum_stack_param;
+
+      sum_stack_param.emit_stack_syms = 0;
+      sum_stack_param.overall_stack = 0;
+      if (!for_each_node (sum_stack, info, &sum_stack_param, TRUE))
+	goto err_exit;
+      htab->reserved = sum_stack_param.overall_stack + htab->extra_stack_space;
+    }
+
+  /* No need for overlays if everything already fits.  */
+  if (fixed_size + htab->reserved <= htab->local_store
+      && htab->params->ovly_flavour != ovly_soft_icache)
+    {
+      htab->params->auto_overlay = 0;
+      return;
+    }
+
   uos_param.exclude_input_section = 0;
   uos_param.exclude_output_section
     = bfd_get_section_by_name (info->output_bfd, ".interrupt");
 
-  htab = spu_hash_table (info);
   ovly_mgr_entry = "__ovly_load";
   if (htab->params->ovly_flavour == ovly_soft_icache)
     ovly_mgr_entry = "__icache_br_handler";
@@ -4186,16 +4199,6 @@ spu_elf_auto_overlay (struct bfd_link_in
     }
   free (bfd_arr);
 
-  if (htab->reserved == 0)
-    {
-      struct _sum_stack_param sum_stack_param;
-
-      sum_stack_param.emit_stack_syms = 0;
-      sum_stack_param.overall_stack = 0;
-      if (!for_each_node (sum_stack, info, &sum_stack_param, TRUE))
-	goto err_exit;
-      htab->reserved = sum_stack_param.overall_stack + htab->extra_stack_space;
-    }
   fixed_size += htab->reserved;
   fixed_size += htab->non_ovly_stub * ovl_stub_size (htab->params->ovly_flavour);
   if (fixed_size + mos_param.max_overlay_size <= htab->local_store)
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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