This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
RE: [PATCH/RFA] SH: cfi stuff
- From: "Stubbs, Andrew" <andrew dot stubbs at superh dot com>
- To: "Kaz Kojima" <kkojima at rr dot iij4u dot or dot jp>, <binutils at sources dot redhat dot com>
- Date: Wed, 17 Mar 2004 15:35:54 -0000
- Subject: RE: [PATCH/RFA] SH: cfi stuff
I don't know anything about the CFI stuff, but, since you have added a
new include file, shouldn't you update the makefile dependecies?
--
Andrew Stubbs
SuperH (UK) Ltd.
> -----Original Message-----
> From: binutils-owner@sources.redhat.com
> [mailto:binutils-owner@sources.redhat.com] On Behalf Of Kaz Kojima
> Sent: 17 March 2004 3:56 AM
> To: binutils@sources.redhat.com
> Subject: [PATCH/RFA] SH: cfi stuff
>
>
> Hi,
>
> The attached patch adds cfi_ stuff for SH gas. There are no
> regressions
> on sh-elf and sh64-elf. It seems work in my local glibc work
> too. I'd
> like to get approval for it because the testsuite portion touches the
> generic part slightly.
>
> I'm happy if I get ok also for 2.15.
>
> Regards,
> kaz
> --
> 2004-03-17 Kaz Kojima <kkojima@rr.iij4u.or.jp>
> [gas]
> * config/tc-sh.c: Include dw2gencfi.h.
> (sh_cfi_frame_initial_instructions): New function.
> (sh_regname_to_dw2regnum): Likewise.
> * config/tc-sh.h (DWARF2_LINE_MIN_INSN_LENGTH): Move to
> the end of
> file.
> (TARGET_USE_CFIPOP): Define.
> (tc_cfi_frame_initial_instructions): Likewise.
> (tc_regname_to_dw2regnum): Likewise.
> (DWARF2_DEFAULT_RETURN_COLUMN,
> DWARF2_CIE_DATA_ALIGNMENT): Likewise.
>
> [gas/testsuite]
> * gas/cfi/cfi-sh-1.d: New file.
> * gas/cfi/cfi-sh-1.s: Likewise.
> * gas/cfi/cfi.exp: Add SH case.
>
> diff -u3prN ORIG/src/gas/config/tc-sh.c LOCAL/src/gas/config/tc-sh.c
> --- ORIG/src/gas/config/tc-sh.c Thu Mar 4 08:17:32 2004
> +++ LOCAL/src/gas/config/tc-sh.c Thu Mar 4 08:39:43 2004
> @@ -35,6 +35,7 @@
> #endif
>
> #include "dwarf2dbg.h"
> +#include "dw2gencfi.h"
>
> typedef struct
> {
> @@ -4341,4 +4342,53 @@ sh_parse_name (char const *name, express
> return 1;
> }
> #endif
> +
> +void
> +sh_cfi_frame_initial_instructions (void)
> +{
> + cfi_add_CFA_def_cfa (15, 0);
> +}
> +
> +int
> +sh_regname_to_dw2regnum (const char *regname)
> +{
> + unsigned int regnum = -1;
> + unsigned int i;
> + const char *p;
> + char *q;
> + static struct { char *name; int dw2regnum; } regnames[] =
> + {
> + { "pr", 17 }, { "t", 18 }, { "gbr", 19 }, { "mach", 20 },
> + { "macl", 21 }, { "fpul", 23 }
> + };
> +
> + 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 >= 16)
> + return -1;
> + }
> + else if (regname[0] == 'f' && regname[1] == 'r')
> + {
> + p = regname + 2;
> + regnum = strtoul (p, &q, 10);
> + if (p == q || *q || regnum >= 16)
> + return -1;
> + regnum += 25;
> + }
> + else if (regname[0] == 'x' && regname[1] == 'd')
> + {
> + p = regname + 2;
> + regnum = strtoul (p, &q, 10);
> + if (p == q || *q || regnum >= 8)
> + return -1;
> + regnum += 87;
> + }
> + return regnum;
> +}
> #endif /* BFD_ASSEMBLER */
> diff -u3prN ORIG/src/gas/config/tc-sh.h LOCAL/src/gas/config/tc-sh.h
> --- ORIG/src/gas/config/tc-sh.h Sun Oct 12 06:32:39 2003
> +++ LOCAL/src/gas/config/tc-sh.h Thu Mar 4 08:39:43 2004
> @@ -42,9 +42,6 @@ extern int sh_small;
> /* Don't try to break words. */
> #define WORKING_DOT_WORD
>
> -/* All SH instructions are multiples of 16 bits. */
> -#define DWARF2_LINE_MIN_INSN_LENGTH 2
> -
> /* We require .long, et. al., to be aligned correctly. */
> #define md_cons_align(nbytes) sh_cons_align (nbytes)
> extern void sh_cons_align (int);
> @@ -260,5 +257,18 @@ void sh_cons_fix_new (fragS *, int, int,
> /* This is used to construct expressions out of @GOTOFF,
> @PLT and @GOT
> symbols. The relocation type is stored in X_md. */
> #define O_PIC_reloc O_md1
> +
> +#define TARGET_USE_CFIPOP 1
> +
> +#define tc_cfi_frame_initial_instructions
> sh_cfi_frame_initial_instructions
> +extern void sh_cfi_frame_initial_instructions (void);
> +
> +#define tc_regname_to_dw2regnum sh_regname_to_dw2regnum
> +extern int sh_regname_to_dw2regnum (const char *regname);
> +
> +/* All SH instructions are multiples of 16 bits. */
> +#define DWARF2_LINE_MIN_INSN_LENGTH 2
> +#define DWARF2_DEFAULT_RETURN_COLUMN 17
> +#define DWARF2_CIE_DATA_ALIGNMENT -4
>
> #endif /* OBJ_ELF */
> diff -u3prN ORIG/src/gas/testsuite/gas/cfi/cfi-sh-1.d
> LOCAL/src/gas/testsuite/gas/cfi/cfi-sh-1.d
> --- ORIG/src/gas/testsuite/gas/cfi/cfi-sh-1.d Thu Jan 1 09:00:00 1970
> +++ LOCAL/src/gas/testsuite/gas/cfi/cfi-sh-1.d Thu Mar
> 4 08:39:43 2004
> @@ -0,0 +1,29 @@
> +#readelf: -wf
> +#name: CFI on SH
> +The section .eh_frame contains:
> +
> +00000000 00000010 00000000 CIE
> + Version: 1
> + Augmentation: "zR"
> + Code alignment factor: 2
> + Data alignment factor: -4
> + Return address column: 17
> + Augmentation data: 1b
> +
> + DW_CFA_def_cfa: r15 ofs 0
> +
> +00000014 00000020 00000018 FDE cie=00000000 pc=0000001c..00000048
> + DW_CFA_advance_loc: 2 to 0000001e
> + DW_CFA_def_cfa_offset: 4
> + DW_CFA_advance_loc: 2 to 00000020
> + DW_CFA_def_cfa_offset: 8
> + DW_CFA_offset: r15 at cfa-4
> + DW_CFA_offset: r17 at cfa-8
> + DW_CFA_advance_loc: 6 to 00000026
> + DW_CFA_def_cfa_reg: r14
> + DW_CFA_advance_loc: 2 to 00000028
> + DW_CFA_def_cfa_offset: 40
> + DW_CFA_nop
> + DW_CFA_nop
> + DW_CFA_nop
> +
> diff -u3prN ORIG/src/gas/testsuite/gas/cfi/cfi-sh-1.s
> LOCAL/src/gas/testsuite/gas/cfi/cfi-sh-1.s
> --- ORIG/src/gas/testsuite/gas/cfi/cfi-sh-1.s Thu Jan 1 09:00:00 1970
> +++ LOCAL/src/gas/testsuite/gas/cfi/cfi-sh-1.s Thu Mar
> 4 08:39:43 2004
> @@ -0,0 +1,39 @@
> + .file "a.c"
> + .text
> + .align 1
> + .globl foo
> + .type foo, @function
> +foo:
> + .cfi_startproc
> + mov.l r14,@-r15
> + .cfi_adjust_cfa_offset 4
> + sts.l pr,@-r15
> + .cfi_adjust_cfa_offset 4
> + .cfi_offset r15,-4
> + .cfi_offset pr,-8
> + tst r4,r4
> + bt/s .L2
> + mov r15,r14
> + .cfi_def_cfa_register r14
> + add #-32,r15
> + .cfi_adjust_cfa_offset 32
> + mov.l .L3,r0
> + jsr @r0
> + mov r15,r4
> +.L2:
> + mov.l .L4,r0
> + jsr @r0
> + nop
> + mov #0,r0
> + mov r14,r15
> + lds.l @r15+,pr
> + rts
> + mov.l @r15+,r14
> +.L5:
> + .align 2
> +.L3:
> + .long bar
> +.L4:
> + .long baz
> + .cfi_endproc
> + .size foo, .-foo
> diff -u3prN ORIG/src/gas/testsuite/gas/cfi/cfi.exp
> LOCAL/src/gas/testsuite/gas/cfi/cfi.exp
> --- ORIG/src/gas/testsuite/gas/cfi/cfi.exp Mon Sep 1 20:16:58 2003
> +++ LOCAL/src/gas/testsuite/gas/cfi/cfi.exp Thu Mar 4 08:39:43 2004
> @@ -49,6 +49,13 @@ if [istarget "x86_64-*"] then {
> if { [regexp "elf64\[_-\]sparc" $nm_help] } then {
> run_dump_test "cfi-sparc64-1"
> }
> +
> +} elseif [istarget "sh*-*"] then {
> + if { [istarget sh64*-*-*] || [istarget sh5*-*-*] } then {
> + } else {
> + run_dump_test "cfi-sh-1"
> + }
> +
> } else {
> return
> }
>