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/rfa] CFI support for hppa target


The attached patch adds CFI assembly directive support to hppa elf targets. Tested on hppa-linux and hppa64-linux. Build tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11. OK to apply?

thanks
randolph
2006-10-29  Randolph Chung  <tausq@debian.org>

	* config/tc-hppa.c (hppa_cfi_frame_initial_instructions)
	(hppa_regname_to_dw2regnum): New funcions.
	* config/tc-hppa.h [OBJ_ELF] (TARGET_USE_CFIPOP): Define.
	(tc_cfi_frame_initial_instructions)
	(tc_regname_to_dw2regnum): Define.
	(hppa_cfi_frame_initial_instructions)
	(hppa_regname_to_dw2regnum): Declare.
	(DWARF2_LINE_MIN_INSN_LENGTH, DWARF2_DEFAULT_RETURN_COLUMN)
	(DWARF2_CIE_DATA_ALIGNMENT): Define.
	* testsuit/gas/cfi/cfi.exp [hppa*-linux*]: Run hppa CFI test.
	* testsuite/gas/cfi/cfi-hppa-1.s: New file.
	* testsuite/gas/cfi/cfi-hppa-1.h: New file.

Index: config/tc-hppa.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-hppa.c,v
retrieving revision 1.132
diff -u -p -r1.132 tc-hppa.c
--- config/tc-hppa.c	7 Jun 2006 11:27:57 -0000	1.132
+++ config/tc-hppa.c	29 Oct 2006 03:35:31 -0000
@@ -25,6 +25,7 @@
 #include "as.h"
 #include "safe-ctype.h"
 #include "subsegs.h"
+#include "dw2gencfi.h"
 
 #include "bfd/libhppa.h"
 
@@ -8690,3 +8691,45 @@ const pseudo_typeS md_pseudo_table[] =
   {"word", pa_cons, 4},
   {NULL, 0, 0}
 };
+
+#ifdef OBJ_ELF
+void
+hppa_cfi_frame_initial_instructions (void)
+{
+  cfi_add_CFA_def_cfa (30, 0);
+}
+
+int
+hppa_regname_to_dw2regnum (char *regname)
+{
+  unsigned int regnum = -1;
+  unsigned int i;
+  const char *p;
+  char *q;
+  static struct { char *name; int dw2regnum; } regnames[] =
+    {
+      { "sp", 30 }, { "rp", 2 },
+    };
+
+  for (i = 0; i < ARRAY_SIZE (regnames); ++i)
+    if (strcmp (regnames[i].name, regname) == 0)
+      return regnames[i].dw2regnum;
+
+  if (regname[0] == 'r')
+    {
+      p = regname + 1;
+      regnum = strtoul (p, &q, 10);
+      if (p == q || *q || regnum >= 32)
+	return -1;
+    }
+  else if (regname[0] == 'f' && regname[1] == 'r')
+    {
+      p = regname + 2;
+      regnum = strtoul (p, &q, 10);
+      if (p == q || *q || regnum <= 4 || regnum >= 32)
+	return -1;
+      regnum += 32 - 4;
+    }
+  return regnum;
+}
+#endif
Index: config/tc-hppa.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-hppa.h,v
retrieving revision 1.31
diff -u -p -r1.31 tc-hppa.h
--- config/tc-hppa.h	24 May 2006 11:05:42 -0000	1.31
+++ config/tc-hppa.h	29 Oct 2006 03:35:31 -0000
@@ -201,4 +201,22 @@ int hppa_force_reg_syms_absolute (expres
 #define TC_FIX_TYPE PTR
 #define TC_INIT_FIX_DATA(FIX) ((FIX)->tc_fix_data = NULL)
 
+#ifdef OBJ_ELF
+#define TARGET_USE_CFIPOP 1
+
+#define tc_cfi_frame_initial_instructions hppa_cfi_frame_initial_instructions
+extern void hppa_cfi_frame_initial_instructions (void);
+
+#define tc_regname_to_dw2regnum hppa_regname_to_dw2regnum
+extern int hppa_regname_to_dw2regnum (char *regname);
+
+#define DWARF2_LINE_MIN_INSN_LENGTH 4
+#define DWARF2_DEFAULT_RETURN_COLUMN 2
+#if TARGET_ARCH_SIZE == 64
+#define DWARF2_CIE_DATA_ALIGNMENT -8
+#else
+#define DWARF2_CIE_DATA_ALIGNMENT -4
+#endif
+#endif
+
 #endif /* _TC_HPPA_H */
Index: testsuite/gas/cfi/cfi.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/cfi/cfi.exp,v
retrieving revision 1.14
diff -u -p -r1.14 cfi.exp
--- testsuite/gas/cfi/cfi.exp	15 Mar 2005 05:28:17 -0000	1.14
+++ testsuite/gas/cfi/cfi.exp	29 Oct 2006 03:35:32 -0000
@@ -61,6 +61,8 @@ if [istarget "x86_64-*"] then {
 
 } elseif { [istarget "mips*-*"] } then {
     run_dump_test "cfi-mips-1"
+} elseif { [istarget "hppa*-linux*"] } then {
+    run_dump_test "cfi-hppa-1"
 } else {
     return
 }
--- testsuite/gas/cfi/cfi-hppa-1.s	2006-10-28 20:00:51.000000000 -0700
+++ testsuite/gas/cfi/cfi-hppa-1.s	2006-10-28 20:00:51.000000000 -0700
@@ -0,0 +1,66 @@
+#; $ as -o test.o gas-cfi-test.s && gcc -nostdlib -o test test.o
+
+	.text
+	.align 4
+	.level 1.1
+
+.globl func_locvars
+	.type	func_locvars, @function
+func_locvars:
+	.PROC
+	.CALLINFO FRAME=0x1234,NO_CALLS,SAVE_SP,ENTRY_GR=3
+	.ENTRY
+	.cfi_startproc
+	copy %r3,%r1
+	copy %r30,%r3
+	.cfi_def_cfa_register r3
+	stwm %r1,0x1234(%r30)
+	.cfi_adjust_cfa_offset 0x1234
+	ldo 64(%r3),%r30
+	ldwm -64(%r30),%r3
+	.cfi_def_cfa_register sp
+	bv,n %r0(%r2)
+	.cfi_endproc
+	.EXIT
+	.PROCEND
+
+.globl func_prologue
+	.type	func_prologue, @function
+func_prologue:
+	.PROC
+	.CALLINFO FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=3
+	.ENTRY
+	.cfi_startproc
+#; This is not ABI-compliant but helps the test to run on both
+#; 32-bit and 64-bit targets
+	stw %r2,-24(%r30)
+	copy %r3,%r1
+	copy %r30,%r3
+	.cfi_def_cfa_register r3
+	.cfi_offset r2, -24
+	stwm %r1,64(%r30)
+	bl func_locvars,%r2
+	nop
+	ldw -20(%r3),%r2
+	ldo 64(%r3),%r30
+	ldwm -64(%r30),%r3
+	.cfi_def_cfa_register sp
+	bv,n %r0(%r2)
+	.cfi_endproc
+	.EXIT
+	.PROCEND
+
+	.align 4
+.globl main
+	.type	main, @function
+main:
+	.PROC
+	.CALLINFO CALLS
+	.ENTRY
+	#; tail call - simple function that doesn't touch the stack
+	.cfi_startproc
+	b func_prologue
+	nop
+	.cfi_endproc
+	.EXIT
+	.PROCEND
--- testsuite/gas/cfi/cfi-hppa-1.d	2006-10-28 20:03:38.000000000 -0700
+++ testsuite/gas/cfi/cfi-hppa-1.d	2006-10-28 20:03:38.000000000 -0700
@@ -0,0 +1,38 @@
+#readelf: -wf
+#name: CFI on hppa
+The section .eh_frame contains:
+
+00000000 00000010 00000000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 4
+  Data alignment factor: -[48]
+  Return address column: 2
+  Augmentation data:     1b
+
+  DW_CFA_def_cfa: r30 ofs 0
+
+00000014 00000018 00000018 FDE cie=00000000 pc=00000000..00000018
+  DW_CFA_advance_loc: 8 to 00000008
+  DW_CFA_def_cfa_reg: r3
+  DW_CFA_advance_loc: 4 to 0000000c
+  DW_CFA_def_cfa_offset: 4660
+  DW_CFA_advance_loc: 8 to 00000014
+  DW_CFA_def_cfa_reg: r30
+  DW_CFA_nop
+
+00000030 00000018 00000034 FDE cie=00000000 pc=00000018..00000040
+  DW_CFA_advance_loc: 12 to 00000024
+  DW_CFA_def_cfa_reg: r3
+  DW_CFA_offset: r2 at cfa-24
+  DW_CFA_advance_loc: 24 to 0000003c
+  DW_CFA_def_cfa_reg: r30
+  DW_CFA_nop
+  DW_CFA_nop
+  DW_CFA_nop
+
+0000004c 00000010 00000050 FDE cie=00000000 pc=00000040..00000048
+  DW_CFA_nop
+  DW_CFA_nop
+  DW_CFA_nop
+

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