Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/gpl3/binutils/dist/gas/config Add a -mtrap-zero-jum...
details: https://anonhg.NetBSD.org/src/rev/88c81deb4e99
branches: trunk
changeset: 768520:88c81deb4e99
user: matt <matt%NetBSD.org@localhost>
date: Thu Aug 18 06:32:35 2011 +0000
description:
Add a -mtrap-zero-jump option for mips that causes a trap instruction to
fire before a jump to a zero or "near" zero address. This can't be used
with MIPS1 kernels since MIPS1 doesn't have a trap instruction (it will
be silently ignored).
diffstat:
external/gpl3/binutils/dist/gas/config/tc-mips.c | 49 +++++++++++++++++++++++-
1 files changed, 48 insertions(+), 1 deletions(-)
diffs (89 lines):
diff -r 9139811a0ecf -r 88c81deb4e99 external/gpl3/binutils/dist/gas/config/tc-mips.c
--- a/external/gpl3/binutils/dist/gas/config/tc-mips.c Thu Aug 18 02:56:21 2011 +0000
+++ b/external/gpl3/binutils/dist/gas/config/tc-mips.c Thu Aug 18 06:32:35 2011 +0000
@@ -749,6 +749,9 @@
NUM_FIX_VR4120_CLASSES
};
+/* ...likewise -mtrap-zero-jump. */
+static bfd_boolean mips_trap_zero_jump;
+
/* ...likewise -mfix-loongson2f-jump. */
static bfd_boolean mips_fix_loongson2f_jump;
@@ -2756,6 +2759,35 @@
fix_loongson2f_jump (ip);
}
+static void
+trap_zero_jump (struct mips_cl_insn * ip)
+{
+ if (strcmp (ip->insn_mo->name, "j") == 0
+ || strcmp (ip->insn_mo->name, "jr") == 0
+ || strcmp (ip->insn_mo->name, "jalr") == 0)
+ {
+ int sreg;
+
+ if (mips_opts.warn_about_macros)
+ return;
+
+ sreg = EXTRACT_OPERAND (RS, *ip);
+ if (mips_opts.isa == ISA_MIPS32
+ || mips_opts.isa == ISA_MIPS32R2
+ || mips_opts.isa == ISA_MIPS64
+ || mips_opts.isa == ISA_MIPS64R2)
+ {
+ expressionS ep;
+ ep.X_op = O_constant;
+ ep.X_add_number = 4096;
+ macro_build (&ep, "tltiu", "s,j", sreg, BFD_RELOC_LO16);
+ }
+ else if (mips_opts.isa != ISA_UNKNOWN
+ && mips_opts.isa != ISA_MIPS1)
+ macro_build (NULL, "teq", "s,t", sreg, 0);
+ }
+}
+
/* Output an instruction. IP is the instruction information.
ADDRESS_EXPR is an operand of the instruction to be used with
RELOC_TYPE. */
@@ -2771,6 +2803,8 @@
if (mips_fix_loongson2f)
fix_loongson2f (ip);
+ if (mips_trap_zero_jump)
+ trap_zero_jump (ip);
/* Mark instruction labels in mips16 mode. */
mips16_mark_labels ();
@@ -11336,9 +11370,14 @@
{"msingle-float", no_argument, NULL, OPTION_SINGLE_FLOAT},
{"mdouble-float", no_argument, NULL, OPTION_DOUBLE_FLOAT},
+#define OPTION_TRAP_ZERO_JUMP (OPTION_MISC_BASE + 20)
+#define OPTION_NO_TRAP_ZERO_JUMP (OPTION_MISC_BASE + 21)
+ {"mtrap-zero-jump", no_argument, NULL, OPTION_TRAP_ZERO_JUMP},
+ {"mno-trap-zero-jump", no_argument, NULL, OPTION_NO_TRAP_ZERO_JUMP},
+
/* ELF-specific options. */
#ifdef OBJ_ELF
-#define OPTION_ELF_BASE (OPTION_MISC_BASE + 20)
+#define OPTION_ELF_BASE (OPTION_MISC_BASE + 22)
#define OPTION_CALL_SHARED (OPTION_ELF_BASE + 0)
{"KPIC", no_argument, NULL, OPTION_CALL_SHARED},
{"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
@@ -11630,6 +11669,14 @@
mips_opts.sym32 = FALSE;
break;
+ case OPTION_TRAP_ZERO_JUMP:
+ mips_trap_zero_jump = TRUE;
+ break;
+
+ case OPTION_NO_TRAP_ZERO_JUMP:
+ mips_trap_zero_jump = FALSE;
+ break;
+
#ifdef OBJ_ELF
/* When generating ELF code, we permit -KPIC and -call_shared to
select SVR4_PIC, and -non_shared to select no PIC. This is
Home |
Main Index |
Thread Index |
Old Index