This closes #202 issue when using x64 binaries on Linux/Mac to proper… (#204)

* This closes #202 issue when using x64 binaries on Linux/Mac to properly encode mov reg, imm64
* add stdint.h
This commit is contained in:
deroko 2017-11-22 03:32:58 +01:00 committed by Anton Kochkov
parent 9f257e0b33
commit a1ba044299
3 changed files with 4 additions and 3 deletions

View File

@ -35,6 +35,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdint.h>
#include <errno.h> /* needed for errno declaration ( "sometimes" it's defined in stdlib.h ) */ #include <errno.h> /* needed for errno declaration ( "sometimes" it's defined in stdlib.h ) */
#if defined(__UNIX__) || defined(__CYGWIN__) || defined(__DJGPP__) /* avoid for MinGW! */ #if defined(__UNIX__) || defined(__CYGWIN__) || defined(__DJGPP__) /* avoid for MinGW! */

View File

@ -319,7 +319,7 @@ static int ms64_param( struct dsym const *proc, int index, struct dsym *param, b
/* v2.06: support 64-bit constants for params > 4 */ /* v2.06: support 64-bit constants for params > 4 */
if ( psize == 8 && if ( psize == 8 &&
( opnd->value64 > LONG_MAX || opnd->value64 < LONG_MIN ) ) { ( opnd->value64 > INT32_MAX || opnd->value64 < INT32_MIN ) ) {
AddLineQueueX( " mov %r ptr [%r+%u], %r ( %s )", T_DWORD, T_RSP, NUMQUAL index*8, T_LOW32, paramvalue ); AddLineQueueX( " mov %r ptr [%r+%u], %r ( %s )", T_DWORD, T_RSP, NUMQUAL index*8, T_LOW32, paramvalue );
AddLineQueueX( " mov %r ptr [%r+%u], %r ( %s )", T_DWORD, T_RSP, NUMQUAL index*8+4, T_HIGH32, paramvalue ); AddLineQueueX( " mov %r ptr [%r+%u], %r ( %s )", T_DWORD, T_RSP, NUMQUAL index*8+4, T_HIGH32, paramvalue );

View File

@ -783,7 +783,7 @@ static ret_code idata_nofixup( struct code_info *CodeInfo, unsigned CurrOpnd, co
CodeInfo->token == T_MOV && CodeInfo->token == T_MOV &&
CurrOpnd == OPND2 && CurrOpnd == OPND2 &&
( CodeInfo->opnd[OPND1].type & OP_R64 ) && ( CodeInfo->opnd[OPND1].type & OP_R64 ) &&
( opndx->value64 > LONG_MAX || opndx->value64 < LONG_MIN || ( opndx->value64 > INT32_MAX || opndx->value64 < INT32_MIN ||
(opndx->explicit && ( opndx->mem_type == MT_QWORD || opndx->mem_type == MT_SQWORD ) ) ) ) { (opndx->explicit && ( opndx->mem_type == MT_QWORD || opndx->mem_type == MT_SQWORD ) ) ) ) {
// CodeInfo->iswide = 1; /* has been set by first operand already */ // CodeInfo->iswide = 1; /* has been set by first operand already */
CodeInfo->opnd[CurrOpnd].type = OP_I64; CodeInfo->opnd[CurrOpnd].type = OP_I64;
@ -1075,7 +1075,7 @@ ret_code idata_fixup( struct code_info *CodeInfo, unsigned CurrOpnd, struct expr
#if AMD64_SUPPORT #if AMD64_SUPPORT
case 8: case 8:
/* v2.05: do only assume size 8 if the constant won't fit in 4 bytes. */ /* v2.05: do only assume size 8 if the constant won't fit in 4 bytes. */
if ( opndx->value64 > LONG_MAX || opndx->value64 < LONG_MIN || if ( opndx->value64 > INT32_MAX || opndx->value64 < INT32_MIN ||
(opndx->explicit && ( opndx->mem_type & MT_SIZE_MASK ) == 7 ) ) { (opndx->explicit && ( opndx->mem_type & MT_SIZE_MASK ) == 7 ) ) {
CodeInfo->opnd[CurrOpnd].type = OP_I64; CodeInfo->opnd[CurrOpnd].type = OP_I64;
CodeInfo->opnd[CurrOpnd].data32h = opndx->hvalue; CodeInfo->opnd[CurrOpnd].data32h = opndx->hvalue;