This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
SPU stack analysis fix
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sourceware dot org
- Date: Mon, 24 Sep 2007 10:00:03 +0930
- Subject: SPU stack analysis fix
On small leaf functions that required no stack, the SPU stack analysis
prologue scan could scan past the return instruction and into the next
function.
2007-09-24 Trevor Smigiel <Trevor_Smigiel@playstation.sony.com>
* elf32-spu.c (is_indirect_branch): New function.
(find_function_stack_adjust): End scan on hitting indirect branch.
(sum_stack): Cast %v arg to correct type.
Index: bfd/elf32-spu.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-spu.c,v
retrieving revision 1.21
diff -u -p -r1.21 elf32-spu.c
--- bfd/elf32-spu.c 4 Sep 2007 04:09:22 -0000 1.21
+++ bfd/elf32-spu.c 24 Sep 2007 00:19:05 -0000
@@ -698,6 +698,22 @@ is_branch (const unsigned char *insn)
return (insn[0] & 0xec) == 0x20 && (insn[1] & 0x80) == 0;
}
+/* Return true for all indirect branch instructions.
+ bi 00110101 000
+ bisl 00110101 001
+ iret 00110101 010
+ bisled 00110101 011
+ biz 00100101 000
+ binz 00100101 001
+ bihz 00100101 010
+ bihnz 00100101 011 */
+
+static bfd_boolean
+is_indirect_branch (const unsigned char *insn)
+{
+ return (insn[0] & 0xef) == 0x25 && (insn[1] & 0x80) == 0;
+}
+
/* Return true for branch hint instructions.
hbra 0001000..
hbrr 0001001.. */
@@ -1534,7 +1550,7 @@ find_function_stack_adjust (asection *se
reg[rt] = 0;
continue;
}
- else if (is_branch (buf))
+ else if (is_branch (buf) || is_indirect_branch (buf))
/* If we hit a branch then we must be out of the prologue. */
break;
unknown_insn:
@@ -2510,7 +2526,8 @@ sum_stack (struct function_info *fun,
}
f1 = func_name (fun);
- info->callbacks->minfo (_("%s: 0x%v 0x%v\n"), f1, fun->stack, max_stack);
+ info->callbacks->minfo (_("%s: 0x%v 0x%v\n"),
+ f1, (bfd_vma) fun->stack, max_stack);
if (fun->call_list)
{
--
Alan Modra
Australia Development Lab, IBM