Update udis86 from official git repo.

git pull  git://udis86.git.sourceforge.net/gitroot/udis86/udis86
This commit is contained in:
pancake 2012-11-12 17:36:29 +01:00
parent b252b34358
commit 1cd860aab6
12 changed files with 4757 additions and 3116 deletions

View File

@ -44,7 +44,7 @@
#define GRUB_EXPORT_START
#define GRUB_MODATTR(name, value)
#define GRUB_EXPORT(name) .ascii "export:",#name,"\0"
//#define GRUB_EXPORT(name) .ascii "export:",#name,"\0"
#define GRUB_EXPORT_END .text
#define GRUB_EXPORT(value)

File diff suppressed because it is too large Load Diff

View File

@ -164,6 +164,7 @@ enum ud_operand_size {
SZ_WV = 17,
SZ_BV = 18,
SZ_DY = 19
} UD_ATTR_PACKED;

View File

@ -42,7 +42,7 @@ extern void ud_set_pc(struct ud*, uint64_t);
extern void ud_set_input_hook(struct ud*, int (*)(struct ud*));
extern void ud_set_input_buffer(struct ud*, const uint8_t*, size_t);
extern void ud_set_input_buffer(struct ud*, uint8_t*, size_t);
#ifndef __UD_STANDALONE__
extern void ud_set_input_file(struct ud*, FILE*);

View File

@ -79,7 +79,7 @@ ud_get_user_opaque_data( struct ud * u )
* =============================================================================
*/
extern void
ud_set_input_buffer(register struct ud* u, const uint8_t* buf, size_t len)
ud_set_input_buffer(register struct ud* u, uint8_t* buf, size_t len)
{
u->inp_hook = inp_buff_hook;
u->inp_buff = buf;

File diff suppressed because it is too large Load Diff

View File

@ -10,11 +10,10 @@ enum ud_table_type {
UD_TAB__OPC_VENDOR,
UD_TAB__OPC_OSIZE,
UD_TAB__OPC_MODE,
UD_TAB__OPC_3BYTE,
UD_TAB__OPC_3DNOW,
UD_TAB__OPC_REG,
UD_TAB__OPC_ASIZE,
UD_TAB__OPC_2BYTE
UD_TAB__OPC_SSE
};
/* ud_mnemonic -- mnemonic constants */
@ -34,8 +33,6 @@ enum ud_mnemonic_code {
UD_Iaddps,
UD_Iaddsd,
UD_Iaddss,
UD_Iaddsubpd,
UD_Iaddsubps,
UD_Iand,
UD_Iandpd,
UD_Iandps,
@ -224,11 +221,7 @@ enum ud_mnemonic_code {
UD_Ifpxtract,
UD_Ifyl2x,
UD_Ifyl2xp1,
UD_Ihaddpd,
UD_Ihaddps,
UD_Ihlt,
UD_Ihsubpd,
UD_Ihsubps,
UD_Iidiv,
UD_Iin,
UD_Iimul,
@ -310,10 +303,6 @@ enum ud_mnemonic_code {
UD_Imovapd,
UD_Imovaps,
UD_Imovd,
UD_Imovddup,
UD_Imovdqa,
UD_Imovdqu,
UD_Imovdq2q,
UD_Imovhpd,
UD_Imovhps,
UD_Imovlhps,
@ -328,13 +317,10 @@ enum ud_mnemonic_code {
UD_Imovntps,
UD_Imovntq,
UD_Imovq,
UD_Imovq2dq,
UD_Imovsb,
UD_Imovsw,
UD_Imovsd,
UD_Imovsq,
UD_Imovsldup,
UD_Imovshdup,
UD_Imovss,
UD_Imovsx,
UD_Imovupd,
@ -363,7 +349,6 @@ enum ud_mnemonic_code {
UD_Ipaddb,
UD_Ipaddw,
UD_Ipaddd,
UD_Ipaddq,
UD_Ipaddsb,
UD_Ipaddsw,
UD_Ipaddusb,
@ -392,7 +377,6 @@ enum ud_mnemonic_code {
UD_Ipmulhuw,
UD_Ipmulhw,
UD_Ipmullw,
UD_Ipmuludq,
UD_Ipop,
UD_Ipopa,
UD_Ipopad,
@ -406,11 +390,7 @@ enum ud_mnemonic_code {
UD_Iprefetcht1,
UD_Iprefetcht2,
UD_Ipsadbw,
UD_Ipshufd,
UD_Ipshufhw,
UD_Ipshuflw,
UD_Ipshufw,
UD_Ipslldq,
UD_Ipsllw,
UD_Ipslld,
UD_Ipsllq,
@ -419,11 +399,9 @@ enum ud_mnemonic_code {
UD_Ipsrlw,
UD_Ipsrld,
UD_Ipsrlq,
UD_Ipsrldq,
UD_Ipsubb,
UD_Ipsubw,
UD_Ipsubd,
UD_Ipsubq,
UD_Ipsubsb,
UD_Ipsubsw,
UD_Ipsubusb,
@ -431,11 +409,9 @@ enum ud_mnemonic_code {
UD_Ipunpckhbw,
UD_Ipunpckhwd,
UD_Ipunpckhdq,
UD_Ipunpckhqdq,
UD_Ipunpcklbw,
UD_Ipunpcklwd,
UD_Ipunpckldq,
UD_Ipunpcklqdq,
UD_Ipi2fw,
UD_Ipi2fd,
UD_Ipf2iw,
@ -451,7 +427,7 @@ enum ud_mnemonic_code {
UD_Ipfcmpgt,
UD_Ipfmax,
UD_Ipfrcpit1,
UD_Ipfrspit1,
UD_Ipfrsqit1,
UD_Ipfsubr,
UD_Ipfacc,
UD_Ipfcmpeq,
@ -584,7 +560,69 @@ enum ud_mnemonic_code {
UD_Ixcryptofb,
UD_Ixsha1,
UD_Ixsha256,
UD_Ixstore
UD_Ixstore,
UD_Imovdqa,
UD_Imovdq2q,
UD_Imovdqu,
UD_Imovq2dq,
UD_Ipaddq,
UD_Ipsubq,
UD_Ipmuludq,
UD_Ipshufhw,
UD_Ipshuflw,
UD_Ipshufd,
UD_Ipslldq,
UD_Ipsrldq,
UD_Ipunpckhqdq,
UD_Ipunpcklqdq,
UD_Iaddsubpd,
UD_Iaddsubps,
UD_Ihaddpd,
UD_Ihaddps,
UD_Ihsubpd,
UD_Ihsubps,
UD_Imovddup,
UD_Imovshdup,
UD_Imovsldup,
UD_Ipabsb,
UD_Ipabsw,
UD_Ipabsd,
UD_Ipsignb,
UD_Iphaddw,
UD_Iphaddd,
UD_Iphaddsw,
UD_Ipmaddubsw,
UD_Iphsubw,
UD_Iphsubd,
UD_Iphsubsw,
UD_Ipsignd,
UD_Ipsignw,
UD_Ipmulhrsw,
UD_Ipalignr,
UD_Ipblendvb,
UD_Ipmuldq,
UD_Ipminsb,
UD_Ipminsd,
UD_Ipminuw,
UD_Ipminud,
UD_Ipmaxsb,
UD_Ipmaxsd,
UD_Ipmaxud,
UD_Ipmulld,
UD_Iphminposuw,
UD_Iroundps,
UD_Iroundpd,
UD_Iroundss,
UD_Iroundsd,
UD_Iblendpd,
UD_Ipblendw,
UD_Iblendps,
UD_Iblendvpd,
UD_Iblendvps,
UD_Idpps,
UD_Idppd,
UD_Impsadbw,
UD_Iextractps
} UD_ATTR_PACKED;
@ -633,9 +671,9 @@ enum ud_mnemonic_code {
#define O_Gd { OP_G, SZ_D }
#define O_Gq { OP_G, SZ_Q }
#define O_Gv { OP_G, SZ_V }
#define O_Gvw { OP_G, SZ_MDQ }
#define O_Gw { OP_G, SZ_W }
#define O_Gx { OP_G, SZ_MDQ }
#define O_Gy { OP_G, SZ_MDQ }
#define O_Gz { OP_G, SZ_Z }
#define O_I1 { OP_I1, SZ_NA }
#define O_I3 { OP_I3, SZ_NA }
@ -651,6 +689,7 @@ enum ud_mnemonic_code {
#define O_Mb { OP_M, SZ_B }
#define O_MbRv { OP_MR, SZ_BV }
#define O_Md { OP_M, SZ_D }
#define O_MdRy { OP_MR, SZ_DY }
#define O_Mo { OP_M, SZ_O }
#define O_Mq { OP_M, SZ_Q }
#define O_Ms { OP_M, SZ_W }
@ -680,6 +719,8 @@ enum ud_mnemonic_code {
#define O_V { OP_V, SZ_O }
#define O_VR { OP_VR, SZ_O }
#define O_W { OP_W, SZ_O }
#define O_Wsd { OP_W, SZ_O }
#define O_Wss { OP_W, SZ_O }
#define O_eAX { OP_eAX, SZ_NA }
#define O_eBP { OP_eBP, SZ_NA }
#define O_eBX { OP_eBX, SZ_NA }
@ -709,5 +750,5 @@ enum ud_mnemonic_code {
extern const char * ud_mnemonics_str[];
#define GROUP(n) (0x8000 | (n))
#endif /* UD_ITAB_H */

View File

@ -102,25 +102,23 @@ gen_operand(struct ud* u, struct ud_operand* op)
/* push sign-extends to operand size */
sext_size = u->opr_mode;
}
if (sext_size < 64)
sext_mask = (1ull << sext_size) - 1;
mkasm (u, "$0x" FMT64 "x", imm & sext_mask); // ok
break;
if ( sext_size < 64 )
sext_mask = ( 1ull << sext_size ) - 1;
mkasm( u, "0x" FMT64 "x", imm & sext_mask );
break;
}
/* Fix bug with 32 bits operand + 64 bits pc */
case UD_OP_JIMM:
switch (op->size) {
case 8:
mkasm(u, "0x" FMT64 "x", u->pc + op->lval.sbyte);
break;
case 16:
//mkasm(u, "0x" FMT64 "x", ( u->pc + op->lval.sword ) & 0xffff );
mkasm(u, "0x" FMT64 "x", ( u->pc + op->lval.sword ));
mkasm(u, "0x" FMT64 "x", ( u->pc + op->lval.sword ) & 0xffff );
break;
case 32:
//mkasm(u, "0x" FMT64 "x", ( u->pc + op->lval.sdword ) & 0xfffffffful );
mkasm(u, "0x" FMT64 "x", ( u->pc + op->lval.sdword ));
mkasm(u, "0x" FMT64 "x", ( u->pc + op->lval.sdword ) & 0xfffffffful );
break;
default:break;
}

View File

@ -135,7 +135,6 @@ static void gen_operand(struct ud* u, struct ud_operand* op, int syn_cast)
}
/* Fix bug with 32 bits operand + 64 bits pc */
case UD_OP_JIMM:
if (syn_cast) opr_cast(u, op);
switch (op->size) {
@ -143,12 +142,10 @@ static void gen_operand(struct ud* u, struct ud_operand* op, int syn_cast)
mkasm(u, "0x" FMT64 "x", u->pc + op->lval.sbyte);
break;
case 16:
//mkasm(u, "0x" FMT64 "x", ( u->pc + op->lval.sword ) & 0xffff );
mkasm(u, "0x" FMT64 "x", ( u->pc + op->lval.sword ));
mkasm(u, "0x" FMT64 "x", ( u->pc + op->lval.sword ) & 0xffff );
break;
case 32:
//mkasm(u, "0x" FMT64 "x", ( u->pc + op->lval.sdword ) & 0xfffffffful );
mkasm(u, "0x" FMT64 "x", ( u->pc + op->lval.sdword ));
mkasm(u, "0x" FMT64 "x", ( u->pc + op->lval.sdword ) & 0xfffffffful );
break;
default:break;
}
@ -225,12 +222,8 @@ extern void ud_translate_intel(struct ud* u)
mkasm(u, "repne ");
/* print the instruction mnemonic */
mkasm(u, "%s ", ud_lookup_mnemonic(u->mnemonic));
if (u->operand[0].type == UD_NONE) {
mkasm(u, "%s", ud_lookup_mnemonic(u->mnemonic));
} else {
mkasm(u, "%s ", ud_lookup_mnemonic(u->mnemonic));
}
/* operand 1 */
if (u->operand[0].type != UD_NONE) {
int cast = 0;

View File

@ -1,6 +1,6 @@
/* udis86 - libudis86/syn.h
*
* Copyright (c) 2002-2009 Vivek Thampi
* Copyright (c) 2002-2009
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
@ -23,13 +23,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* -----------------------------------------------------------------------------
* syn.h
*
* Copyright (c) 2006, Vivek Mohan <vivek@sig9.com>
* All rights reserved. See LICENSE
* -----------------------------------------------------------------------------
*/
#ifndef UD_SYN_H
#define UD_SYN_H

View File

@ -177,8 +177,8 @@ struct ud
FILE* inp_file;
#endif
uint8_t inp_ctr;
const uint8_t* inp_buff;
const uint8_t* inp_buff_end;
uint8_t* inp_buff;
uint8_t* inp_buff_end;
uint8_t inp_end;
void (*translator)(struct ud*);
uint64_t insn_offset;

View File

@ -58,8 +58,10 @@ ud_disassemble(struct ud* u)
{
if (ud_input_end(u))
return 0;
u->insn_buffer[0] = u->insn_hexcode[0] = 0;
if (ud_decode(u) == 0)
return 0;