From d3364db9c360c317221971692b59520ef9e69d2a Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 25 Oct 2004 12:26:04 +0000 Subject: [PATCH] Add ARM CFI support --- gas/ChangeLog | 16 ++++++++++++++++ gas/Makefile.am | 2 +- gas/Makefile.in | 6 +++--- gas/aclocal.m4 | 4 ++-- gas/config/tc-arm.c | 26 ++++++++++++++++++++++++++ gas/config/tc-arm.h | 16 +++++++++++++++- gas/doc/Makefile.in | 2 +- gas/testsuite/ChangeLog | 5 +++++ gas/testsuite/gas/cfi/cfi-arm-1.d | 27 +++++++++++++++++++++++++++ gas/testsuite/gas/cfi/cfi-arm-1.s | 23 +++++++++++++++++++++++ gas/testsuite/gas/cfi/cfi.exp | 3 +++ 11 files changed, 122 insertions(+), 8 deletions(-) create mode 100644 gas/testsuite/gas/cfi/cfi-arm-1.d create mode 100644 gas/testsuite/gas/cfi/cfi-arm-1.s diff --git a/gas/ChangeLog b/gas/ChangeLog index a60b747af..fdc74da04 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,19 @@ +2004-10-25 Daniel Jacobowitz + + * Makefile.am: Run dep-am. + * aclocal.m4: Regenerate with automake 1.9.2. + * Makefile.in: Regenerate with automake 1.9.2. + * doc/Makefile.in: Likewise. + + * config/tc-arm.c: Include "dw2gencfi.h". + (tc_arm_regname_to_dw2regnum, tc_arm_frame_initial_instructions): + New functions. + * config/tc-arm.h (TARGET_USE_CFIPOP, DWARF2_DEFAULT_RETURN_COLUMN) + (DWARF2_CIE_DATA_ALIGNMENT, tc_regname_to_dw2regnum) + (tc_cfi_frame_initial_instructions): Define. + (tc_arm_regname_to_dw2regnum, tc_arm_frame_initial_instructions): + Add prototypes. + 2004-10-21 Tomer Levi * config/tc-crx.c (assemble_insn): Check unsigned immediate diff --git a/gas/Makefile.am b/gas/Makefile.am index 20ed5f0aa..71956d3b3 100644 --- a/gas/Makefile.am +++ b/gas/Makefile.am @@ -1036,7 +1036,7 @@ DEPTC_arm_elf = $(INCDIR)/symcat.h $(srcdir)/config/obj-elf.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(srcdir)/config/tc-arm.h \ $(INCDIR)/safe-ctype.h subsegs.h $(INCDIR)/obstack.h \ $(INCDIR)/opcode/arm.h $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h \ - dwarf2dbg.h + dwarf2dbg.h dw2gencfi.h $(INCDIR)/elf/dwarf2.h DEPTC_avr_coff = $(INCDIR)/symcat.h $(srcdir)/config/obj-coff.h \ $(srcdir)/config/tc-avr.h $(INCDIR)/coff/internal.h \ $(BFDDIR)/libcoff.h $(INCDIR)/bfdlink.h $(INCDIR)/safe-ctype.h \ diff --git a/gas/Makefile.in b/gas/Makefile.in index d86cfb0f3..4a94899e9 100644 --- a/gas/Makefile.in +++ b/gas/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.9.1 from Makefile.am. +# Makefile.in generated by automake 1.9.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -825,7 +825,7 @@ DEPTC_arm_elf = $(INCDIR)/symcat.h $(srcdir)/config/obj-elf.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(srcdir)/config/tc-arm.h \ $(INCDIR)/safe-ctype.h subsegs.h $(INCDIR)/obstack.h \ $(INCDIR)/opcode/arm.h $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h \ - dwarf2dbg.h + dwarf2dbg.h dw2gencfi.h $(INCDIR)/elf/dwarf2.h DEPTC_avr_coff = $(INCDIR)/symcat.h $(srcdir)/config/obj-coff.h \ $(srcdir)/config/tc-avr.h $(INCDIR)/coff/internal.h \ @@ -2857,9 +2857,9 @@ distclean-generic: maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." - -rm -f m68k-parse.c -rm -f itbl-lex.c -rm -f itbl-parse.c + -rm -f m68k-parse.c clean: clean-recursive clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ diff --git a/gas/aclocal.m4 b/gas/aclocal.m4 index f107a80ff..eeef70b52 100644 --- a/gas/aclocal.m4 +++ b/gas/aclocal.m4 @@ -1,4 +1,4 @@ -# generated automatically by aclocal 1.9.1 -*- Autoconf -*- +# generated automatically by aclocal 1.9.2 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 # Free Software Foundation, Inc. @@ -40,7 +40,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"]) # Call AM_AUTOMAKE_VERSION so it can be traced. # This function is AC_REQUIREd by AC_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], - [AM_AUTOMAKE_VERSION([1.9.1])]) + [AM_AUTOMAKE_VERSION([1.9.2])]) # AM_AUX_DIR_EXPAND diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index 8af8593ff..af7cd1903 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -41,6 +41,7 @@ #ifdef OBJ_ELF #include "elf/arm.h" #include "dwarf2dbg.h" +#include "dw2gencfi.h" #endif /* XXX Set this to 1 after the next binutils release. */ @@ -14859,6 +14860,31 @@ arm_init_frag (fragS * fragP) fragP->tc_frag_data = thumb_mode; } +#ifdef OBJ_ELF + +/* Convert REGNAME to a DWARF-2 register number. */ + +int +tc_arm_regname_to_dw2regnum (const char *regname) +{ + unsigned int i; + + for (i = 0; rn_table[i].name; i++) + if (streq (regname, rn_table[i].name)) + return rn_table[i].number; + + return -1; +} + +/* Initialize the DWARF-2 unwind information for this procedure. */ + +void +tc_arm_frame_initial_instructions (void) +{ + cfi_add_CFA_def_cfa (REG_SP, 0); +} +#endif + /* This table describes all the machine specific pseudo-ops the assembler has to support. The fields are: pseudo-op name without dot diff --git a/gas/config/tc-arm.h b/gas/config/tc-arm.h index fb8ca8d1b..55f45589d 100644 --- a/gas/config/tc-arm.h +++ b/gas/config/tc-arm.h @@ -180,6 +180,19 @@ enum mstate MAP_THUMB }; +/* We want .cfi_* pseudo-ops for generating unwind info. */ +#define TARGET_USE_CFIPOP 1 + +/* The lr register is r14. */ +#define DWARF2_DEFAULT_RETURN_COLUMN 14 + +/* Registers are generally saved at negative offsets to the CFA. */ +#define DWARF2_CIE_DATA_ALIGNMENT -4 + +/* CFI hooks. */ +#define tc_regname_to_dw2regnum tc_arm_regname_to_dw2regnum +#define tc_cfi_frame_initial_instructions tc_arm_frame_initial_instructions + #else /* Not OBJ_ELF. */ #define GLOBAL_OFFSET_TABLE_NAME "__GLOBAL_OFFSET_TABLE_" #endif @@ -211,4 +224,5 @@ extern void arm_init_frag (struct frag *); extern void arm_handle_align (struct frag *); extern bfd_boolean arm_fix_adjustable (struct fix *); extern int arm_elf_section_type (const char *, size_t); - +extern int tc_arm_regname_to_dw2regnum (const char *regname); +extern void tc_arm_frame_initial_instructions (void); diff --git a/gas/doc/Makefile.in b/gas/doc/Makefile.in index 8bc188cbb..244cb17a3 100644 --- a/gas/doc/Makefile.in +++ b/gas/doc/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.9.1 from Makefile.am. +# Makefile.in generated by automake 1.9.2 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index c1b966851..1639d142f 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-10-23 Daniel Jacobowitz + + * gas/cfi/cfi-arm-1.d, gas/cfi/cfi-arm-1.s: New files. + * gas/cfi/cfi.exp: Run cfi-arm-1 test. + 2004-10-21 Tomer Levi * gas/crx/cop_insn.s: Reverse operands order in store co-processor diff --git a/gas/testsuite/gas/cfi/cfi-arm-1.d b/gas/testsuite/gas/cfi/cfi-arm-1.d new file mode 100644 index 000000000..8474e20bb --- /dev/null +++ b/gas/testsuite/gas/cfi/cfi-arm-1.d @@ -0,0 +1,27 @@ +#readelf: -wf +#name: CFI on ARM + +The section .eh_frame contains: + +00000000 00000010 00000000 CIE + Version: 1 + Augmentation: "zR" + Code alignment factor: 2 + Data alignment factor: -4 + Return address column: 14 + Augmentation data: 1b + + DW_CFA_def_cfa: r13 ofs 0 + +00000014 00000020 00000018 FDE cie=00000000 pc=00000000..00000018 + DW_CFA_advance_loc: 4 to 00000004 + DW_CFA_def_cfa: r12 ofs 0 + DW_CFA_advance_loc: 4 to 00000008 + DW_CFA_def_cfa: r13 ofs 16 + DW_CFA_advance_loc: 4 to 0000000c + DW_CFA_def_cfa_offset: 32 + DW_CFA_offset: r11 at cfa-32 + DW_CFA_offset: r14 at cfa-24 + DW_CFA_advance_loc: 4 to 00000010 + DW_CFA_def_cfa: r11 ofs 16 + diff --git a/gas/testsuite/gas/cfi/cfi-arm-1.s b/gas/testsuite/gas/cfi/cfi-arm-1.s new file mode 100644 index 000000000..8c9d9176b --- /dev/null +++ b/gas/testsuite/gas/cfi/cfi-arm-1.s @@ -0,0 +1,23 @@ +#; $ as -o test.o gas-cfi-test.s && gcc -nostdlib -o test test.o + + .file "a.c" + .text + .align 2 + .global foo + .type foo, %function +foo: + .cfi_startproc + mov ip, sp + .cfi_def_cfa ip, 0 + stmfd sp!, {r0, r1, r2, r3} + .cfi_def_cfa sp, 16 + stmfd sp!, {fp, ip, lr, pc} + .cfi_adjust_cfa_offset 16 + .cfi_rel_offset r11, 0 + .cfi_rel_offset lr, 8 + sub fp, ip, #20 + .cfi_def_cfa fp, 16 + nop + ldmea fp, {fp, sp, pc} + .cfi_endproc + .size foo, .-foo diff --git a/gas/testsuite/gas/cfi/cfi.exp b/gas/testsuite/gas/cfi/cfi.exp index a1dc006ca..21483b14e 100644 --- a/gas/testsuite/gas/cfi/cfi.exp +++ b/gas/testsuite/gas/cfi/cfi.exp @@ -56,6 +56,9 @@ if [istarget "x86_64-*"] then { run_dump_test "cfi-sh-1" } +} elseif { [istarget "arm*-*"] || [istarget "xscale*-*"] } then { + run_dump_test "cfi-arm-1" + } else { return } -- 2.11.4.GIT