From a4d54e17570429aae06bad837f4d9547e5882ac5 Mon Sep 17 00:00:00 2001 From: Elena Zannoni Date: Sun, 3 Nov 2002 21:54:26 +0000 Subject: [PATCH] merge from mainline --- include/ChangeLog | 20 ++++++++ include/ansidecl.h | 5 +- include/elf/ChangeLog | 4 ++ include/elf/sh.h | 16 +++++-- include/getopt.h | 8 ++-- include/opcode/ChangeLog | 4 ++ include/opcode/cgen.h | 16 +++---- include/partition.h | 4 ++ libiberty/ChangeLog | 10 ++++ libiberty/config.table | 1 + libiberty/cplus-dem.c | 18 ++++---- opcodes/ChangeLog | 12 +++++ opcodes/m68hc11-dis.c | 99 ++++++++++++++++++++-------------------- opcodes/sparc-opc.c | 38 +++++++-------- sim/common/ChangeLog | 4 ++ sim/common/cgen-trace.h | 2 +- sim/sh/ChangeLog | 8 ++++ sim/sh/gencode.c | 33 ++++---------- sim/sh/interp.c | 19 ++++++-- 19 files changed, 200 insertions(+), 121 deletions(-) diff --git a/include/ChangeLog b/include/ChangeLog index 257e381931f..8efd9a3cd0b 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,23 @@ +2002-10-26 Roger Sayle + + * partition.h: Close the extern "C" scope when compiling with C++. + +2002-10-26 Roger Sayle + DJ Delorie + + PR bootstrap/8351 + * getopt.h: Avoid prototyping getopt with no arguments in C++. + +2002-10-24 Nathan Tallent + + * ansidecl.h (__STDC__): Add (__alpha && __cplusplus) to the + list of platform compilers that may look, smell and act + like __STDC__ but that may not define it. + +2002-10-11 David O'Brien + + * getopt.h: getopt is in unistd.h (based on SUSv2). + 2002-09-26 Jakub Jelinek * elf/x86-64.h: Add TLS relocs. diff --git a/include/ansidecl.h b/include/ansidecl.h index 9a7c5777ff2..d169b4f50ed 100644 --- a/include/ansidecl.h +++ b/include/ansidecl.h @@ -136,10 +136,13 @@ So instead we use the macro below and test it against specific values. */ #define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) #endif /* GCC_VERSION */ -#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32) +#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32) || (defined(__alpha) && defined(__cplusplus)) /* All known AIX compilers implement these things (but don't always define __STDC__). The RISC/OS MIPS compiler defines these things in SVR4 mode, but does not define __STDC__. */ +/* eraxxon@alumni.rice.edu: The Compaq C++ compiler, unlike many other + C++ compilers, does not define __STDC__, though it acts as if this + was so. (Verified versions: 5.7, 6.2, 6.3, 6.5) */ #define ANSI_PROTOTYPES 1 #define PTR void * diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog index 254b2c425b1..65f3160af38 100644 --- a/include/elf/ChangeLog +++ b/include/elf/ChangeLog @@ -1,3 +1,7 @@ +2002-10-11 Kaz Kojima + + * sh.h: Add SH TLS relocs. + 2002-09-30 Gavin Romig-Koch Ken Raeburn Aldy Hernandez diff --git a/include/elf/sh.h b/include/elf/sh.h index af78c9bb04e..ef964d685e8 100644 --- a/include/elf/sh.h +++ b/include/elf/sh.h @@ -167,7 +167,17 @@ START_RELOC_NUMBERS (elf_sh_reloc_type) RELOC_NUMBER (R_SH_DIR10SL, 50) RELOC_NUMBER (R_SH_DIR10SQ, 51) FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_3, 52) - FAKE_RELOC (R_SH_LAST_INVALID_RELOC_3, 159) + FAKE_RELOC (R_SH_LAST_INVALID_RELOC_3, 143) + RELOC_NUMBER (R_SH_TLS_GD_32, 144) + RELOC_NUMBER (R_SH_TLS_LD_32, 145) + RELOC_NUMBER (R_SH_TLS_LDO_32, 146) + RELOC_NUMBER (R_SH_TLS_IE_32, 147) + RELOC_NUMBER (R_SH_TLS_LE_32, 148) + RELOC_NUMBER (R_SH_TLS_DTPMOD32, 149) + RELOC_NUMBER (R_SH_TLS_DTPOFF32, 150) + RELOC_NUMBER (R_SH_TLS_TPOFF32, 151) + FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_4, 152) + FAKE_RELOC (R_SH_LAST_INVALID_RELOC_4, 159) RELOC_NUMBER (R_SH_GOT32, 160) RELOC_NUMBER (R_SH_PLT32, 161) RELOC_NUMBER (R_SH_COPY, 162) @@ -205,8 +215,8 @@ START_RELOC_NUMBERS (elf_sh_reloc_type) RELOC_NUMBER (R_SH_GLOB_DAT64, 194) RELOC_NUMBER (R_SH_JMP_SLOT64, 195) RELOC_NUMBER (R_SH_RELATIVE64, 196) - FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_4, 197) - FAKE_RELOC (R_SH_LAST_INVALID_RELOC_4, 241) + FAKE_RELOC (R_SH_FIRST_INVALID_RELOC_5, 197) + FAKE_RELOC (R_SH_LAST_INVALID_RELOC_5, 241) RELOC_NUMBER (R_SH_SHMEDIA_CODE, 242) RELOC_NUMBER (R_SH_PT_16, 243) RELOC_NUMBER (R_SH_IMMS16, 244) diff --git a/include/getopt.h b/include/getopt.h index 0c6470b3ddb..a99a2290159 100644 --- a/include/getopt.h +++ b/include/getopt.h @@ -1,6 +1,6 @@ /* Declarations for getopt. - Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 2000 - Free Software Foundation, Inc. + Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 2000, + 2002 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@gnu.org. @@ -108,11 +108,13 @@ struct option #if !HAVE_DECL_GETOPT #if defined (__GNU_LIBRARY__) || defined (HAVE_DECL_GETOPT) /* Many other libraries have conflicting prototypes for getopt, with - differences in the consts, in stdlib.h. To avoid compilation + differences in the consts, in unistd.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ extern int getopt (int argc, char *const *argv, const char *shortopts); #else +#ifndef __cplusplus extern int getopt (); +#endif /* __cplusplus */ #endif #endif /* !HAVE_DECL_GETOPT */ diff --git a/include/opcode/ChangeLog b/include/opcode/ChangeLog index ab908ec92c3..af5707e8e88 100644 --- a/include/opcode/ChangeLog +++ b/include/opcode/ChangeLog @@ -1,3 +1,7 @@ +2002-10-14 Alan Modra + + * cgen.h: Test __BFD_H_SEEN__ rather than BFD_VERSION_DATE. + 2002-09-30 Gavin Romig-Koch Ken Raeburn Aldy Hernandez diff --git a/include/opcode/cgen.h b/include/opcode/cgen.h index 09c5cbf03a6..89477985e5d 100644 --- a/include/opcode/cgen.h +++ b/include/opcode/cgen.h @@ -26,7 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., Perhaps the definition of bfd_vma can be moved outside of bfd.h. Or perhaps one could duplicate its definition in another file. Until such time, this file conditionally compiles definitions that require - bfd_vma using BFD_VERSION_DATE. */ + bfd_vma using __BFD_H_SEEN__. */ /* Enums must be defined before they can be used. Allow them to be used in struct definitions, even though the enum must @@ -276,7 +276,7 @@ typedef const char * (cgen_parse_fn) PC is the pc value of the insn. The result is an error message or NULL if success. */ -#ifdef BFD_VERSION_DATE +#ifdef __BFD_H_SEEN__ typedef const char * (cgen_insert_fn) PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *insn_, CGEN_FIELDS *fields_, CGEN_INSN_BYTES_PTR insnp_, @@ -297,7 +297,7 @@ typedef const char * (cgen_insert_fn) (); PC is the pc value of the insn. The result is the length of the insn in bits or zero if not recognized. */ -#ifdef BFD_VERSION_DATE +#ifdef __BFD_H_SEEN__ typedef int (cgen_extract_fn) PARAMS ((CGEN_CPU_DESC, const CGEN_INSN *insn_, CGEN_EXTRACT_INFO *ex_info_, CGEN_INSN_INT base_insn_, @@ -316,7 +316,7 @@ typedef int (cgen_extract_fn) (); PC is the pc value of the insn. LEN is the length of the insn, in bits. */ -#ifdef BFD_VERSION_DATE +#ifdef __BFD_H_SEEN__ typedef void (cgen_print_fn) PARAMS ((CGEN_CPU_DESC, PTR info_, const CGEN_INSN *insn_, CGEN_FIELDS *fields_, bfd_vma pc_, int len_)); @@ -381,7 +381,7 @@ enum cgen_parse_operand_result CGEN_PARSE_OPERAND_RESULT_ERROR }; -#ifdef BFD_VERSION_DATE /* Don't require bfd.h unnecessarily. */ +#ifdef __BFD_H_SEEN__ /* Don't require bfd.h unnecessarily. */ typedef const char * (cgen_parse_operand_fn) PARAMS ((CGEN_CPU_DESC, enum cgen_parse_operand_type, const char **, int, int, @@ -565,7 +565,7 @@ const CGEN_KEYWORD_ENTRY *cgen_keyword_search_next extern const char *cgen_parse_keyword PARAMS ((CGEN_CPU_DESC, const char **, CGEN_KEYWORD *, long *)); -#ifdef BFD_VERSION_DATE /* Don't require bfd.h unnecessarily. */ +#ifdef __BFD_H_SEEN__ /* Don't require bfd.h unnecessarily. */ extern const char *cgen_parse_signed_integer PARAMS ((CGEN_CPU_DESC, const char **, int, long *)); extern const char *cgen_parse_unsigned_integer @@ -1253,7 +1253,7 @@ typedef struct cgen_cpu_desc const char * (*parse_operand) PARAMS ((CGEN_CPU_DESC, int opindex_, const char **, CGEN_FIELDS *fields_)); -#ifdef BFD_VERSION_DATE +#ifdef __BFD_H_SEEN__ const char * (*insert_operand) PARAMS ((CGEN_CPU_DESC, int opindex_, CGEN_FIELDS *fields_, CGEN_INSN_BYTES_PTR, bfd_vma pc_)); @@ -1286,7 +1286,7 @@ typedef struct cgen_cpu_desc PARAMS ((CGEN_CPU_DESC, int opindex_, const CGEN_FIELDS *fields_)); void (*set_int_operand) PARAMS ((CGEN_CPU_DESC, int opindex_, CGEN_FIELDS *fields_, int value_)); -#ifdef BFD_VERSION_DATE +#ifdef __BFD_H_SEEN__ bfd_vma (*get_vma_operand) PARAMS ((CGEN_CPU_DESC, int opindex_, const CGEN_FIELDS *fields_)); void (*set_vma_operand) diff --git a/include/partition.h b/include/partition.h index 885a79b4ba3..5d3623f716e 100644 --- a/include/partition.h +++ b/include/partition.h @@ -78,4 +78,8 @@ extern void partition_print PARAMS((partition, #define partition_find(partition__, element__) \ ((partition__)->elements[(element__)].class_element) +#ifdef __cplusplus +} +#endif /* __cplusplus */ + #endif /* _PARTITION_H */ diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index bde129cda84..4a32a3b298a 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,13 @@ +2002-10-16 Jakub Jelinek + + * config.table: Use mh-s390pic for s390x too. + +2002-10-06 Andreas Jaeger + + * libiberty/cplus-dem.c (ada_demangle): Get rid of unneeded + variable and of strict-aliasing warning. + (grow_vect): Use char as first parameter. + 2002-09-22 Kaveh R. Ghazi * Makefile.in (all): Fix multilib parallel build. diff --git a/libiberty/config.table b/libiberty/config.table index b9a2479aac7..df48ce99525 100644 --- a/libiberty/config.table +++ b/libiberty/config.table @@ -39,6 +39,7 @@ if [ "${shared}" = "yes" ]; then powerpc*-*-aix*) ;; powerpc*-*-*) frag=mh-ppcpic ;; sparc*-*-*) frag=mh-sparcpic ;; + s390*-*-*) frag=mh-s390pic ;; *) frag=mh-${host_cpu}pic ;; esac if [ -n "${frag}" ]; then diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c index 4c4778375b0..f42d6181d40 100644 --- a/libiberty/cplus-dem.c +++ b/libiberty/cplus-dem.c @@ -514,7 +514,7 @@ recursively_demangle PARAMS ((struct work_stuff *, const char **, string *, int)); static void -grow_vect PARAMS ((void **, size_t *, size_t, int)); +grow_vect PARAMS ((char **, size_t *, size_t, int)); /* Translate count to integer, consuming tokens in the process. Conversion terminates on the first non-digit character. @@ -936,7 +936,7 @@ cplus_demangle (mangled, options) static void grow_vect (old_vect, size, min_size, element_size) - void **old_vect; + char **old_vect; size_t *size; size_t min_size; int element_size; @@ -969,8 +969,7 @@ ada_demangle (mangled, option) char *demangled = NULL; int at_start_name; int changed; - char *demangling_buffer = NULL; - size_t demangling_buffer_size = 0; + size_t demangled_size = 0; changed = 0; @@ -998,10 +997,9 @@ ada_demangle (mangled, option) } /* Make demangled big enough for possible expansion by operator name. */ - grow_vect ((void **) &(demangling_buffer), - &demangling_buffer_size, 2 * len0 + 1, + grow_vect (&demangled, + &demangled_size, 2 * len0 + 1, sizeof (char)); - demangled = demangling_buffer; if (ISDIGIT ((unsigned char) mangled[len0 - 1])) { for (i = len0 - 2; i >= 0 && ISDIGIT ((unsigned char) mangled[i]); i -= 1) @@ -1051,10 +1049,10 @@ ada_demangle (mangled, option) return demangled; Suppress: - grow_vect ((void **) &(demangling_buffer), - &demangling_buffer_size, strlen (mangled) + 3, + grow_vect (&demangled, + &demangled_size, strlen (mangled) + 3, sizeof (char)); - demangled = demangling_buffer; + if (mangled[0] == '<') strcpy (demangled, mangled); else diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 6128a7d1cfa..558b900aa70 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,15 @@ +2002-10-07 Nathan Tallent + + * sparc-opc.c (sparc_opcodes) : Add conditional/unconditional branch + classification. + +2002-10-13 Stephane Carrez + + * m68hc11-dis.c (print_insn): Treat bitmask and branch operands + at the end. + 2002-09-30 Gavin Romig-Koch Ken Raeburn Aldy Hernandez diff --git a/opcodes/m68hc11-dis.c b/opcodes/m68hc11-dis.c index c721d16e0c4..bcd3ee5103f 100644 --- a/opcodes/m68hc11-dis.c +++ b/opcodes/m68hc11-dis.c @@ -495,55 +495,6 @@ print_insn (memaddr, info, arch) reg_dst_table[(buffer[0] & 7)]); } - /* M6811_OP_BITMASK and M6811_OP_JUMP_REL must be treated separately - and in that order. The brset/brclr insn have a bitmask and then - a relative branch offset. */ - if (format & M6811_OP_BITMASK) - { - status = read_memory (memaddr + pos, &buffer[0], 1, info); - if (status != 0) - { - return status; - } - pos++; - (*info->fprintf_func) (info->stream, " #$%02x%s", - buffer[0] & 0x0FF, - (format & M6811_OP_JUMP_REL ? " " : "")); - format &= ~M6811_OP_BITMASK; - } - if (format & M6811_OP_JUMP_REL) - { - int val; - - status = read_memory (memaddr + pos, &buffer[0], 1, info); - if (status != 0) - { - return status; - } - - pos++; - val = (buffer[0] & 0x80) ? buffer[0] | 0xFFFFFF00 : buffer[0]; - (*info->print_address_func) (memaddr + pos + val, info); - format &= ~M6811_OP_JUMP_REL; - } - else if (format & M6812_OP_JUMP_REL16) - { - int val; - - status = read_memory (memaddr + pos, &buffer[0], 2, info); - if (status != 0) - { - return status; - } - - pos += 2; - val = ((buffer[0] << 8) | (buffer[1] & 0x0FF)); - if (val & 0x8000) - val |= 0xffff0000; - - (*info->print_address_func) (memaddr + pos + val, info); - format &= ~M6812_OP_JUMP_REL16; - } if (format & (M6811_OP_IMM16 | M6811_OP_IND16)) { int val; @@ -641,6 +592,56 @@ print_insn (memaddr, info, arch) (*info->print_address_func) (val, info); } + /* M6811_OP_BITMASK and M6811_OP_JUMP_REL must be treated separately + and in that order. The brset/brclr insn have a bitmask and then + a relative branch offset. */ + if (format & M6811_OP_BITMASK) + { + status = read_memory (memaddr + pos, &buffer[0], 1, info); + if (status != 0) + { + return status; + } + pos++; + (*info->fprintf_func) (info->stream, " #$%02x%s", + buffer[0] & 0x0FF, + (format & M6811_OP_JUMP_REL ? " " : "")); + format &= ~M6811_OP_BITMASK; + } + if (format & M6811_OP_JUMP_REL) + { + int val; + + status = read_memory (memaddr + pos, &buffer[0], 1, info); + if (status != 0) + { + return status; + } + + pos++; + val = (buffer[0] & 0x80) ? buffer[0] | 0xFFFFFF00 : buffer[0]; + (*info->print_address_func) (memaddr + pos + val, info); + format &= ~M6811_OP_JUMP_REL; + } + else if (format & M6812_OP_JUMP_REL16) + { + int val; + + status = read_memory (memaddr + pos, &buffer[0], 2, info); + if (status != 0) + { + return status; + } + + pos += 2; + val = ((buffer[0] << 8) | (buffer[1] & 0x0FF)); + if (val & 0x8000) + val |= 0xffff0000; + + (*info->print_address_func) (memaddr + pos + val, info); + format &= ~M6812_OP_JUMP_REL16; + } + if (format & M6812_OP_PAGE) { int val; diff --git a/opcodes/sparc-opc.c b/opcodes/sparc-opc.c index 5c06d01df14..00102323f2b 100644 --- a/opcodes/sparc-opc.c +++ b/opcodes/sparc-opc.c @@ -1440,25 +1440,25 @@ cond ("bz", "tz", CONDZ, F_CONDBR|F_ALIAS), /* for e */ FBRX(fop, F2(0, 5)|COND(mask), F2(~0, ~5)|COND(~(mask)), flags), /* v9 */ \ FBR(fop, F2(0, 6)|COND(mask), F2(~0, ~6)|COND(~(mask)), flags) -CONDFC ("fb", "cb", 0x8, 0), -CONDFCL ("fba", "cba", 0x8, F_ALIAS), -CONDFC ("fbe", "cb0", 0x9, 0), -CONDF ("fbz", 0x9, F_ALIAS), -CONDFC ("fbg", "cb2", 0x6, 0), -CONDFC ("fbge", "cb02", 0xb, 0), -CONDFC ("fbl", "cb1", 0x4, 0), -CONDFC ("fble", "cb01", 0xd, 0), -CONDFC ("fblg", "cb12", 0x2, 0), -CONDFCL ("fbn", "cbn", 0x0, 0), -CONDFC ("fbne", "cb123", 0x1, 0), -CONDF ("fbnz", 0x1, F_ALIAS), -CONDFC ("fbo", "cb012", 0xf, 0), -CONDFC ("fbu", "cb3", 0x7, 0), -CONDFC ("fbue", "cb03", 0xa, 0), -CONDFC ("fbug", "cb23", 0x5, 0), -CONDFC ("fbuge", "cb023", 0xc, 0), -CONDFC ("fbul", "cb13", 0x3, 0), -CONDFC ("fbule", "cb013", 0xe, 0), +CONDFC ("fb", "cb", 0x8, F_UNBR), +CONDFCL ("fba", "cba", 0x8, F_UNBR|F_ALIAS), +CONDFC ("fbe", "cb0", 0x9, F_CONDBR), +CONDF ("fbz", 0x9, F_CONDBR|F_ALIAS), +CONDFC ("fbg", "cb2", 0x6, F_CONDBR), +CONDFC ("fbge", "cb02", 0xb, F_CONDBR), +CONDFC ("fbl", "cb1", 0x4, F_CONDBR), +CONDFC ("fble", "cb01", 0xd, F_CONDBR), +CONDFC ("fblg", "cb12", 0x2, F_CONDBR), +CONDFCL ("fbn", "cbn", 0x0, F_UNBR), +CONDFC ("fbne", "cb123", 0x1, F_CONDBR), +CONDF ("fbnz", 0x1, F_CONDBR|F_ALIAS), +CONDFC ("fbo", "cb012", 0xf, F_CONDBR), +CONDFC ("fbu", "cb3", 0x7, F_CONDBR), +CONDFC ("fbue", "cb03", 0xa, F_CONDBR), +CONDFC ("fbug", "cb23", 0x5, F_CONDBR), +CONDFC ("fbuge", "cb023", 0xc, F_CONDBR), +CONDFC ("fbul", "cb13", 0x3, F_CONDBR), +CONDFC ("fbule", "cb013", 0xe, F_CONDBR), #undef CONDFC #undef CONDFCL diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index ae252fd2769..eb38a7bf944 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,7 @@ +2002-10-14 Alan Modra + + * cgen-trace.h: Test __BFD_H_SEEN__ rather than BFD_VERSION. + 2002-08-29 Dave Brolley * Make-common.in (CGEN_READ_SCM): Remove ../../cgen/stamp-cgen. diff --git a/sim/common/cgen-trace.h b/sim/common/cgen-trace.h index 5e796fbf061..be1dd1dff4e 100644 --- a/sim/common/cgen-trace.h +++ b/sim/common/cgen-trace.h @@ -78,7 +78,7 @@ typedef struct { extern int sim_disasm_sprintf (SFILE *, const char *, ...); /* For opcodes based disassemblers. */ -#ifdef BFD_VERSION +#ifdef __BFD_H_SEEN__ struct disassemble_info; extern int sim_disasm_read_memory (bfd_vma memaddr_, bfd_byte *myaddr_, int length_, diff --git a/sim/sh/ChangeLog b/sim/sh/ChangeLog index ec587595082..60b41f7c552 100644 --- a/sim/sh/ChangeLog +++ b/sim/sh/ChangeLog @@ -1,3 +1,11 @@ +Fri Oct 11 16:22:28 2002 J"orn Rennecke + + * interp.c (trap): Return int. Take extra parameter for address + of the trap instruction. Changed all callers. + Add case 33 for profiling. + * gencode.c (trapa): Handle trap 33 using the trap function. + Add read of vector for generic traps. + Wed Jul 17 19:36:38 2002 J"orn Rennecke * Makefile.in (interp.o): Depend on $(srcroot)/include/gdb/sim-sh.h. diff --git a/sim/sh/gencode.c b/sim/sh/gencode.c index ba6ee4c1bc6..8e2445a7e11 100644 --- a/sim/sh/gencode.c +++ b/sim/sh/gencode.c @@ -577,7 +577,7 @@ op tab[] = }, { "", "nm", "mac.l @+,@+", "0000nnnnmmmm1111", - "trap (255,R0,memory,maskl,maskw, endianw);", + "trap (255, R0, PC, memory, maskl, maskw, endianw);", "/* FIXME: mac.l support */", }, @@ -951,8 +951,7 @@ op tab[] = }, { "", "", "sleep", "0000000000011011", - "nip = PC;", - "trap (0xc3, R0, memory, maskl, maskw, endianw);", + "nip += trap (0xc3, R0, PC, memory, maskl, maskw, endianw);", }, { "n", "", "stc ,", "0000nnnnmmmm0010", @@ -1029,37 +1028,25 @@ op tab[] = }, { "0", "", "trapa #", "11000011i8*1....", -#if 0 - /* SH-[12] */ "long imm = 0xff & i;", - "if (i==0xc3)", - " PC-=2;", - "if (i<20||i==34||i==0xc3)", - " trap(i,R,memory,maskl,maskw,endianw);", + "if (i < 20 || i == 33 || i == 34 || i == 0xc3)", + " nip += trap (i, R, PC, memory, maskl, maskw,endianw);", +#if 0 "else {", + /* SH-[12] */ " R[15]-=4;", - " WLAT(R[15],GET_SR());", + " WLAT (R[15], GET_SR());", " R[15]-=4;", - " WLAT(R[15],PC+2);", - " PC=RLAT(VBR+(imm<<2))-2;", - "}", + " WLAT (R[15], PH2T (PC + 2));", #else - "if (i == 0xc3)", - " {", - " nip = PC;", - " trap (i, R, memory, maskl, maskw,endianw);", - " }", - "else if (i < 20 || i==34 || i==0xc3)", - " trap (i, R, memory, maskl, maskw,endianw);", "else if (!SR_BL) {", - " /* FIXME: TRA = (imm << 2); */", " SSR = GET_SR();", " SPC = PH2T (PC + 2);", " SET_SR (GET_SR() | SR_MASK_MD | SR_MASK_BL | SR_MASK_RB);", " /* FIXME: EXPEVT = 0x00000160; */", - " SET_NIP (PT2H (VBR + 0x00000100));", - "}", #endif + " SET_NIP (PT2H (RLAT (VBR + (imm<<2))));", + "}", }, { "", "mn", "tst ,", "0010nnnnmmmm1000", diff --git a/sim/sh/interp.c b/sim/sh/interp.c index 2f5d1d37d59..8c2f3598a5d 100644 --- a/sim/sh/interp.c +++ b/sim/sh/interp.c @@ -954,12 +954,14 @@ strnswap (str, len) while (start < end); } -/* Simulate a monitor trap, put the result into r0 and errno into r1 */ +/* Simulate a monitor trap, put the result into r0 and errno into r1 + return offset by which to adjust pc. */ -static void -trap (i, regs, memory, maskl, maskw, endianw) +static int +trap (i, regs, insn_ptr, memory, maskl, maskw, endianw) int i; int *regs; + unsigned char *insn_ptr; unsigned char *memory; { switch (i) @@ -971,6 +973,13 @@ trap (i, regs, memory, maskl, maskw, endianw) raise_exception (SIGQUIT); break; case 3: /* FIXME: for backwards compat, should be removed */ + case 33: + { + unsigned int countp = * (unsigned int *) (insn_ptr + 4); + + WLAT (countp, RLAT (countp) + 1); + return 6; + } case 34: { extern int errno; @@ -1154,9 +1163,11 @@ trap (i, regs, memory, maskl, maskw, endianw) case 0xc3: case 255: raise_exception (SIGTRAP); + if (i == 0xc3) + return -2; break; } - + return 0; } void -- 2.47.2