Fix indentation of:
[deliverable/binutils-gdb.git] / bfd / elf32-spu.c
index 81ef78b0c72558657150d3762256e3a22aa98755..e2449d4b8b1beff3c54e6c4f2c995231e989de55 100644 (file)
@@ -367,6 +367,7 @@ struct call_info
   unsigned int max_depth;
   unsigned int is_tail : 1;
   unsigned int is_pasted : 1;
+  unsigned int broken_cycle : 1;
   unsigned int priority : 13;
 };
 
@@ -1013,18 +1014,14 @@ needs_ovl_stub (struct elf_link_hash_entry *h,
   if (spu_elf_section_data (sym_sec->output_section)->u.o.ovl_index
        != spu_elf_section_data (input_section->output_section)->u.o.ovl_index)
     {
-      if (call || sym_type == STT_FUNC)
+      unsigned int lrlive = 0;
+      if (branch)
+       lrlive = (contents[1] & 0x70) >> 4;
+
+      if (!lrlive && (call || sym_type == STT_FUNC))
        ret = call_ovl_stub;
       else
-       {
-         ret = br000_ovl_stub;
-
-         if (branch)
-           {
-             unsigned int lrlive = (contents[1] & 0x70) >> 4;
-             ret += lrlive;
-           }
-       }
+       ret = br000_ovl_stub + lrlive;
     }
 
   /* If this insn isn't a branch then we are possibly taking the
@@ -2592,7 +2589,7 @@ insert_callee (struct function_info *caller, struct call_info *callee)
            p->fun->start = NULL;
            p->fun->is_func = TRUE;
          }
-       p->count += 1;
+       p->count += callee->count;
        /* Reorder list so most recent call is first.  */
        *pp = p->next;
        p->next = caller->call_list;
@@ -2600,7 +2597,6 @@ insert_callee (struct function_info *caller, struct call_info *callee)
        return FALSE;
       }
   callee->next = caller->call_list;
-  callee->count += 1;
   caller->call_list = callee;
   return TRUE;
 }
@@ -2790,7 +2786,7 @@ mark_functions_via_relocs (asection *sec,
       callee->is_tail = !is_call;
       callee->is_pasted = FALSE;
       callee->priority = priority;
-      callee->count = 0;
+      callee->count = 1;
       if (callee->fun->last_caller != sec)
        {
          callee->fun->last_caller = sec;
@@ -2882,7 +2878,7 @@ pasted_function (asection *sec)
              callee->fun = fun;
              callee->is_tail = TRUE;
              callee->is_pasted = TRUE;
-             callee->count = 0;
+             callee->count = 1;
              if (!insert_callee (fun_start, callee))
                free (callee);
              return TRUE;
@@ -3272,9 +3268,8 @@ remove_cycles (struct function_info *fun,
                                       "from %s to %s\n"),
                                     f1, f2);
            }
-         *callp = call->next;
-         free (call);
-         continue;
+
+         call->broken_cycle = TRUE;
        }
       callp = &call->next;
     }
@@ -3398,7 +3393,9 @@ mark_overlay_section (struct function_info *fun,
   if (!fun->sec->linker_mark
       && (htab->params->ovly_flavour != ovly_soft_icache
          || htab->params->non_ia_text
-         || strncmp (fun->sec->name, ".text.ia.", 9) == 0))
+         || strncmp (fun->sec->name, ".text.ia.", 9) == 0
+         || strcmp (fun->sec->name, ".init") == 0
+         || strcmp (fun->sec->name, ".fini") == 0))
     {
       unsigned int size;
 
@@ -3515,7 +3512,8 @@ mark_overlay_section (struct function_info *fun,
          BFD_ASSERT (!fun->sec->segment_mark);
          fun->sec->segment_mark = 1;
        }
-      if (!mark_overlay_section (call->fun, info, param))
+      if (!call->broken_cycle
+         && !mark_overlay_section (call->fun, info, param))
        return FALSE;
     }
 
@@ -3575,7 +3573,8 @@ unmark_overlay_section (struct function_info *fun,
     }
 
   for (call = fun->call_list; call != NULL; call = call->next)
-    if (!unmark_overlay_section (call->fun, info, param))
+    if (!call->broken_cycle
+       && !unmark_overlay_section (call->fun, info, param))
       return FALSE;
 
   if (RECURSE_UNMARK)
@@ -3626,7 +3625,8 @@ collect_lib_sections (struct function_info *fun,
     }
 
   for (call = fun->call_list; call != NULL; call = call->next)
-    collect_lib_sections (call->fun, info, param);
+    if (!call->broken_cycle)
+      collect_lib_sections (call->fun, info, param);
 
   return TRUE;
 }
@@ -3820,7 +3820,7 @@ collect_overlays (struct function_info *fun,
 
   fun->visit7 = TRUE;
   for (call = fun->call_list; call != NULL; call = call->next)
-    if (!call->is_pasted)
+    if (!call->is_pasted && !call->broken_cycle)
       {
        if (!collect_overlays (call->fun, info, ovly_sections))
          return FALSE;
@@ -3866,7 +3866,8 @@ collect_overlays (struct function_info *fun,
     }
 
   for (call = fun->call_list; call != NULL; call = call->next)
-    if (!collect_overlays (call->fun, info, ovly_sections))
+    if (!call->broken_cycle
+       && !collect_overlays (call->fun, info, ovly_sections))
       return FALSE;
 
   if (added_fun)
@@ -3917,6 +3918,8 @@ sum_stack (struct function_info *fun,
   max = NULL;
   for (call = fun->call_list; call; call = call->next)
     {
+      if (call->broken_cycle)
+       continue;
       if (!call->is_pasted)
        has_call = TRUE;
       if (!sum_stack (call->fun, info, sum_stack_param))
@@ -3960,7 +3963,7 @@ sum_stack (struct function_info *fun,
        {
          info->callbacks->minfo (_("  calls:\n"));
          for (call = fun->call_list; call; call = call->next)
-           if (!call->is_pasted)
+           if (!call->is_pasted && !call->broken_cycle)
              {
                const char *f2 = func_name (call->fun);
                const char *ann1 = call->fun == max ? "*" : " ";
@@ -4436,14 +4439,18 @@ spu_elf_auto_overlay (struct bfd_link_info *info)
          for (call = dummy_caller.call_list; call; call = call->next)
            {
              unsigned int k;
+             unsigned int stub_delta = 1;
+
+             if (htab->params->ovly_flavour == ovly_soft_icache)
+               stub_delta = call->count;
+             num_stubs += stub_delta;
 
-             ++num_stubs;
              /* If the call is within this overlay, we won't need a
                 stub.  */
              for (k = base; k < i + 1; k++)
                if (call->fun->sec == ovly_sections[2 * k])
                  {
-                   --num_stubs;
+                   num_stubs -= stub_delta;
                    break;
                  }
            }
@@ -4837,9 +4844,10 @@ spu_elf_relocate_section (bfd *output_bfd,
 
          for (g = *head; g != NULL; g = g->next)
            if (htab->params->ovly_flavour == ovly_soft_icache
-               ? g->br_addr == (rel->r_offset
-                                + input_section->output_offset
-                                + input_section->output_section->vma)
+               ? (g->ovl == ovl
+                  && g->br_addr == (rel->r_offset
+                                    + input_section->output_offset
+                                    + input_section->output_section->vma))
                : g->addend == addend && (g->ovl == ovl || g->ovl == 0))
              break;
          if (g == NULL)
@@ -4982,7 +4990,7 @@ spu_elf_relocate_section (bfd *output_bfd,
 
 /* Adjust _SPUEAR_ syms to point at their overlay stubs.  */
 
-static bfd_boolean
+static int
 spu_elf_output_symbol_hook (struct bfd_link_info *info,
                            const char *sym_name ATTRIBUTE_UNUSED,
                            Elf_Internal_Sym *sym,
@@ -5014,7 +5022,7 @@ spu_elf_output_symbol_hook (struct bfd_link_info *info,
          }
     }
 
-  return TRUE;
+  return 1;
 }
 
 static int spu_plugin = 0;
This page took 0.026231 seconds and 4 git commands to generate.