From: Ulrich Drepper Date: Fri, 11 Jan 2008 06:17:06 +0000 (+0000) Subject: Fix a few instructions with immediate arguments. X-Git-Tag: elfutils-0.132~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=96a739922f7bc651ecfacaf9c70168b015ec5e96;p=thirdparty%2Felfutils.git Fix a few instructions with immediate arguments. --- diff --git a/libcpu/ChangeLog b/libcpu/ChangeLog index 8cf6be07c..d4280cbfd 100644 --- a/libcpu/ChangeLog +++ b/libcpu/ChangeLog @@ -1,5 +1,7 @@ 2008-01-10 Ulrich Drepper + * defs/i386: Fix a few instructions with immediate arguments. + * i386_disasm.c: Rewrite interface to callback functions for operands to take a single pointer to a structure. * i386_data.h: Adjust all functions. diff --git a/libcpu/defs/i386 b/libcpu/defs/i386 index 29ea606ed..b545c4816 100644 --- a/libcpu/defs/i386 +++ b/libcpu/defs/i386 @@ -71,7 +71,7 @@ ifdef(`i386', 0001001{w},{mod}{reg}{r_m}:adc {mod}{r_m}{w},{reg}{w} 0000010{w},{imm}:add {imm}{w},{ax}{w} 1000000{w},{mod}000{r_m},{imm}:add{w} {imm}{w},{mod}{r_m}{w} -10000011,{mod}000{r_m},{imms8}:add{w0} {imms8},{mod}{r_m} +10000011,{mod}000{r_m},{imms8}:add{w} {imms8},{mod}{r_m} 0000000{w},{mod}{reg}{r_m}:add {reg}{w},{mod}{r_m}{w} 0000001{w},{mod}{reg}{r_m}:add {mod}{r_m}{w},{reg}{w} 01100110,00001111,11010000,{Mod}{xmmreg}{R_m}:addsubpd {Mod}{R_m},{xmmreg} @@ -124,7 +124,7 @@ ifdef(`i386', 00001111,0100{tttn},{mod}{reg}{r_m}:cmov{tttn} {mod}{r_m},{reg} 0011110{w},{imm}:cmp {imm}{w},{ax}{w} 1000000{w},{mod}111{r_m},{imm}:cmp{w} {imm}{w},{mod}{r_m}{w} -10000011,{mod}111{r_m},{imms8}:cmp{w0} {imms8},{mod}{r_m} +10000011,{mod}111{r_m},{imms8}:cmp{w} {imms8},{mod}{r_m} 0011100{w},{mod}{reg}{r_m}:cmp {reg}{w},{mod}{r_m}{w} 0011101{w},{mod}{reg}{r_m}:cmp {mod}{r_m}{w},{reg}{w} ifdef(`ASSEMBLER', @@ -429,7 +429,7 @@ ifdef(`i386', 0000100{w},{mod}{reg}{r_m}:or {reg}{w},{mod}{r_m}{w} 0000101{w},{mod}{reg}{r_m}:or {mod}{r_m}{w},{reg}{w} 1000000{w},{mod}001{r_m},{imm}:or{w} {imm}{w},{mod}{r_m}{w} -1000001{w},{mod}001{r_m},{imm8}:or{w} {imm8},{mod}{r_m}{w} +1000001{w},{mod}001{r_m},{imms8}:or{w} {imms8},{mod}{r_m}{w} 0000110{w},{imm}:or {imm}{w},{ax}{w} 1110011{w},{imm8}:out {ax}{w},{imm8} 1110111{w}:out {ax}{w},{dx} diff --git a/libcpu/i386_data.h b/libcpu/i386_data.h index 94bb84bf8..7815dbc2f 100644 --- a/libcpu/i386_data.h +++ b/libcpu/i386_data.h @@ -813,8 +813,15 @@ FCT_imms8 (struct output_data *d) if (*d->param_start >= d->end) return -1; int_fast8_t byte = *(*d->param_start)++; - int needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx32, - (int32_t) byte); + int needed; +#ifdef X86_64 + if (*d->prefixes & has_rex_w) + needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx64, + (int64_t) byte); + else +#endif + needed = snprintf (&d->bufp[*bufcntp], avail, "$0x%" PRIx32, + (int32_t) byte); if ((size_t) needed > avail) return (size_t) needed - avail; *bufcntp += needed; diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c index 0f3a01d47..acd2d4430 100644 --- a/libcpu/i386_disasm.c +++ b/libcpu/i386_disasm.c @@ -640,6 +640,10 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr, { if (prefixes & has_data16) ch = 'w'; +#ifdef X86_64 + else if (prefixes & has_rex_w) + ch = 'q'; +#endif else ch = 'l'; } diff --git a/tests/ChangeLog b/tests/ChangeLog index 64faabd35..458acd150 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2008-01-10 Ulrich Drepper + + * testfile45.S.bz2: Add more tests. + * testfile45.expect.bz2: Adjust. + 2008-01-08 Ulrich Drepper * Makefile.am (TESTS): Add run-disasm-x86-64.sh. diff --git a/tests/testfile45.S.bz2 b/tests/testfile45.S.bz2 index a2012edbc..2fc212898 100644 Binary files a/tests/testfile45.S.bz2 and b/tests/testfile45.S.bz2 differ diff --git a/tests/testfile45.expect.bz2 b/tests/testfile45.expect.bz2 index ac814e31a..cb054b63c 100644 Binary files a/tests/testfile45.expect.bz2 and b/tests/testfile45.expect.bz2 differ