This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Cute AS segfault bug


On Tue, 16 Nov 1999, Karel Kulhavy wrote:

> Hi everyone
> 
> Try to compile this asm source:
> 
> je 0x100000000
> 
> I got
> Segmentation fault
> 
> Try this:
> 
> push 0x100000000
> 
> I got
> a.s: Assembler messages:
> a.s:2: Error: Attempt to get value of unresolved symbol .L0
> as: bfd assertion fail elf.c:3139
> 
> Maybe I have too old as...

And maybe you're just trying to break gas :-)

I've just checked in the following patch to fix this problem.

--- gas/config/tc-i386.c~	Tue Oct 12 20:14:12 1999
+++ gas/config/tc-i386.c	Tue Nov 16 22:47:16 1999
@@ -2558,7 +2558,7 @@ i386_immediate (imm_start)
 
   input_line_pointer = save_input_line_pointer;
 
-  if (exp->X_op == O_absent)
+  if (exp->X_op == O_absent || exp->X_op == O_big)
     {
       /* missing or bad expr becomes absolute 0 */
       as_bad (_("Missing or invalid immediate expression `%s' taken as 0"),
@@ -2567,9 +2567,9 @@ i386_immediate (imm_start)
       exp->X_add_number = 0;
       exp->X_add_symbol = (symbolS *) 0;
       exp->X_op_symbol = (symbolS *) 0;
-      i.types[this_operand] |= Imm;
     }
-  else if (exp->X_op == O_constant)
+
+  if (exp->X_op == O_constant)
     {
       int bigimm = Imm32;
       if (flag_16bit_code ^ (i.prefix[DATA_PREFIX] != 0))
@@ -2807,6 +2807,17 @@ i386_displacement (disp_start, disp_end)
 #endif
   RESTORE_END_STRING (disp_end);
   input_line_pointer = save_input_line_pointer;
+
+  if (exp->X_op == O_absent || exp->X_op == O_big)
+    {
+      /* missing or bad expr becomes absolute 0 */
+      as_bad (_("Missing or invalid displacement expression `%s' taken as 0"),
+	      disp_start);
+      exp->X_op = O_constant;
+      exp->X_add_number = 0;
+      exp->X_add_symbol = (symbolS *) 0;
+      exp->X_op_symbol = (symbolS *) 0;
+    }
 
   if (exp->X_op == O_constant)
     {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]