public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [patch] gas cfi support for hppa
@ 2005-02-28 16:22 Randolph Chung
  2005-02-28 20:38 ` John David Anglin
  0 siblings, 1 reply; 3+ messages in thread
From: Randolph Chung @ 2005-02-28 16:22 UTC (permalink / raw)
  To: binutils; +Cc: dave, carlos

Carlos asked about cfi support for hppa, so here's a lightly tested
patch. Please apply if ok. Passes the testsuite.

randolph

2005-02-28  Randolph Chung  <tausq@debian.org>

	* config/tc-hppa.c: Include "dw2gencfi.h".
	(tc_hppa_regname_to_dw2regnum, tc_hppa_frame_initial_instructions):
	New functions.
	* config/tc-hppa.h (TARGET_USE_CFIPOP, DWARF2_DEFAULT_RETURN_COLUMN)
	(DWARF2_CIE_DATA_ALIGNMENT, tc_regname_to_dw2regnum)
	(tc_cfi_frame_initial_instructions): Define.
	(tc_hppa_regname_to_dw2regnum, tc_hppa_frame_initial_instructions):
	Add prototypes.

testsuite/
	* gas/cfi/cfi-hppa-1.d, gas/cfi/cfi-hppa-1.s: New files.
	* gas/cfi/cfi.exp: Run cfi-hppa-1 test.

Index: config/tc-hppa.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-hppa.c,v
retrieving revision 1.114
diff -u -p -r1.114 tc-hppa.c
--- config/tc-hppa.c	20 Jul 2004 03:07:08 -0000	1.114
+++ config/tc-hppa.c	28 Feb 2005 14:30:16 -0000
@@ -42,6 +42,7 @@ error only one of OBJ_ELF and OBJ_SOM ca
    then we want to use the assembler support for compact line numbers.  */
 #ifdef OBJ_ELF
 #include "dwarf2dbg.h"
+#include "dw2gencfi.h"
 
 /* A "convenient" place to put object file dependencies which do
    not need to be seen outside of tc-hppa.c.  */
@@ -8732,4 +8733,47 @@ pa_vtable_inherit (ignore)
       new_fix->fx_r_type = (int) R_PARISC_GNU_VTINHERIT;
     }
 }
+
+/* Convert REGNAME to a DWARF-2 register number.  */
+
+int
+tc_hppa_regname_to_dw2regnum (const char *regname)
+{
+  unsigned int regnum = -1;
+  const char *p = regname;
+
+  if (p[0] == 'r')
+    {
+      regnum = strtoul (p + 1, 0, 10);
+    }
+  else if (p[0] == 'f')
+    {
+      regnum = strtoul (p + 1, 0, 10);
+      regnum = (regnum - 4) * 2 + 32;;
+      if (p[strlen (p) - 1] == 'R')
+        regnum++;
+    }
+  else if (strcmp (p, "rp") == 0)
+    {
+      regnum = 2;
+    }
+  else if (strcmp (p, "sp") == 0)
+    {
+      regnum = 30;
+    }
+  else if (strcmp (p, "sar") == 0)
+    {
+      regnum = 32 + (32 - 4) * 2 + 1;
+    }
+
+  return regnum;
+}
+
+/* Initialize the DWARF-2 unwind information for this procedure.  */
+
+void
+tc_hppa_frame_initial_instructions (void)
+{
+  cfi_add_CFA_def_cfa (30, 0);
+}
 #endif
Index: config/tc-hppa.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-hppa.h,v
retrieving revision 1.27
diff -u -p -r1.27 tc-hppa.h
--- config/tc-hppa.h	19 Feb 2005 08:56:08 -0000	1.27
+++ config/tc-hppa.h	28 Feb 2005 14:30:16 -0000
@@ -187,6 +187,23 @@ int hppa_fix_adjustable PARAMS((struct f
 void elf_hppa_final_processing PARAMS ((void));
 
 #define DWARF2_LINE_MIN_INSN_LENGTH 4
+
+/* We want .cfi_* pseudo-ops for generating unwind info.  */
+#define TARGET_USE_CFIPOP              1
+
+/* The rp register is r2.  */
+#define DWARF2_DEFAULT_RETURN_COLUMN	2
+
+/* Registers are generally saved at negative offsets to the CFA.  */
+#define DWARF2_CIE_DATA_ALIGNMENT     -4
+
+/* CFI hooks.  */
+extern int tc_hppa_regname_to_dw2regnum (const char *regname);
+extern void tc_hppa_frame_initial_instructions (void);
+
+#define tc_regname_to_dw2regnum            tc_hppa_regname_to_dw2regnum
+#define tc_cfi_frame_initial_instructions  tc_hppa_frame_initial_instructions
+
 #endif /* OBJ_ELF */
 
 #define md_operand(x)
Index: testsuite/gas/cfi/cfi.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/cfi/cfi.exp,v
retrieving revision 1.13
diff -u -p -r1.13 cfi.exp
--- testsuite/gas/cfi/cfi.exp	25 Oct 2004 12:26:04 -0000	1.13
+++ testsuite/gas/cfi/cfi.exp	28 Feb 2005 14:30:17 -0000
@@ -59,6 +59,9 @@ if [istarget "x86_64-*"] then {
 } elseif { [istarget "arm*-*"] || [istarget "xscale*-*"] } then {
     run_dump_test "cfi-arm-1"
 
+} elseif { [istarget "hppa*-*"] } then {
+    run_dump_test "cfi-hppa-1"
+
 } else {
     return
 }
--- testsuite/gas/cfi/cfi-hppa-1.s	2005-02-28 06:22:35.000000000 -0800
+++ testsuite/gas/cfi/cfi-hppa-1.s	2005-02-28 06:22:35.000000000 -0800
@@ -0,0 +1,38 @@
+	.file	"a.c"
+	.version	"01.01"
+	.LEVEL 1.1
+
+	.file "a.c"
+	.text
+	.align 4
+.globl foo
+	.type	foo, @function
+foo:
+	.PROC
+	.CALLINFO FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=3
+	.ENTRY
+	.cfi_startproc
+	stw %r2,-20(%r30)
+	.cfi_rel_offset r2, -20
+	copy %r3,%r1
+	copy %r30,%r3
+	.cfi_def_cfa_register r3
+	stwm %r1,64(%r30)
+	stw %r26,-36(%r3)
+	.cfi_rel_offset r26, -36
+	stw %r25,-40(%r3)
+	.cfi_rel_offset r25, -40
+	ldw -36(%r3),%r26
+	ldw -40(%r3),%r25
+	bl bar,%r2
+	nop
+	copy %r28,%r19
+	copy %r19,%r28
+	ldw -20(%r3),%r2
+	ldo 64(%r3),%r30
+	ldwm -64(%r30),%r3
+	bv,n %r0(%r2)
+	.cfi_endproc
+	.EXIT
+	.PROCEND
+	.size	foo, .-foo
--- testsuite/gas/cfi/cfi-hppa-1.d	2005-02-28 06:23:15.000000000 -0800
+++ testsuite/gas/cfi/cfi-hppa-1.d	2005-02-28 06:23:15.000000000 -0800
@@ -0,0 +1,28 @@
+#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: -4
+  Return address column: 2
+  Augmentation data:     1b
+
+  DW_CFA_def_cfa: r30 ofs 0
+
+00000014 0000001c 00000018 FDE cie=00000000 pc=00000000..00000040
+  DW_CFA_advance_loc: 4 to 00000004
+  DW_CFA_offset: r2 at cfa-20
+  DW_CFA_advance_loc: 8 to 0000000c
+  DW_CFA_def_cfa_reg: r3
+  DW_CFA_advance_loc: 8 to 00000014
+  DW_CFA_offset: r26 at cfa-36
+  DW_CFA_advance_loc: 4 to 00000018
+  DW_CFA_offset: r25 at cfa-40
+  DW_CFA_nop
+  DW_CFA_nop
+  DW_CFA_nop
+

-- 
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] gas cfi support for hppa
  2005-02-28 16:22 [patch] gas cfi support for hppa Randolph Chung
@ 2005-02-28 20:38 ` John David Anglin
  0 siblings, 0 replies; 3+ messages in thread
From: John David Anglin @ 2005-02-28 20:38 UTC (permalink / raw)
  To: randolph; +Cc: binutils, carlos

> Carlos asked about cfi support for hppa, so here's a lightly tested
> patch. Please apply if ok. Passes the testsuite.

Did you check change under hpux 32-bit?  I don't think that we want
to run the cfi test using som.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] gas cfi support for hppa
       [not found] <20050228234703.GG4645@tausq.org>
@ 2005-03-01  4:01 ` John David Anglin
  0 siblings, 0 replies; 3+ messages in thread
From: John David Anglin @ 2005-03-01  4:01 UTC (permalink / raw)
  To: randolph; +Cc: binutils, carlos

> the code and test only runs on elf targets.

Test fails on hppa64-hpux.  The .globl line needs indentation.
After fixing this, we have

Running /xxx/gnu/binutils-2.15.90/src/gas/testsuite/gas/cfi/cfi.exp ...
/xxx/gnu/binutils-2.15.90/src/gas/testsuite/lib/run ../as-new   -o dump.o /xxx/g
nu/binutils-2.15.90/src/gas/testsuite/gas/cfi/cfi-hppa-1.s
/xxx/gnu/binutils-2.15.90/objdir/gas/testsuite/../../binutils/readelf  -wf dump.
o > dump.out
regexp_diff match failure
regexp "^00000014 0000001c 00000018 FDE cie=00000000 pc=00000000..00000040$"
line   "00000014 00000020 00000018 FDE cie=00000000 pc=00000000..00000040"
extra lines in dump.out starting with "^  DW_CFA_nop$"
EOF from /xxx/gnu/binutils-2.15.90/src/gas/testsuite/gas/cfi/cfi-hppa-1.d
FAIL: CFI on HPPA

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-03-01  4:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-28 16:22 [patch] gas cfi support for hppa Randolph Chung
2005-02-28 20:38 ` John David Anglin
     [not found] <20050228234703.GG4645@tausq.org>
2005-03-01  4:01 ` John David Anglin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).