public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Dwarf2 cfi for m68k
@ 2003-08-03 17:29 Andreas Schwab
  2003-08-08  6:35 ` Ben Elliston
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2003-08-03 17:29 UTC (permalink / raw)
  To: binutils

This implements the target dependent dwarf2 cfi support for m68k.

Andreas.

gas/
	* config/tc-m68k.h (TARGET_USE_CFIPOP)
	(DWARF2_DEFAULT_RETURN_COLUMN, DWARF2_CIE_DATA_ALIGNMENT)
	(tc_regname_to_dw2regnum, tc_cfi_frame_initial_instructions):
	Define.

	* config/tc-m68k.c: Include "dw2gencfi.h".
	(tc_m68k_regname_to_dw2regnum)
	(tc_m68k_frame_initial_instructions): New functions.

gas/testsuite/
	* gas/cfi/cfi-m68k.s, gas/cfi/cfi-m68k.d: New test.
	* gas/cfi/cfi.exp (run_list_test): Run it.

Index: gas/config/tc-m68k.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-m68k.c,v
retrieving revision 1.44
diff -u -a -p -r1.44 tc-m68k.c
--- gas/config/tc-m68k.c	21 May 2003 12:07:55 -0000	1.44
+++ gas/config/tc-m68k.c	3 Aug 2003 17:11:14 -0000
@@ -1,6 +1,6 @@
 /* tc-m68k.c -- Assemble for the m68k family
    Copyright 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002
+   2000, 2001, 2002, 2003
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -25,6 +25,7 @@
 #include "obstack.h"
 #include "subsegs.h"
 #include "dwarf2dbg.h"
+#include "dw2gencfi.h"
 
 #include "opcode/m68k.h"
 #include "m68k-parse.h"
@@ -7146,3 +7147,34 @@ m68k_elf_final_processing ()
     elf_elfheader (stdoutput)->e_flags |= EF_M68000;
 }
 #endif
+
+int
+tc_m68k_regname_to_dw2regnum (const char *regname)
+{
+  unsigned int regnum;
+  static const char *const regnames[] =
+    {
+      "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
+      "a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp",
+      "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7",
+      "pc"
+    };
+
+  for (regnum = 0; regnum < ARRAY_SIZE (regnames); regnum++)
+    if (strcmp (regname, regnames[regnum]) == 0)
+      return regnum;
+
+  return -1;
+}
+
+void
+tc_m68k_frame_initial_instructions (void)
+{
+  static int sp_regno = -1;
+
+  if (sp_regno < 0)
+    sp_regno = tc_m68k_regname_to_dw2regnum ("sp");
+
+  cfi_add_CFA_def_cfa (sp_regno, -DWARF2_CIE_DATA_ALIGNMENT);
+  cfi_add_CFA_offset (DWARF2_DEFAULT_RETURN_COLUMN, DWARF2_CIE_DATA_ALIGNMENT);
+}
Index: gas/config/tc-m68k.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-m68k.h,v
retrieving revision 1.13
diff -u -a -p -r1.13 tc-m68k.h
--- gas/config/tc-m68k.h	23 Jan 2003 12:51:05 -0000	1.13
+++ gas/config/tc-m68k.h	3 Aug 2003 17:11:14 -0000
@@ -220,3 +220,15 @@ extern struct relax_type md_relax_table[
   while (0)
 
 #define DWARF2_LINE_MIN_INSN_LENGTH 2
+
+/* We want .cfi_* pseudo-ops for generating unwind info.  */
+#define TARGET_USE_CFIPOP 1
+
+#define DWARF2_DEFAULT_RETURN_COLUMN 24
+#define DWARF2_CIE_DATA_ALIGNMENT (-4)
+
+#define tc_regname_to_dw2regnum tc_m68k_regname_to_dw2regnum
+extern int tc_m68k_regname_to_dw2regnum (const char *regname);
+
+#define tc_cfi_frame_initial_instructions tc_m68k_frame_initial_instructions
+extern void tc_m68k_frame_initial_instructions (void);
Index: gas/testsuite/gas/cfi/cfi-m68k.d
===================================================================
RCS file: gas/testsuite/gas/cfi/cfi-m68k.d
diff -N gas/testsuite/gas/cfi/cfi-m68k.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/cfi/cfi-m68k.d	3 Aug 2003 17:11:15 -0000
@@ -0,0 +1,33 @@
+#readelf: -wf
+#name: CFI on m68k
+The section .eh_frame contains:
+
+00000000 00000012 00000000 CIE
+  Version:               1
+  Augmentation:          "zR"
+  Code alignment factor: 2
+  Data alignment factor: -4
+  Return address column: 24
+  Augmentation data:     1b
+
+  DW_CFA_def_cfa: r15 ofs 4
+  DW_CFA_offset: r24 at cfa-4
+
+00000016 00000014 0000001a FDE cie=00000000 pc=0000001e..0000002a
+  DW_CFA_advance_loc: 4 to 00000022
+  DW_CFA_def_cfa_offset: 4664
+  DW_CFA_advance_loc: 6 to 00000028
+  DW_CFA_def_cfa_offset: 4
+
+0000002e 00000017 00000032 FDE cie=00000000 pc=00000036..00000042
+  DW_CFA_advance_loc: 4 to 0000003a
+  DW_CFA_def_cfa_offset: 8
+  DW_CFA_offset: r14 at cfa-8
+  DW_CFA_def_cfa_reg: r14
+  DW_CFA_advance_loc: 6 to 00000040
+  DW_CFA_def_cfa_reg: r15
+
+00000049 0000000f 0000004d FDE cie=00000000 pc=00000051..00000055
+
+  DW_CFA_nop
+  DW_CFA_nop
Index: gas/testsuite/gas/cfi/cfi-m68k.s
===================================================================
RCS file: gas/testsuite/gas/cfi/cfi-m68k.s
diff -N gas/testsuite/gas/cfi/cfi-m68k.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gas/testsuite/gas/cfi/cfi-m68k.s	3 Aug 2003 17:11:15 -0000
@@ -0,0 +1,64 @@
+#; $ as -o test.o gas-cfi-test.s && gcc -nostdlib -o test test.o
+
+	.text
+
+#; func_locvars
+#; - function with a space on the stack 
+#;   allocated for local variables
+
+	.type	func_locvars,@function
+func_locvars:
+	.cfi_startproc
+	
+	#; alocate space for local vars
+	suba.w	#0x1234,%sp
+	.cfi_adjust_cfa_offset	0x1234
+	
+	#; dummy body
+	moveq.l	#1,%d0
+	
+	#; release space of local vars and return
+	adda.w	#0x1234,%sp
+	.cfi_adjust_cfa_offset	-0x1234
+	rts
+	.cfi_endproc
+
+#; func_prologue
+#; - functions that begins with standard
+#;   prologue: "link %a6,#0"
+
+	.type	func_prologue,@function
+func_prologue:
+	.cfi_startproc
+	
+	#; prologue, CFI is valid after 
+	#; each instruction.
+	link	%a6,#0
+	.cfi_def_cfa_offset	8
+	.cfi_offset		a6,-8
+	.cfi_def_cfa_register	a6
+
+	#; function body
+	jbsr	func_locvars
+	addq.l	#3, %d0
+
+	#; epilogue with valid CFI
+	#; (we're better than gcc :-)
+	unlk	%a6
+	.cfi_def_cfa_register	sp
+	rts
+	.cfi_endproc
+
+#; main
+#; - typical function
+	.type	main,@function
+main:
+	.cfi_startproc
+	
+	#; only function body that doesn't
+	#; touch the stack at all.
+	jbsr	func_prologue
+	
+	#; return
+	rts
+	.cfi_endproc
Index: gas/testsuite/gas/cfi/cfi.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/cfi/cfi.exp,v
retrieving revision 1.8
diff -u -a -p -r1.8 cfi.exp
--- gas/testsuite/gas/cfi/cfi.exp	10 Jul 2003 16:46:38 -0000	1.8
+++ gas/testsuite/gas/cfi/cfi.exp	3 Aug 2003 17:11:15 -0000
@@ -36,6 +36,9 @@ if [istarget "x86_64-*"] then {
 	run_dump_test "cfi-s390x-1"
     }
 
+} elseif { [istarget "m68*-*"] } then {
+    run_dump_test "cfi-m68k"
+
 } else {
     return
 }

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

* Re: Dwarf2 cfi for m68k
  2003-08-03 17:29 Dwarf2 cfi for m68k Andreas Schwab
@ 2003-08-08  6:35 ` Ben Elliston
  2003-08-08 14:31   ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Elliston @ 2003-08-08  6:35 UTC (permalink / raw)
  To: binutils

Andreas Schwab <schwab@suse.de> writes:

> This implements the target dependent dwarf2 cfi support for m68k.

This looks okay.  Are any documentation changes required?

Ben

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

* Re: Dwarf2 cfi for m68k
  2003-08-08  6:35 ` Ben Elliston
@ 2003-08-08 14:31   ` Andreas Schwab
  2003-08-08 22:39     ` Ben Elliston
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2003-08-08 14:31 UTC (permalink / raw)
  To: Ben Elliston; +Cc: binutils

Ben Elliston <bje@wasabisystems.com> writes:

|> Andreas Schwab <schwab@suse.de> writes:
|> 
|> > This implements the target dependent dwarf2 cfi support for m68k.
|> 
|> This looks okay.  Are any documentation changes required?

There are currently no arch specific docs about cfi.  The only thing that
might be worth documenting are the names of the registers that are
recognised, but that are the same that the assembler already knows about.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: Dwarf2 cfi for m68k
  2003-08-08 14:31   ` Andreas Schwab
@ 2003-08-08 22:39     ` Ben Elliston
  0 siblings, 0 replies; 4+ messages in thread
From: Ben Elliston @ 2003-08-08 22:39 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: binutils

Andreas Schwab <schwab@suse.de> writes:

> There are currently no arch specific docs about cfi.  The only thing
> that might be worth documenting are the names of the registers that
> are recognised, but that are the same that the assembler already
> knows about.

OK, then.

Ben

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

end of thread, other threads:[~2003-08-08 22:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-03 17:29 Dwarf2 cfi for m68k Andreas Schwab
2003-08-08  6:35 ` Ben Elliston
2003-08-08 14:31   ` Andreas Schwab
2003-08-08 22:39     ` Ben Elliston

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).