From c04898f807516f8361a4ec6f55b984bdf0955f7e Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Fri, 8 Aug 2003 14:46:41 +0000 Subject: [PATCH] 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. --- gas/ChangeLog | 10 +++++ gas/config/tc-m68k.c | 34 ++++++++++++++++- gas/config/tc-m68k.h | 12 ++++++ gas/testsuite/ChangeLog | 5 +++ gas/testsuite/gas/cfi/cfi-m68k.d | 33 ++++++++++++++++ gas/testsuite/gas/cfi/cfi-m68k.s | 64 ++++++++++++++++++++++++++++++++ gas/testsuite/gas/cfi/cfi.exp | 3 ++ 7 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 gas/testsuite/gas/cfi/cfi-m68k.d create mode 100644 gas/testsuite/gas/cfi/cfi-m68k.s diff --git a/gas/ChangeLog b/gas/ChangeLog index b1cf375c550..155917fdeb6 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,13 @@ +2003-08-08 Andreas Schwab + + * 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. + 2003-08-08 Dmitry Diky * config/tc-msp430.c: Add xW42 and xE42 parts. Sort MPU list diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c index d913dc6c528..2c213c6a152 100644 --- a/gas/config/tc-m68k.c +++ b/gas/config/tc-m68k.c @@ -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); +} diff --git a/gas/config/tc-m68k.h b/gas/config/tc-m68k.h index 477030049b9..11828201a0f 100644 --- a/gas/config/tc-m68k.h +++ b/gas/config/tc-m68k.h @@ -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); diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 51a12396195..f372e873aa7 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-08-08 Andreas Schwab + + * gas/cfi/cfi-m68k.s, gas/cfi/cfi-m68k.d: New test. + * gas/cfi/cfi.exp (run_list_test): Run it. + 2003-08-06 Jason Eckhardt * gas/i860/dir-align01.{s,d}: New files. diff --git a/gas/testsuite/gas/cfi/cfi-m68k.d b/gas/testsuite/gas/cfi/cfi-m68k.d new file mode 100644 index 00000000000..a7287591d40 --- /dev/null +++ b/gas/testsuite/gas/cfi/cfi-m68k.d @@ -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 diff --git a/gas/testsuite/gas/cfi/cfi-m68k.s b/gas/testsuite/gas/cfi/cfi-m68k.s new file mode 100644 index 00000000000..6bf0cb2b8cf --- /dev/null +++ b/gas/testsuite/gas/cfi/cfi-m68k.s @@ -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 diff --git a/gas/testsuite/gas/cfi/cfi.exp b/gas/testsuite/gas/cfi/cfi.exp index 8824c227e94..d1b1ca876b1 100644 --- a/gas/testsuite/gas/cfi/cfi.exp +++ b/gas/testsuite/gas/cfi/cfi.exp @@ -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 } -- 2.30.2