This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Underscore bfd_target sibling changes for CRIS ([patch] to-be-committed)
- To: binutils at sources dot redhat dot com
- Subject: Underscore bfd_target sibling changes for CRIS ([patch] to-be-committed)
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- Date: Wed, 27 Sep 2000 12:07:10 +0200
Here are the (supposedly self-contained) core changes, affecting other
than CRIS files, to get symbol-leading char handled correctly.
I'll commit this in a couple of days unless advised otherwise, together
with the more CRIS-specific changes. There are also a few changes to the
assembler and linker scripts that are not here, to set the right target
name and handle register prefix. And testcases.
bfd:
Define two bfd_targets for absence and presence of leading
underscore on symbols. Make sure to only link same kind.
* elf32-cris.c (cris_elf_object_p,
cris_elf_final_write_processing, cris_elf_print_private_bfd_data,
cris_elf_merge_private_bfd_data): New.
(elf_backend_object_p, elf_backend_final_write_processing,
bfd_elf32_bfd_print_private_bfd_data,
bfd_elf32_bfd_merge_private_bfd_data): Define.
<Target vector definition>: Include elf32-target.h twice with
different macro settings:
(TARGET_LITTLE_SYM): First as bfd_elf32_cris_vec, then as
bfd_elf32_us_cris_vec.
(TARGET_LITTLE_NAME): First as "elf32-cris", then "elf32-us-cris".
(elf_symbol_leading_char): First as 0, then '_'.
(INCLUDED_TARGET_FILE): Define for second include of elf32-target.h.
* config.bfd (cris-*-*): Add bfd_elf32_us_cris_vec to targ_selvecs.
* configure.in (bfd_elf32_cris_vec, cris_aout_vec): New vector.
* configure: Regenerate.
* targets.c: Declare bfd_elf32_us_cris_vec.
* bfd/po/bfd.pot: Regenerate.
include/elf:
* cris.h (EF_CRIS_UNDERSCORE): New.
include:
* dis-asm.h: Declare cris_get_disassembler, not print_insn_cris.
Fix typo in comment.
opcodes:
Changes to prefix '$' on registers for files where user symbols
don't have a leading underscore. Fix formatting.
* cris-dis.c (REGISTER_PREFIX_CHAR): New.
(format_reg): Add parameter with_reg_prefix. All callers changed.
(print_with_operands): Ditto.
(print_insn_cris_generic): Renamed from print_insn_cris, add
parameter with_reg_prefix.
(print_insn_cris_with_register_prefix,
print_insn_cris_without_register_prefix, cris_get_disassembler):
New.
* disassemble.c (disassembler) [ARCH_cris]: Calling
cris_get_disassembler.
Index: bfd/config.bfd
===================================================================
RCS file: /cvs/src/src/bfd/config.bfd,v
retrieving revision 1.40
diff -p -c -r1.40 config.bfd
*** config.bfd 2000/09/07 04:23:43 1.40
--- config.bfd 2000/09/27 07:58:15
*************** case "${targ}" in
*** 209,216 ****
cris-*-*)
targ_defvec=cris_aout_vec
! targ_selvecs="bfd_elf32_cris_vec ieee_vec"
! targ_underscore=yes
;;
d10v-*-*)
--- 209,216 ----
cris-*-*)
targ_defvec=cris_aout_vec
! targ_selvecs="bfd_elf32_us_cris_vec bfd_elf32_cris_vec ieee_vec"
! targ_underscore=yes # Note: not true for bfd_elf32_cris_vec.
;;
d10v-*-*)
Index: bfd/configure.in
===================================================================
RCS file: /cvs/src/src/bfd/configure.in,v
retrieving revision 1.32
diff -p -c -r1.32 configure.in
*** configure.in 2000/09/07 04:23:43 1.32
--- configure.in 2000/09/27 07:58:37
*************** do
*** 494,499 ****
--- 494,500 ----
bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"
target64=true ;;
bfd_elf32_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;;
+ bfd_elf32_us_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;;
bfd_elf32_d10v_vec) tb="$tb elf32-d10v.lo elf32.lo $elf" ;;
bfd_elf32_d30v_vec) tb="$tb elf32-d30v.lo elf32.lo $elf" ;;
bfd_elf32_fr30_vec) tb="$tb elf32-fr30.lo elf32.lo $elf" ;;
Index: bfd/elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.1
diff -p -c -r1.1 elf32-cris.c
*** elf32-cris.c 2000/07/20 16:21:06 1.1
--- elf32-cris.c 2000/09/27 08:53:22
*************** static asection * cris_elf_gc_mark_hook
*** 48,53 ****
--- 48,61 ----
PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
struct elf_link_hash_entry *, Elf_Internal_Sym *));
+ static boolean cris_elf_object_p PARAMS ((bfd *));
+
+ static void cris_elf_final_write_processing PARAMS ((bfd *, boolean));
+
+ static boolean cris_elf_print_private_bfd_data PARAMS ((bfd *, PTR));
+
+ static boolean cris_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
+
static reloc_howto_type cris_elf_howto_table [] =
{
/* This reloc does nothing. */
*************** cris_elf_check_relocs (abfd, info, sec,
*** 565,570 ****
--- 573,668 ----
return true;
}
+
+ /* Reject a file depending on underscores on symbols. */
+
+ static boolean
+ cris_elf_object_p (abfd)
+ bfd *abfd;
+ {
+ if ((elf_elfheader (abfd)->e_flags & EF_CRIS_UNDERSCORE))
+ return (bfd_get_symbol_leading_char (abfd) == '_');
+ else
+ return (bfd_get_symbol_leading_char (abfd) == 0);
+ }
+
+ /* Mark presence or absence of leading underscore. */
+
+ static void
+ cris_elf_final_write_processing (abfd, linker)
+ bfd *abfd;
+ boolean linker ATTRIBUTE_UNUSED;
+ {
+ if (bfd_get_symbol_leading_char (abfd) == '_')
+ elf_elfheader (abfd)->e_flags |= EF_CRIS_UNDERSCORE;
+ else
+ elf_elfheader (abfd)->e_flags &= ~EF_CRIS_UNDERSCORE;
+ }
+
+ /* Display the flags field */
+
+ static boolean
+ cris_elf_print_private_bfd_data (abfd, ptr)
+ bfd *abfd;
+ PTR ptr;
+ {
+ FILE *file = (FILE *) ptr;
+
+ BFD_ASSERT (abfd != NULL && ptr != NULL)
+
+ _bfd_elf_print_private_bfd_data (abfd, ptr);
+
+ fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
+
+ if (elf_elfheader (abfd)->e_flags & EF_CRIS_UNDERSCORE)
+ fprintf (file, _(" [symbols have a _ prefix]"));
+
+ fputc ('\n', file);
+ return true;
+ }
+
+ /* Don't mix files with and without a leading underscore. */
+
+ static boolean
+ cris_elf_merge_private_bfd_data (ibfd, obfd)
+ bfd *ibfd;
+ bfd *obfd;
+ {
+ flagword old_flags, new_flags;
+
+ if (_bfd_generic_verify_endian_match (ibfd, obfd) == false)
+ return false;
+
+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return true;
+
+ if (! elf_flags_init (obfd))
+ {
+ /* This happens when ld starts out with a 'blank' output file. */
+ elf_flags_init (obfd) = true;
+
+ /* Set flags according to current bfd_target. */
+ cris_elf_final_write_processing (obfd, false);
+ }
+
+ old_flags = elf_elfheader (obfd)->e_flags;
+ new_flags = elf_elfheader (ibfd)->e_flags;
+
+ /* Is this good or bad? We'll follow with other excluding flags. */
+ if ((old_flags & EF_CRIS_UNDERSCORE) != (new_flags & EF_CRIS_UNDERSCORE))
+ {
+ (*_bfd_error_handler)
+ ((new_flags & EF_CRIS_UNDERSCORE)
+ ? _("%s: uses _-prefixed symbols, but writing file with non-prefixed symbols")
+ : _("%s: uses non-prefixed symbols, but writing file with _-prefixed symbols"),
+ bfd_get_filename (ibfd));
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+
+ return true;
+ }
#define ELF_ARCH bfd_arch_cris
#define ELF_MACHINE_CODE EM_CRIS
*************** cris_elf_check_relocs (abfd, info, sec,
*** 572,585 ****
#define TARGET_LITTLE_SYM bfd_elf32_cris_vec
#define TARGET_LITTLE_NAME "elf32-cris"
!
! /* For the time being, we have a leading underscore. Perhaps change to 0
! later, when
! 1) a.out isn't as dominating, and we can forget about multiformat links
! and old assembly code.
! 2) there's an official solution to the symbol vs. register duality
! problem; perhaps a % register prefix, optionally enforced. */
! #define elf_symbol_leading_char '_'
#define elf_info_to_howto_rel NULL
#define elf_info_to_howto cris_info_to_howto_rela
--- 670,676 ----
#define TARGET_LITTLE_SYM bfd_elf32_cris_vec
#define TARGET_LITTLE_NAME "elf32-cris"
! #define elf_symbol_leading_char 0
#define elf_info_to_howto_rel NULL
#define elf_info_to_howto cris_info_to_howto_rela
*************** cris_elf_check_relocs (abfd, info, sec,
*** 590,595 ****
--- 681,694 ----
#define elf_backend_can_gc_sections 1
+ #define elf_backend_object_p cris_elf_object_p
+ #define elf_backend_final_write_processing \
+ cris_elf_final_write_processing
+ #define bfd_elf32_bfd_print_private_bfd_data \
+ cris_elf_print_private_bfd_data
+ #define bfd_elf32_bfd_merge_private_bfd_data \
+ cris_elf_merge_private_bfd_data
+
#define bfd_elf32_bfd_reloc_type_lookup cris_reloc_type_lookup
/* Later, we my want to optimize RELA entries into REL entries for dynamic
*************** cris_elf_check_relocs (abfd, info, sec,
*** 597,601 ****
--- 696,712 ----
take the easy route. */
#define elf_backend_may_use_rel_p 0
#define elf_backend_may_use_rela_p 1
+
+ #include "elf32-target.h"
+
+ #define INCLUDED_TARGET_FILE
+
+ #undef TARGET_LITTLE_SYM
+ #undef TARGET_LITTLE_NAME
+ #undef elf_symbol_leading_char
+
+ #define TARGET_LITTLE_SYM bfd_elf32_us_cris_vec
+ #define TARGET_LITTLE_NAME "elf32-us-cris"
+ #define elf_symbol_leading_char '_'
#include "elf32-target.h"
Index: include/elf/cris.h
===================================================================
RCS file: /cvs/src/src/include/elf/cris.h,v
retrieving revision 1.1
diff -p -c -r1.1 cris.h
*** cris.h 2000/07/20 15:44:56 1.1
--- cris.h 2000/09/27 07:59:50
*************** START_RELOC_NUMBERS (elf_cris_reloc_type
*** 41,44 ****
--- 41,47 ----
END_RELOC_NUMBERS (R_CRIS_max)
+ /* Symbols in this file have a leading underscore. */
+ #define EF_CRIS_UNDERSCORE 0x00000001
+
#endif /* _ELF_CRIS_H */
Index: include/dis-asm.h
===================================================================
RCS file: /cvs/src/src/include/dis-asm.h,v
retrieving revision 1.17
diff -p -c -r1.17 dis-asm.h
*** dis-asm.h 2000/07/28 21:10:20 1.17
--- dis-asm.h 2000/09/27 07:59:50
*************** extern int print_insn_big_powerpc PARAMS
*** 191,197 ****
extern int print_insn_little_powerpc PARAMS ((bfd_vma, disassemble_info*));
extern int print_insn_rs6000 PARAMS ((bfd_vma, disassemble_info*));
extern int print_insn_w65 PARAMS ((bfd_vma, disassemble_info*));
! extern int print_insn_cris PARAMS ((bfd_vma, disassemble_info*));
extern int print_insn_d10v PARAMS ((bfd_vma, disassemble_info*));
extern int print_insn_d30v PARAMS ((bfd_vma, disassemble_info*));
extern int print_insn_v850 PARAMS ((bfd_vma, disassemble_info*));
--- 191,197 ----
extern int print_insn_little_powerpc PARAMS ((bfd_vma, disassemble_info*));
extern int print_insn_rs6000 PARAMS ((bfd_vma, disassemble_info*));
extern int print_insn_w65 PARAMS ((bfd_vma, disassemble_info*));
! extern disassembler_ftype cris_get_disassembler PARAMS ((bfd *));
extern int print_insn_d10v PARAMS ((bfd_vma, disassemble_info*));
extern int print_insn_d30v PARAMS ((bfd_vma, disassemble_info*));
extern int print_insn_v850 PARAMS ((bfd_vma, disassemble_info*));
*************** extern int generic_symbol_at_address
*** 251,257 ****
/* Call this macro to initialize only the internal variables for the
disassembler. Architecture dependent things such as byte order, or machine
variant are not touched by this macro. This makes things much easier for
! GDB which must initialize these things seperatly. */
#define INIT_DISASSEMBLE_INFO_NO_ARCH(INFO, STREAM, FPRINTF_FUNC) \
(INFO).fprintf_func = (fprintf_ftype)(FPRINTF_FUNC), \
--- 251,257 ----
/* Call this macro to initialize only the internal variables for the
disassembler. Architecture dependent things such as byte order, or machine
variant are not touched by this macro. This makes things much easier for
! GDB which must initialize these things separately. */
#define INIT_DISASSEMBLE_INFO_NO_ARCH(INFO, STREAM, FPRINTF_FUNC) \
(INFO).fprintf_func = (fprintf_ftype)(FPRINTF_FUNC), \
Index: opcodes/cris-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/cris-dis.c,v
retrieving revision 1.1
diff -p -c -r1.1 cris-dis.c
*** cris-dis.c 2000/07/20 16:46:28 1.1
--- cris-dis.c 2000/09/27 08:00:29
*************** Foundation, Inc., 59 Temple Place - Suit
*** 24,30 ****
#include "opcode/cris.h"
#include "libiberty.h"
-
/* No instruction will be disassembled longer than this. In theory, and
in silicon, address prefixes can be cascaded. In practice, cascading
is not used by GCC, and not supported by the assembler. */
--- 24,29 ----
*************** Foundation, Inc., 59 Temple Place - Suit
*** 38,43 ****
--- 37,45 ----
#define PARSE_PREFIX 1
#endif
+ /* Sometimes we prefix all registers with this character. */
+ #define REGISTER_PREFIX_CHAR '$'
+
/* Whether or not to trace the following sequence:
sub* X,r%d
bound* Y,r%d
*************** static long last_immediate = 0;
*** 78,99 ****
static int number_of_bits PARAMS ((unsigned int));
static char *format_hex PARAMS ((unsigned long, char *));
static char *format_dec PARAMS ((long, char *, int));
! static char *format_reg PARAMS ((int, char *));
static int cris_constraint PARAMS ((const char *, unsigned int,
unsigned int));
static unsigned bytes_to_skip PARAMS ((unsigned int,
const struct cris_opcode *));
static char *print_flags PARAMS ((unsigned int, char *));
! static void print_with_operands PARAMS ((const struct cris_opcode *,
! unsigned int, unsigned char *,
! bfd_vma, disassemble_info *,
! const struct cris_opcode *,
! unsigned int, unsigned char *));
static const struct cris_spec_reg *spec_reg_info PARAMS ((unsigned int));
/* Return the descriptor of a special register.
FIXME: Depend on a CPU-version specific argument when all machinery
is in place. */
static const struct cris_spec_reg *
spec_reg_info (sreg)
unsigned int sreg;
--- 80,107 ----
static int number_of_bits PARAMS ((unsigned int));
static char *format_hex PARAMS ((unsigned long, char *));
static char *format_dec PARAMS ((long, char *, int));
! static char *format_reg PARAMS ((int, char *, boolean));
static int cris_constraint PARAMS ((const char *, unsigned int,
unsigned int));
static unsigned bytes_to_skip PARAMS ((unsigned int,
const struct cris_opcode *));
static char *print_flags PARAMS ((unsigned int, char *));
! static void print_with_operands
! PARAMS ((const struct cris_opcode *, unsigned int, unsigned char *,
! bfd_vma, disassemble_info *, const struct cris_opcode *,
! unsigned int, unsigned char *, boolean));
static const struct cris_spec_reg *spec_reg_info PARAMS ((unsigned int));
+ static int print_insn_cris_generic
+ PARAMS ((bfd_vma, disassemble_info *, boolean));
+ static int print_insn_cris_with_register_prefix
+ PARAMS ((bfd_vma, disassemble_info *));
+ static int print_insn_cris_without_register_prefix
+ PARAMS ((bfd_vma, disassemble_info *));
/* Return the descriptor of a special register.
FIXME: Depend on a CPU-version specific argument when all machinery
is in place. */
+
static const struct cris_spec_reg *
spec_reg_info (sreg)
unsigned int sreg;
*************** spec_reg_info (sreg)
*** 108,115 ****
return NULL;
}
-
/* Return the number of bits in the argument. */
static int
number_of_bits (val)
unsigned int val;
--- 116,123 ----
return NULL;
}
/* Return the number of bits in the argument. */
+
static int
number_of_bits (val)
unsigned int val;
*************** number_of_bits (val)
*** 122,129 ****
return bits;
}
-
/* Get an entry in the opcode-table. */
static const struct cris_opcode *
get_opcode_entry (insn, prefix_insn)
unsigned int insn;
--- 130,137 ----
return bits;
}
/* Get an entry in the opcode-table. */
+
static const struct cris_opcode *
get_opcode_entry (insn, prefix_insn)
unsigned int insn;
*************** get_opcode_entry (insn, prefix_insn)
*** 281,288 ****
return max_matchedp;
}
-
/* Format number as hex with a leading "0x" into outbuffer. */
static char *
format_hex (number, outbuffer)
unsigned long number;
--- 289,296 ----
return max_matchedp;
}
/* Format number as hex with a leading "0x" into outbuffer. */
+
static char *
format_hex (number, outbuffer)
unsigned long number;
*************** format_hex (number, outbuffer)
*** 302,311 ****
return outbuffer + strlen (outbuffer);
}
-
/* Format number as decimal into outbuffer. Parameter signedp says
whether the number should be formatted as signed (!= 0) or
unsigned (== 0). */
static char *
format_dec (number, outbuffer, signedp)
long number;
--- 310,319 ----
return outbuffer + strlen (outbuffer);
}
/* Format number as decimal into outbuffer. Parameter signedp says
whether the number should be formatted as signed (!= 0) or
unsigned (== 0). */
+
static char *
format_dec (number, outbuffer, signedp)
long number;
*************** format_dec (number, outbuffer, signedp)
*** 318,330 ****
return outbuffer + strlen (outbuffer);
}
-
/* Format the name of the general register regno into outbuffer. */
static char *
! format_reg (regno, outbuffer)
int regno;
! char *outbuffer;
{
switch (regno)
{
case 15:
--- 326,344 ----
return outbuffer + strlen (outbuffer);
}
/* Format the name of the general register regno into outbuffer. */
+
static char *
! format_reg (regno, outbuffer_start, with_reg_prefix)
int regno;
! char *outbuffer_start;
! boolean with_reg_prefix;
{
+ char *outbuffer = outbuffer_start;
+
+ if (with_reg_prefix)
+ *outbuffer++ = REGISTER_PREFIX_CHAR;
+
switch (regno)
{
case 15:
*************** format_reg (regno, outbuffer)
*** 340,352 ****
break;
}
! return outbuffer + strlen (outbuffer);
}
-
/* Return -1 if the constraints of a bitwise-matched instruction say
that there is no match. Otherwise return a nonnegative number
indicating the confidence in the match (higher is better). */
static int
cris_constraint (cs, insn, prefix_insn)
const char *cs;
--- 354,366 ----
break;
}
! return outbuffer_start + strlen (outbuffer_start);
}
/* Return -1 if the constraints of a bitwise-matched instruction say
that there is no match. Otherwise return a nonnegative number
indicating the confidence in the match (higher is better). */
+
static int
cris_constraint (cs, insn, prefix_insn)
const char *cs;
*************** cris_constraint (cs, insn, prefix_insn)
*** 493,500 ****
return retval;
}
-
/* Return the length of an instruction. */
static unsigned
bytes_to_skip (insn, matchedp)
unsigned int insn;
--- 507,514 ----
return retval;
}
/* Return the length of an instruction. */
+
static unsigned
bytes_to_skip (insn, matchedp)
unsigned int insn;
*************** bytes_to_skip (insn, matchedp)
*** 536,543 ****
return to_skip;
}
-
/* Print condition code flags. */
static char *
print_flags (insn, cp)
unsigned int insn;
--- 550,557 ----
return to_skip;
}
/* Print condition code flags. */
+
static char *
print_flags (insn, cp)
unsigned int insn;
*************** print_flags (insn, cp)
*** 559,571 ****
return cp;
}
-
/* Print out an insn with its operands, and update the info->insn_type
fields. The prefix_opcodep and the rest hold a prefix insn that is
supposed to be output as an address mode. */
static void
print_with_operands (opcodep, insn, buffer, addr, info, prefix_opcodep,
! prefix_insn, prefix_buffer)
const struct cris_opcode *opcodep;
unsigned int insn;
unsigned char *buffer;
--- 573,585 ----
return cp;
}
/* Print out an insn with its operands, and update the info->insn_type
fields. The prefix_opcodep and the rest hold a prefix insn that is
supposed to be output as an address mode. */
+
static void
print_with_operands (opcodep, insn, buffer, addr, info, prefix_opcodep,
! prefix_insn, prefix_buffer, with_reg_prefix)
const struct cris_opcode *opcodep;
unsigned int insn;
unsigned char *buffer;
*************** print_with_operands (opcodep, insn, buff
*** 577,586 ****
const struct cris_opcode *prefix_opcodep;
unsigned int prefix_insn;
unsigned char *prefix_buffer;
{
/* Get a buffer of somewhat reasonable size where we store
intermediate parts of the insn. */
! char temp[sizeof (".d [r13=r12-2147483648],r10") * 2];
char *tp = temp;
static const char mode_char[] = "bwd?";
const char *s;
--- 591,601 ----
const struct cris_opcode *prefix_opcodep;
unsigned int prefix_insn;
unsigned char *prefix_buffer;
+ boolean with_reg_prefix;
{
/* Get a buffer of somewhat reasonable size where we store
intermediate parts of the insn. */
! char temp[sizeof (".d [$r13=$r12-2147483648],$r10") * 2];
char *tp = temp;
static const char mode_char[] = "bwd?";
const char *s;
*************** print_with_operands (opcodep, insn, buff
*** 654,664 ****
case 'D':
case 'r':
! tp = format_reg (insn & 15, tp);
break;
case 'R':
! tp = format_reg ((insn >> 12) & 15, tp);
break;
case 'y':
--- 669,679 ----
case 'D':
case 'r':
! tp = format_reg (insn & 15, tp, with_reg_prefix);
break;
case 'R':
! tp = format_reg ((insn >> 12) & 15, tp, with_reg_prefix);
break;
case 'y':
*************** print_with_operands (opcodep, insn, buff
*** 804,810 ****
{
if (insn & 0x400)
{
! tp = format_reg (insn & 15, tp);
*tp++ = '=';
}
--- 819,825 ----
{
if (insn & 0x400)
{
! tp = format_reg (insn & 15, tp, with_reg_prefix);
*tp++ = '=';
}
*************** print_with_operands (opcodep, insn, buff
*** 846,852 ****
info->target2 = prefix_insn & 15;
*tp++ = '[';
! tp = format_reg (prefix_insn & 15, tp);
if (prefix_insn & 0x400)
*tp++ = '+';
*tp++ = ']';
--- 861,868 ----
info->target2 = prefix_insn & 15;
*tp++ = '[';
! tp = format_reg (prefix_insn & 15, tp,
! with_reg_prefix);
if (prefix_insn & 0x400)
*tp++ = '+';
*tp++ = ']';
*************** print_with_operands (opcodep, insn, buff
*** 862,868 ****
number -= 256;
/* Output "reg+num" or, if num < 0, "reg-num". */
! tp = format_reg ((prefix_insn >> 12) & 15, tp);
if (number >= 0)
*tp++ = '+';
tp = format_dec (number, tp, 1);
--- 878,885 ----
number -= 256;
/* Output "reg+num" or, if num < 0, "reg-num". */
! tp = format_reg ((prefix_insn >> 12) & 15, tp,
! with_reg_prefix);
if (number >= 0)
*tp++ = '+';
tp = format_dec (number, tp, 1);
*************** print_with_operands (opcodep, insn, buff
*** 875,883 ****
case BIAP_OPCODE:
/* Output "r+R.m". */
! tp = format_reg (prefix_insn & 15, tp);
*tp++ = '+';
! tp = format_reg ((prefix_insn >> 12) & 15, tp);
*tp++ = '.';
*tp++ = mode_char[(prefix_insn >> 4) & 3];
--- 892,901 ----
case BIAP_OPCODE:
/* Output "r+R.m". */
! tp = format_reg (prefix_insn & 15, tp, with_reg_prefix);
*tp++ = '+';
! tp = format_reg ((prefix_insn >> 12) & 15, tp,
! with_reg_prefix);
*tp++ = '.';
*tp++ = mode_char[(prefix_insn >> 4) & 3];
*************** print_with_operands (opcodep, insn, buff
*** 899,905 ****
case BDAP_INDIR_OPCODE:
/* Output "r+s.m", or, if "s" is [pc+], "r+s" or
"r-s". */
! tp = format_reg ((prefix_insn >> 12) & 15, tp);
if ((prefix_insn & 0x400) && (prefix_insn & 15) == 15)
{
--- 917,924 ----
case BDAP_INDIR_OPCODE:
/* Output "r+s.m", or, if "s" is [pc+], "r+s" or
"r-s". */
! tp = format_reg ((prefix_insn >> 12) & 15, tp,
! with_reg_prefix);
if ((prefix_insn & 0x400) && (prefix_insn & 15) == 15)
{
*************** print_with_operands (opcodep, insn, buff
*** 969,975 ****
/* Output "r+[R].m" or "r+[R+].m". */
*tp++ = '+';
*tp++ = '[';
! tp = format_reg (prefix_insn & 15, tp);
if (prefix_insn & 0x400)
*tp++ = '+';
*tp++ = ']';
--- 988,995 ----
/* Output "r+[R].m" or "r+[R+].m". */
*tp++ = '+';
*tp++ = '[';
! tp = format_reg (prefix_insn & 15, tp,
! with_reg_prefix);
if (prefix_insn & 0x400)
*tp++ = '+';
*tp++ = ']';
*************** print_with_operands (opcodep, insn, buff
*** 998,1004 ****
}
else
{
! tp = format_reg (insn & 15, tp);
info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
info->target = insn & 15;
--- 1018,1024 ----
}
else
{
! tp = format_reg (insn & 15, tp, with_reg_prefix);
info->flags |= CRIS_DIS_FLAG_MEM_TARGET_IS_REG;
info->target = insn & 15;
*************** print_with_operands (opcodep, insn, buff
*** 1011,1017 ****
break;
case 'x':
! tp = format_reg ((insn >> 12) & 15, tp);
*tp++ = '.';
*tp++ = mode_char[(insn >> 4) & 3];
break;
--- 1031,1037 ----
break;
case 'x':
! tp = format_reg ((insn >> 12) & 15, tp, with_reg_prefix);
*tp++ = '.';
*tp++ = mode_char[(insn >> 4) & 3];
break;
*************** print_with_operands (opcodep, insn, buff
*** 1083,1089 ****
tp = format_dec (number, tp, 1);
*tp++ = ',';
! tp = format_reg ((insn >> 12) & 15, tp);
}
break;
--- 1103,1109 ----
tp = format_dec (number, tp, 1);
*tp++ = ',';
! tp = format_reg ((insn >> 12) & 15, tp, with_reg_prefix);
}
break;
*************** print_with_operands (opcodep, insn, buff
*** 1105,1110 ****
--- 1125,1132 ----
*tp++ = '?';
else
{
+ if (with_reg_prefix)
+ *tp++ = REGISTER_PREFIX_CHAR;
strcpy (tp, sregp->name);
tp += strlen (tp);
}
*************** print_with_operands (opcodep, insn, buff
*** 1155,1165 ****
/* Print the CRIS instruction at address memaddr on stream. Returns
! length of the instruction, in bytes. */
! int
! print_insn_cris (memaddr, info)
bfd_vma memaddr;
disassemble_info *info;
{
int nbytes;
unsigned int insn;
--- 1177,1190 ----
/* Print the CRIS instruction at address memaddr on stream. Returns
! length of the instruction, in bytes. Prefix register names with `$' if
! WITH_REG_PREFIX. */
!
! static int
! print_insn_cris_generic (memaddr, info, with_reg_prefix)
bfd_vma memaddr;
disassemble_info *info;
+ boolean with_reg_prefix;
{
int nbytes;
unsigned int insn;
*************** print_insn_cris (memaddr, info)
*** 1300,1306 ****
to the operands. */
print_with_operands (matchedp, insn, bufp, addr, info,
prefix_opcodep, prefix_insn,
! prefix_buffer);
}
}
}
--- 1325,1331 ----
to the operands. */
print_with_operands (matchedp, insn, bufp, addr, info,
prefix_opcodep, prefix_insn,
! prefix_buffer, with_reg_prefix);
}
}
}
*************** print_insn_cris (memaddr, info)
*** 1333,1338 ****
--- 1358,1396 ----
info->display_endian = BFD_ENDIAN_BIG;
return advance;
+ }
+
+ /* Disassemble, prefixing register names with `$'. */
+
+ static int
+ print_insn_cris_with_register_prefix (vma, info)
+ bfd_vma vma;
+ disassemble_info *info;
+ {
+ return print_insn_cris_generic (vma, info, true);
+ }
+
+ /* Disassemble, no prefixes on register names. */
+
+ static int
+ print_insn_cris_without_register_prefix (vma, info)
+ bfd_vma vma;
+ disassemble_info *info;
+ {
+ return print_insn_cris_generic (vma, info, false);
+ }
+
+ /* Return a disassembler-function that prints registers with a `$' prefix,
+ or one that prints registers without a prefix. */
+
+ disassembler_ftype
+ cris_get_disassembler (abfd)
+ bfd *abfd;
+ {
+ if (bfd_get_symbol_leading_char (abfd) == 0)
+ return print_insn_cris_with_register_prefix;
+
+ return print_insn_cris_without_register_prefix;
}
/*
Index: opcodes/disassemble.c
===================================================================
RCS file: /cvs/src/src/opcodes/disassemble.c,v
retrieving revision 1.17
diff -p -c -r1.17 disassemble.c
*** disassemble.c 2000/07/28 21:10:20 1.17
--- disassemble.c 2000/09/27 08:00:29
*************** disassembler (abfd)
*** 107,113 ****
#endif
#ifdef ARCH_cris
case bfd_arch_cris:
! disassemble = print_insn_cris;
break;
#endif
#ifdef ARCH_d10v
--- 107,113 ----
#endif
#ifdef ARCH_cris
case bfd_arch_cris:
! disassemble = cris_get_disassembler (abfd);
break;
#endif
#ifdef ARCH_d10v
brgds, H-P