This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
x86: don't bomb on bad @GOTOFF expression
- To: binutils at sources dot redhat dot com
- Subject: x86: don't bomb on bad @GOTOFF expression
- From: amodra at one dot net dot au
- Date: Thu, 3 May 2001 10:38:25 +0930
Bad user input like
pushl sym1+sym2@GOTOFF(%ebx)
shouldn't trigger an assert, as it's not an internal error.
gas/ChangeLog
* config/tc-i386.c (i386_displacement): Call as_bad for bad GOTOFF
expressions rather than triggering an assert.
Applying to mainline only.
--
Alan Modra
Index: config/tc-i386.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.c,v
retrieving revision 1.93
diff -u -p -r1.93 tc-i386.c
--- tc-i386.c 2001/03/30 00:06:10 1.93
+++ tc-i386.c 2001/05/02 12:51:04
@@ -3466,6 +3466,19 @@ i386_displacement (disp_start, disp_end)
exp_seg = expression (exp);
+ SKIP_WHITESPACE ();
+ if (*input_line_pointer)
+ as_bad (_("junk `%s' after expression"), input_line_pointer);
+#if GCC_ASM_O_HACK
+ RESTORE_END_STRING (disp_end + 1);
+#endif
+ RESTORE_END_STRING (disp_end);
+ input_line_pointer = save_input_line_pointer;
+#ifndef LEX_AT
+ if (gotfree_input_line)
+ free (gotfree_input_line);
+#endif
+
#ifdef BFD_ASSEMBLER
/* We do this to make sure that the section symbol is in
the symbol table. We will ultimately change the relocation
@@ -3473,10 +3486,18 @@ i386_displacement (disp_start, disp_end)
if (i.reloc[this_operand] == BFD_RELOC_386_GOTOFF
|| i.reloc[this_operand] == BFD_RELOC_X86_64_GOTPCREL)
{
+ if (exp->X_op != O_symbol)
+ {
+ as_bad (_("bad expression used with @%s"),
+ (i.reloc[this_operand] == BFD_RELOC_X86_64_GOTPCREL
+ ? "GOTPCREL"
+ : "GOTOFF"));
+ return 0;
+ }
+
if (S_IS_LOCAL (exp->X_add_symbol)
&& S_GET_SEGMENT (exp->X_add_symbol) != undefined_section)
section_symbol (S_GET_SEGMENT (exp->X_add_symbol));
- assert (exp->X_op == O_symbol);
exp->X_op = O_subtract;
exp->X_op_symbol = GOT_symbol;
if (i.reloc[this_operand] == BFD_RELOC_X86_64_GOTPCREL)
@@ -3484,19 +3505,6 @@ i386_displacement (disp_start, disp_end)
else
i.reloc[this_operand] = BFD_RELOC_32;
}
-#endif
-
- SKIP_WHITESPACE ();
- if (*input_line_pointer)
- as_bad (_("junk `%s' after expression"), input_line_pointer);
-#if GCC_ASM_O_HACK
- RESTORE_END_STRING (disp_end + 1);
-#endif
- RESTORE_END_STRING (disp_end);
- input_line_pointer = save_input_line_pointer;
-#ifndef LEX_AT
- if (gotfree_input_line)
- free (gotfree_input_line);
#endif
if (exp->X_op == O_absent || exp->X_op == O_big)