This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Tidy i386 signal handler


guru writes:
 > actually  this works better
 > +         _gregs[REG_EIP] += 2;  with  this the libgcj isn't libgij like 
 > the first one I tried
 > +         _gregs[REG_EIP] = (greg_t)_eip;   not sure if this is right 
 > even thou it seems to be working

You need both of these lines.  The code in question should look like
this:

-------------------------------------------------------------------------
  /* Detect a signed division of Integer.MIN_VALUE.  */			\
  if (_eip[0] == 0xf7)							\
    {									\
      bool _min_value_dividend = false;					\
      unsigned char _modrm = _eip[1];					\
									\
      if (((_modrm >> 3) & 7) == 7) /* Signed divide */			\
	{								\
	  _min_value_dividend =						\
	    _gregs[REG_EAX] == (greg_t)0x80000000UL;			\
	}								\
									\
      if (_min_value_dividend)						\
	{								\
	  unsigned char _rm = _modrm & 7;				\
	  _gregs[REG_EDX] = 0; /* the remainder is zero */		\
	  switch (_modrm >> 6)						\
	    {								\
	    case 0:  /* register indirect */				\
	      if (_rm == 5)   /* 32-bit displacement */			\
		_eip += 4;						\
	      if (_rm == 4)  /* A SIB byte follows the ModR/M byte */	\
		_eip += 1;						\
	      break;							\
	    case 1:  /* register indirect + 8-bit displacement */	\
	      _eip += 1;						\
	      if (_rm == 4)  /* A SIB byte follows the ModR/M byte */	\
		_eip += 1;						\
	      break;							\
	    case 2:  /* register indirect + 32-bit displacement */	\
	      _eip += 4;						\
	      if (_rm == 4)  /* A SIB byte follows the ModR/M byte */	\
		_eip += 1;						\
	      break;							\
	    case 3:							\
	      break;							\
	    }								\
	  _eip += 2;							\
	  _gregs[REG_EIP] = (greg_t)_eip;				\
	  return;							\
	}								\
    }									\
}									\
while (0)
-------------------------------------------------------------------------

If this doesn't work for you, please let us know what your system is,
and how you built gcc.

Andrew.


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