diff options
author | Ulrich Drepper <[email protected]> | 2008-01-09 05:49:49 +0000 |
---|---|---|
committer | Ulrich Drepper <[email protected]> | 2008-01-09 05:49:49 +0000 |
commit | e219f1c1b2a5a2e4f248714fdc93d031cdc5ee6a (patch) | |
tree | fa6765a61fa75066ddc0dd271135025748a7faf6 /libcpu/i386_disasm.c | |
parent | 9fbf0d9bdcc9043491e7ea53e769506743160760 (diff) |
propagate from branch 'com.redhat.elfutils.roland.pending' (head 26cc2ce45739af072e7ff4fdab5e8eb7cd756d50)
to branch 'com.redhat.elfutils' (head bb519012dee7013b2cab5c2f5ed465cb3821b063)
Diffstat (limited to 'libcpu/i386_disasm.c')
-rw-r--r-- | libcpu/i386_disasm.c | 117 |
1 files changed, 58 insertions, 59 deletions
diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c index 0f3a01d4..ecdbfb65 100644 --- a/libcpu/i386_disasm.c +++ b/libcpu/i386_disasm.c @@ -184,25 +184,6 @@ 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 @@ -423,7 +404,6 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr, break; default: /* Cannot happen. */ - puts ("unknown prefix"); abort (); } data = begin + 1; @@ -470,20 +450,6 @@ 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') { @@ -707,14 +673,21 @@ 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]); - 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); + 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); if (r < 0) goto not; if (r > 0) @@ -725,17 +698,28 @@ 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 - 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); + 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); if (r < 0) goto not; if (r > 0) @@ -746,21 +730,36 @@ 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 - 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); + 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 #ifdef OFF3_3_BITS - output_data.opoff3 = (instrtab[cnt].off3_3 - + OFF3_3_BIAS - opoff); + instrtab[cnt].off3_3 + OFF3_3_BIAS - opoff, #else - output_data.opoff3 = 0; + 0, #endif - int r = op3_fct[instrtab[cnt].fct3] (&output_data); + buf, &bufcnt, bufsize, + data, ¶m_start, + end, + symcb, symcbarg); if (r < 0) goto not; if (r > 0) |