diff options
author | Ulrich Drepper <[email protected]> | 2008-01-11 05:10:32 +0000 |
---|---|---|
committer | Ulrich Drepper <[email protected]> | 2008-01-11 05:10:32 +0000 |
commit | d117ed89d2a215d17a8b750b535fc25f1ba2da48 (patch) | |
tree | 354b8bd369be341ae31bda68334f66017f25f0a2 /libcpu/i386_disasm.c | |
parent | e219f1c1b2a5a2e4f248714fdc93d031cdc5ee6a (diff) |
merge of '3bc1b3a545049c99f3627ae7f0cbd7cf256e3806'
and '944c821e8ff593d1d87d48b73871f5ffa8c88515'
Diffstat (limited to 'libcpu/i386_disasm.c')
-rw-r--r-- | libcpu/i386_disasm.c | 117 |
1 files changed, 59 insertions, 58 deletions
diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c index ecdbfb65..0f3a01d4 100644 --- a/libcpu/i386_disasm.c +++ b/libcpu/i386_disasm.c @@ -184,6 +184,25 @@ static const char *prefix_str[] = #endif +struct output_data +{ + GElf_Addr addr; + int *prefixes; + const char *op1str; + size_t opoff1; + size_t opoff2; + size_t opoff3; + char *bufp; + size_t *bufcntp; + size_t bufsize; + const uint8_t *data; + const uint8_t **param_start; + const uint8_t *end; + DisasmGetSymCB_t symcb; + void *symcbarg; +}; + + #ifndef DISFILE # define DISFILE "i386_dis.h" #endif @@ -404,6 +423,7 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr, break; default: /* Cannot happen. */ + puts ("unknown prefix"); abort (); } data = begin + 1; @@ -450,6 +470,20 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr, goto not; } + struct output_data output_data = + { + .addr = addr + (data - begin), + .prefixes = &prefixes, + .bufp = buf, + .bufcntp = &bufcnt, + .bufsize = bufsize, + .data = data, + .param_start = ¶m_start, + .end = end, + .symcb = symcb, + .symcbarg = symcbarg + }; + unsigned long string_end_idx = 0; while (*fmt != '\0') { @@ -673,21 +707,14 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr, if (instrtab[cnt].str1 != 0) ADD_STRING (op1_str[instrtab[cnt].str1]); - int r = op1_fct[instrtab[cnt].fct1] (addr - + (data - begin), - &prefixes, -#ifdef STR1_BITS - op1_str[instrtab[cnt].str1], -#else - NULL, -#endif - instrtab[cnt].off1_1 + OFF1_1_BIAS - opoff, - instrtab[cnt].off1_2 + OFF1_2_BIAS - opoff, - instrtab[cnt].off1_3 + OFF1_3_BIAS - opoff, - buf, &bufcnt, bufsize, - data, ¶m_start, - end, - symcb, symcbarg); + output_data.op1str = op1_str[instrtab[cnt].str1]; + output_data.opoff1 = (instrtab[cnt].off1_1 + + OFF1_1_BIAS - opoff); + output_data.opoff2 = (instrtab[cnt].off1_2 + + OFF1_2_BIAS - opoff); + output_data.opoff3 = (instrtab[cnt].off1_3 + + OFF1_3_BIAS - opoff); + int r = op1_fct[instrtab[cnt].fct1] (&output_data); if (r < 0) goto not; if (r > 0) @@ -698,28 +725,17 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr, else if (prec == 2 && instrtab[cnt].fct2 != 0) { /* Second parameter. */ -#ifdef STR2_BITS - // XXX Probably not needed once the instruction - // XXX tables are complete if (instrtab[cnt].str2 != 0) ADD_STRING (op2_str[instrtab[cnt].str2]); -#endif - int r = op2_fct[instrtab[cnt].fct2] (addr - + (data - begin), - &prefixes, -#ifdef STR2_BITS - op2_str[instrtab[cnt].str2], -#else - NULL, -#endif - instrtab[cnt].off2_1 + OFF2_1_BIAS - opoff, - instrtab[cnt].off2_2 + OFF2_2_BIAS - opoff, - instrtab[cnt].off2_3 + OFF2_3_BIAS - opoff, - buf, &bufcnt, bufsize, - data, ¶m_start, - end, - symcb, symcbarg); + output_data.op1str = op2_str[instrtab[cnt].str2]; + output_data.opoff1 = (instrtab[cnt].off2_1 + + OFF2_1_BIAS - opoff); + output_data.opoff2 = (instrtab[cnt].off2_2 + + OFF2_2_BIAS - opoff); + output_data.opoff3 = (instrtab[cnt].off2_3 + + OFF2_3_BIAS - opoff); + int r = op2_fct[instrtab[cnt].fct2] (&output_data); if (r < 0) goto not; if (r > 0) @@ -730,36 +746,21 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr, else if (prec == 3 && instrtab[cnt].fct3 != 0) { /* Third parameter. */ -#ifdef STR3_BITS - // XXX Probably not needed once the instruction - // XXX tables are complete if (instrtab[cnt].str3 != 0) ADD_STRING (op3_str[instrtab[cnt].str3]); -#endif - int r = op3_fct[instrtab[cnt].fct3] (addr - + (data - begin), - &prefixes, -#ifdef STR3_BITS - op3_str[instrtab[cnt].str3], -#else - NULL, -#endif - instrtab[cnt].off3_1 + OFF3_1_BIAS - opoff, -#ifdef OFF3_2_BITS - instrtab[cnt].off3_2 + OFF3_2_BIAS - opoff, -#else - 0, -#endif + output_data.op1str = op3_str[instrtab[cnt].str3]; + output_data.opoff1 = (instrtab[cnt].off3_1 + + OFF3_1_BIAS - opoff); + output_data.opoff2 = (instrtab[cnt].off3_2 + + OFF3_2_BIAS - opoff); #ifdef OFF3_3_BITS - instrtab[cnt].off3_3 + OFF3_3_BIAS - opoff, + output_data.opoff3 = (instrtab[cnt].off3_3 + + OFF3_3_BIAS - opoff); #else - 0, + output_data.opoff3 = 0; #endif - buf, &bufcnt, bufsize, - data, ¶m_start, - end, - symcb, symcbarg); + int r = op3_fct[instrtab[cnt].fct3] (&output_data); if (r < 0) goto not; if (r > 0) |