]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Rewrite matcher to allow easier handling of SSE instructions.
authorUlrich Drepper <drepper@redhat.com>
Thu, 3 Jan 2008 07:41:03 +0000 (07:41 +0000)
committerUlrich Drepper <drepper@redhat.com>
Thu, 3 Jan 2008 07:41:03 +0000 (07:41 +0000)
A\\Correct/add copyrights.

13 files changed:
libasm/disasm_begin.c
libasm/disasm_end.c
libasm/disasm_str.c
libcpu/ChangeLog
libcpu/defs/i386
libcpu/i386_data.h
libcpu/i386_dis.c [deleted file]
libcpu/i386_disasm.c
libcpu/i386_gendis.c
libcpu/i386_lex.l
libcpu/i386_parse.y
libcpu/memory-access.h
libcpu/x86_64_disasm.c

index 5cdb5424e5fe80a6ddd2a461c1bd9942f5b0e377..5b98b2a378e1fc17930878c2e26941049dba60da 100644 (file)
@@ -1,16 +1,28 @@
 /* Create context descriptor for disassembler.
-   Copyright (C) 2005 Red Hat, Inc.
+   Copyright (C) 2005, 2008 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 2005.
 
-   This program is Open Source software; you can redistribute it and/or
-   modify it under the terms of the Open Software License version 1.0 as
-   published by the Open Source Initiative.
-
-   You should have received a copy of the Open Software License along
-   with this program; if not, you may obtain a copy of the Open Software
-   License version 1.0 from http://www.opensource.org/licenses/osl.php or
-   by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
-   3001 King Ranch Road, Ukiah, CA 95482.   */
+   Red Hat elfutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
index 3165c2dc33c80500da0fdda511bd1764bf45cffc..ee8b2f981ced0f8bdeca5f305e3b28718d9908a6 100644 (file)
@@ -1,16 +1,28 @@
 /* Release descriptor for disassembler.
-   Copyright (C) 2005 Red Hat, Inc.
+   Copyright (C) 2005, 2008 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 2005.
 
-   This program is Open Source software; you can redistribute it and/or
-   modify it under the terms of the Open Software License version 1.0 as
-   published by the Open Source Initiative.
-
-   You should have received a copy of the Open Software License along
-   with this program; if not, you may obtain a copy of the Open Software
-   License version 1.0 from http://www.opensource.org/licenses/osl.php or
-   by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
-   3001 King Ranch Road, Ukiah, CA 95482.   */
+   Red Hat elfutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
index 9f40737190065359474d4389b6d4875a4d91baab..856fd11d12e0c66c702538218b0c65bf00cc426a 100644 (file)
@@ -1,14 +1,27 @@
-/* Copyright (C) 2005 Red Hat, Inc.
+/* Copyright (C) 2005, 2008 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
+   Written by Ulrich Drepper <drepper@redhat.com>, 2007.
 
-   This program is Open Source software; you can redistribute it and/or
-   modify it under the terms of the Open Software License version 1.0 as
-   published by the Open Source Initiative.
+   Red Hat elfutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
 
-   You should have received a copy of the Open Software License along
-   with this program; if not, you may obtain a copy of the Open Software
-   License version 1.0 from http://www.opensource.org/licenses/osl.php or
-   by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
-   3001 King Ranch Road, Ukiah, CA 95482.   */
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
index c5be1d7b3ee135b1a1c6fbb0ce804e6db087ac1c..6ba6cacbec78861f5fe927371bebf72305f25267 100644 (file)
@@ -1,3 +1,10 @@
+2008-01-02  Ulrich Drepper  <drepper@redhat.com>
+
+       * i386_disasm.c (i386_disasm): Extend matcher to allow tables to
+       contain instructions with prefixes.
+       * defs/i386: Use for many SSE operations.
+       * i386_data.h (FCT_mmxreg2): Removed.
+
 2008-01-01  Ulrich Drepper  <drepper@redhat.com>
 
        * defs/i386: More 0f prefix support.
index b0cdfb4b9df94d3cc6bedac4c040dd1cbbf4bdb1..d9cd2886e8b5a43345bd4c0b4d623a172ca5cf88 100644 (file)
@@ -152,13 +152,9 @@ ifdef(`ASSEMBLER',
 00001111,01011011,{Mod}{xmmreg}{R_m}:cvtdq2ps {Mod}{R_m},{xmmreg}
 11110010,00001111,11100110,{Mod}{xmmreg}{R_m}:cvtpd2dq {Mod}{R_m},{xmmreg}
 01100110,00001111,01011010,{Mod}{xmmreg}{R_m}:cvtpd2ps {Mod}{R_m},{xmmreg}
-01100110,00001111,00101010,{MOD}{xmmreg}{R_M}:cvtpi2pd {MOD}{R_M},{xmmreg}
-00001111,00101010,{MOD}{xmmreg}{R_M}:{R}INVALID {MOD}{R_M},{xmmreg}
 01100110,00001111,01011011,{Mod}{xmmreg}{R_m}:cvtps2dq {Mod}{R_m},{xmmreg}
 00001111,01011010,{Mod}{xmmreg}{R_m}:cvtps2pd {Mod}{R_m},{xmmreg}
 11110010,00001111,01011010,{Mod}{xmmreg}{R_m}:cvtsd2ss {Mod}{R_m},{xmmreg}
-11110010,00001111,00101010,{mod}{xmmreg}{r_m}:cvtsi2sd {mod}{r_m},{xmmreg}
-11110011,00001111,00101010,{mod}{xmmreg}{r_m}:cvtsi2ss {mod}{r_m},{xmmreg}
 11110011,00001111,01011010,{Mod}{xmmreg}{R_m}:cvtss2sd {Mod}{R_m},{xmmreg}
 01100110,00001111,11100110,{Mod}{xmmreg}{R_m}:cvttpd2dq {Mod}{R_m},{xmmreg}
 11110011,00001111,01011011,{Mod}{mmxreg}{R_m}:cvttps2dq {Mod}{R_m},{mmxreg}
@@ -532,12 +528,6 @@ ifdef(`ASSEMBLER',
 00001111,00011000,{mod}010{r_m}:prefetcht1 {mod}{r_m}
 00001111,00011000,{mod}011{r_m}:prefetcht2 {mod}{r_m}
 00001111,00011111,{mod}{reg}{r_m}:nop{w} {mod}{r_m}
-dnl without prefix: movups
-dnl with 0xf3: movss
-dnl with 0x66: movupd
-dnl with 0xf2: movsd
-00001111,00010000,{Mod}{xmmreg}{R_m}:{R}INVALID {Mod}{R_m},{xmmreg}
-00001111,00010001,{Mod}{xmmreg}{R_m}:{R}INVALID {xmmreg},{Mod}{R_m}
 00001111,00110000:wrmsr
 00001111,1100000{w},{mod}{reg}{r_m}:xadd{w} {reg},{mod}{r_m}
 1000011{w},{mod}{reg}{r_m}:xchg {reg}{w},{mod}{r_m}{w}
@@ -599,8 +589,6 @@ dnl with 0xf2: movsd
 11110011,00001111,11000010,{Mod}{xmmreg}{R_m},00000101:cmpnltss {Mod}{R_m},{xmmreg}
 11110011,00001111,11000010,{Mod}{xmmreg}{R_m},00000110:cmpnless {Mod}{R_m},{xmmreg}
 11110011,00001111,11000010,{Mod}{xmmreg}{R_m},00000111:cmpordss {Mod}{R_m},{xmmreg}
-00001111,00101010,{MOD}{xmmreg}{R_M}:cvtpi2ps {MOD}{R_M},{xmmreg}
-11110011,00001111,00101010,{mod}{xmmreg}{r_m}:cvtsi2ss {mod}{r_m},{xmmreg}
 00001111,01011110,{Mod}{xmmreg}{R_m}:divps {Mod}{R_m},{xmmreg}
 11110011,00001111,01011110,{Mod}{xmmreg}{R_m}:divss {Mod}{R_m},{xmmreg}
 00001111,10101110,{mod}001{r_m}:fxrstor {mod}{r_m}
@@ -610,24 +598,68 @@ dnl with 0xf2: movsd
 11110011,00001111,01011111,{Mod}{xmmreg}{R_m}:maxss {Mod}{R_m},{xmmreg}
 00001111,01011101,{Mod}{xmmreg}{R_m}:minps {Mod}{R_m},{xmmreg}
 11110011,00001111,01011101,{Mod}{xmmreg}{R_m}:minss {Mod}{R_m},{xmmreg}
-00001111,00101000,{Mod}{xmmreg}{R_m}:INVALID {Mod}{R_m},{xmmreg}
-00001111,00101001,{Mod}{xmmreg}{R_m}:INVALID {xmmreg},{Mod}{R_m}
-00001111,00010010,{Mod}{xmmreg}{R_m}:{R}INVALID {Mod}{R_m},{xmmreg}
-00001111,00010011,{Mod}{xmmreg}{R_m}:INVALID {xmmreg},{Mod}{R_m}
-00001111,00010100,{Mod}{xmmreg}{R_m}:INVALID {Mod}{R_m},{xmmreg}
-00001111,00010101,{Mod}{xmmreg}{R_m}:INVALID {Mod}{R_m},{xmmreg}
-00001111,00010110,{Mod}{xmmreg}{R_m}:{R}INVALID {Mod}{R_m},{xmmreg}
-00001111,00010111,{Mod}{xmmreg}{R_m}:INVALID {xmmreg},{Mod}{R_m}
-00001111,00101011,{mod}{xmmreg}{r_m}:INVALID {xmmreg},{mod}{r_m}
-00001111,00101100,{Mod}{mmxreg2}{R_m}:{R}INVALID {Mod}{R_m},{mmxreg2}
-00001111,00101101,{Mod}{mmxreg2}{R_m}:{R}INVALID {Mod}{R_m},{mmxreg2}
-00001111,00101110,{Mod}{xmmreg}{R_m}:INVALID {Mod}{R_m},{xmmreg}
-00001111,00101111,{Mod}{xmmreg}{R_m}:INVALID {Mod}{R_m},{xmmreg}
+11110010,00001111,00010000,{Mod}{xmmreg}{R_m}:movsd {Mod}{R_m},{xmmreg}
+11110011,00001111,00010000,{Mod}{xmmreg}{R_m}:movss {Mod}{R_m},{xmmreg}
+01100110,00001111,00010000,{Mod}{xmmreg}{R_m}:movupd {Mod}{R_m},{xmmreg}
+00001111,00010000,{Mod}{xmmreg}{R_m}:movups {Mod}{R_m},{xmmreg}
+11110010,00001111,00010001,{Mod}{xmmreg}{R_m}:movsd {xmmreg},{Mod}{R_m}
+11110011,00001111,00010001,{Mod}{xmmreg}{R_m}:movss {xmmreg},{Mod}{R_m}
+01100110,00001111,00010001,{Mod}{xmmreg}{R_m}:movupd {xmmreg},{Mod}{R_m}
+00001111,00010001,{Mod}{xmmreg}{R_m}:movups {xmmreg},{Mod}{R_m}
+11110010,00001111,00010010,{Mod}{xmmreg}{R_m}:movddup {Mod}{R_m},{xmmreg}
+11110011,00001111,00010010,{Mod}{xmmreg}{R_m}:movsldup {Mod}{R_m},{xmmreg}
+01100110,00001111,00010010,{Mod}{xmmreg}{R_m}:movlpd {Mod}{R_m},{xmmreg}
+00001111,00010010,11{xmmreg1}{xmmreg2}:movhlps {xmmreg2},{xmmreg1}
+00001111,00010010,{Mod}{xmmreg}{R_m}:movlps {Mod}{R_m},{xmmreg}
+01100110,00001111,00010011,11{xmmreg1}{xmmreg2}:movhlpd {xmmreg1},{xmmreg2}
+00001111,00010011,11{xmmreg1}{xmmreg2}:movhlps {xmmreg1},{xmmreg2}
+01100110,00001111,00010011,{Mod}{xmmreg}{R_m}:movlpd {xmmreg},{Mod}{R_m}
+00001111,00010011,{Mod}{xmmreg}{R_m}:movlps {xmmreg},{Mod}{R_m}
+01100110,00001111,00010100,{Mod}{xmmreg}{R_m}:unpcklpd {Mod}{R_m},{xmmreg}
+00001111,00010100,{Mod}{xmmreg}{R_m}:unpcklps {Mod}{R_m},{xmmreg}
+01100110,00001111,00010101,{Mod}{xmmreg}{R_m}:unpckhpd {Mod}{R_m},{xmmreg}
+00001111,00010101,{Mod}{xmmreg}{R_m}:unpckhps {Mod}{R_m},{xmmreg}
+11110011,00001111,00010110,{Mod}{xmmreg}{R_m}:movshdup {Mod}{R_m},{xmmreg}
+01100110,00001111,00010110,{Mod}{xmmreg}{R_m}:movhpd {Mod}{R_m},{xmmreg}
+00001111,00010110,11{xmmreg1}{xmmreg2}:movlhps {xmmreg2},{xmmreg1}
+00001111,00010110,{Mod}{xmmreg}{R_m}:movhps {Mod}{R_m},{xmmreg}
+01100110,00001111,00010111,11{xmmreg1}{xmmreg2}:movlhpd {xmmreg1},{xmmreg2}
+00001111,00010111,11{xmmreg1}{xmmreg2}:movlhps {xmmreg1},{xmmreg2}
+01100110,00001111,00010111,{Mod}{xmmreg}{R_m}:movhpd {xmmreg},{Mod}{R_m}
+00001111,00010111,{Mod}{xmmreg}{R_m}:movhps {xmmreg},{Mod}{R_m}
+01100110,00001111,00101000,{Mod}{xmmreg}{R_m}:movapd {Mod}{R_m},{xmmreg}
+00001111,00101000,{Mod}{xmmreg}{R_m}:movaps {Mod}{R_m},{xmmreg}
+01100110,00001111,00101001,{Mod}{xmmreg}{R_m}:movapd {xmmreg},{Mod}{R_m}
+00001111,00101001,{Mod}{xmmreg}{R_m}:movaps {xmmreg},{Mod}{R_m}
+11110010,00001111,00101010,{mod}{xmmreg}{r_m}:cvtsi2sd {mod}{r_m},{xmmreg}
+11110011,00001111,00101010,{mod}{xmmreg}{r_m}:cvtsi2ss {mod}{r_m},{xmmreg}
+01100110,00001111,00101010,{MOD}{xmmreg}{R_M}:cvtpi2pd {MOD}{R_M},{xmmreg}
+00001111,00101010,{MOD}{xmmreg}{R_M}:cvtpi2ps {MOD}{R_M},{xmmreg}
+01100110,00001111,00101011,{mod}{xmmreg}{r_m}:movntpd {xmmreg},{mod}{r_m}
+00001111,00101011,{mod}{xmmreg}{r_m}:movntps {xmmreg},{mod}{r_m}
+11110010,00001111,00101100,{Mod}{reg}{R_m}:cvttsd2si {Mod}{R_m},{reg}
+11110011,00001111,00101100,{Mod}{reg}{R_m}:cvttss2si {Mod}{R_m},{reg}
+01100110,00001111,00101100,{Mod}{mmxreg}{R_m}:cvttpd2pi {Mod}{R_m},{mmxreg}
+00001111,00101100,{Mod}{mmxreg}{R_m}:cvttps2pi {Mod}{R_m},{mmxreg}
+01100110,00001111,00101101,{Mod}{mmxreg}{R_m}:cvtpd2pi {Mod}{R_m},{mmxreg}
+11110010,00001111,00101101,{Mod}{reg}{R_m}:cvtsd2si {Mod}{R_m},{reg}
+11110011,00001111,00101101,{Mod}{reg}{R_m}:cvtss2si {Mod}{R_m},{reg}
+00001111,00101101,{Mod}{mmxreg}{R_m}:cvtps2pi {Mod}{R_m},{mmxreg}
+01100110,00001111,00101110,{Mod}{xmmreg}{R_m}:ucomisd {Mod}{R_m},{xmmreg}
+00001111,00101110,{Mod}{xmmreg}{R_m}:ucomiss {Mod}{R_m},{xmmreg}
+01100110,00001111,00101111,{Mod}{xmmreg}{R_m}:comisd {Mod}{R_m},{xmmreg}
+00001111,00101111,{Mod}{xmmreg}{R_m}:comiss {Mod}{R_m},{xmmreg}
 00001111,00110111:getsec
-00001111,01010000,11{reg}{xmmreg}:INVALID {xmmreg},{reg}
-00001111,01010001,{Mod}{xmmreg}{R_m}:{R}INVALID {Mod}{R_m},{xmmreg}
-00001111,01010010,{Mod}{xmmreg}{R_m}:{R}INVALID {Mod}{R_m},{xmmreg}
-00001111,01010011,{Mod}{xmmreg}{R_m}:{R}INVALID {Mod}{R_m},{xmmreg}
+01100110,00001111,01010000,11{reg}{xmmreg}:movmskpd {xmmreg},{reg}
+00001111,01010000,11{reg}{xmmreg}:movmskps {xmmreg},{reg}
+01100110,00001111,01010001,{Mod}{xmmreg}{R_m}:sqrtpd {Mod}{R_m},{xmmreg}
+11110010,00001111,01010001,{Mod}{xmmreg}{R_m}:sqrtsd {Mod}{R_m},{xmmreg}
+11110011,00001111,01010001,{Mod}{xmmreg}{R_m}:sqrtss {Mod}{R_m},{xmmreg}
+00001111,01010001,{Mod}{xmmreg}{R_m}:sqrtps {Mod}{R_m},{xmmreg}
+11110011,00001111,01010010,{Mod}{xmmreg}{R_m}:rsqrtss {Mod}{R_m},{xmmreg}
+00001111,01010010,{Mod}{xmmreg}{R_m}:rsqrtps {Mod}{R_m},{xmmreg}
+11110011,00001111,01010011,{Mod}{xmmreg}{R_m}:rcpss {Mod}{R_m},{xmmreg}
+00001111,01010011,{Mod}{xmmreg}{R_m}:rcpps {Mod}{R_m},{xmmreg}
 # ORDER:
 dnl Many previous entries depend on this being last.
 000{sreg2}111:pop {sreg2}
index 38e99354e0d0d4bc5e76d365634102cb602875f2..b0bab10d7ddc8426ae7742d14e1da541c9b7f6ce 100644 (file)
@@ -1,3 +1,29 @@
+/* Helper routines for disassembler for x86-64.
+   Copyright (C) 2007, 2008 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
+   Written by Ulrich Drepper <drepper@redhat.com>, 2007.
+
+   Red Hat elfutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
+
 #include <inttypes.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -922,37 +948,6 @@ FCT_mmxreg (GElf_Addr addr __attribute__ ((unused)),
   return 0;
 }
 
-static int
-FCT_mmxreg2 (GElf_Addr addr __attribute__ ((unused)),
-            int *prefixes __attribute__ ((unused)),
-            const char *op1str __attribute__ ((unused)),
-            size_t opoff1 __attribute__ ((unused)),
-            size_t opoff2 __attribute__ ((unused)),
-            size_t opoff3 __attribute__ ((unused)),
-            char *bufp __attribute__ ((unused)),
-            size_t *bufcntp __attribute__ ((unused)),
-            size_t bufsize __attribute__ ((unused)),
-            const uint8_t *data __attribute__ ((unused)),
-            const uint8_t **param_start __attribute__ ((unused)),
-            const uint8_t *end __attribute__ ((unused)),
-            DisasmGetSymCB_t symcb __attribute__ ((unused)),
-            void *symcbarg __attribute__ ((unused)))
-{
-  uint_fast8_t byte = data[opoff1 / 8];
-  assert (opoff1 % 8 == 2 || opoff1 % 8 == 5);
-  byte = (byte >> (5 - opoff1 % 8)) & 7;
-  size_t avail = bufsize - *bufcntp;
-  int needed;
-  if (*prefixes & (has_rep | has_repne))
-    needed = snprintf (&bufp[*bufcntp], avail, "%%%s", regs[byte]);
-  else
-    needed = snprintf (&bufp[*bufcntp], avail, "%%mm%" PRIxFAST8, byte);
-  if ((size_t) needed > avail)
-    return needed - avail;
-  *bufcntp += needed;
-  return 0;
-}
-
 
 static int
 FCT_mod$r_m (GElf_Addr addr __attribute__ ((unused)),
diff --git a/libcpu/i386_dis.c b/libcpu/i386_dis.c
deleted file mode 100644 (file)
index 971746e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-int foo;
index ca173cc6d05cee3a1f47209b126471e20efa4550..d52498ba22a5f0e1e2102ae0101f59df0d8db71d 100644 (file)
@@ -1,3 +1,33 @@
+/* Disassembler for x86.
+   Copyright (C) 2007, 2008 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
+   Written by Ulrich Drepper <drepper@redhat.com>, 2007.
+
+   Red Hat elfutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
 #include <assert.h>
 #include <config.h>
 #include <ctype.h>
@@ -185,6 +215,7 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
       size_t bufcnt = 0;
 
       int prefixes = 0;
+      int last_prefix_bit = 0;
 
       const uint8_t *data = *startp;
       const uint8_t *begin = data;
@@ -201,7 +232,7 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
          if (i == nknown_prefixes)
            break;
 
-         prefixes |= 1 << i;
+         prefixes |= last_prefix_bit = 1 << i;
 
          ++data;
        }
@@ -224,7 +255,7 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
       size_t cnt = 0;
       while (curr < match_end)
        {
-         const uint8_t *const start = curr;
+         const uint8_t *start = curr;
 
          uint_fast8_t len = *curr++;
 
@@ -233,6 +264,25 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
 
          const uint8_t *codep = data;
          size_t avail = len;
+         int correct_prefix = 0;
+         int opoff = 0;
+
+         if (data > begin && codep[-1] == curr[1] && curr[0] == 0xff)
+           {
+             /* We match a prefix byte.  This is exactly one byte and
+                is matched exactly, without a mask.  */
+             --avail;
+
+             --len;
+             start += 2;
+             opoff = 8;
+
+             curr += 2;
+             assert (avail > 0);
+
+             assert (last_prefix_bit != 0);
+             correct_prefix = last_prefix_bit;
+           }
 
          do
            {
@@ -260,6 +310,10 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
               the input data.  */
            return 0;
 
+         assert (correct_prefix == 0
+                 || (prefixes & correct_prefix) != 0);
+         prefixes ^= correct_prefix;
+
          size_t prefix_size = 0;
 
          // XXXonly print as prefix if valid?
@@ -463,238 +517,8 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
                          str = prefixes & has_addr16 ? "jcxz" : "jecxz";
                          break;
 
-                       case 0x0f:
-                         if (data[1] == 0x10 || data[1] == 0x11)
-                           {
-                             bufcnt = 0;
-                             int mod = prefixes & (has_data16 | has_rep
-                                                   | has_repne);
-                             if (mod & (mod - 1))
-                               return -1;
-                             str = (mod & has_data16
-                                    ? "movupd"
-                                    : mod & has_rep
-                                    ? "movss"
-                                    : mod & has_repne
-                                    ? "movsd"
-                                    : "movups");
-                             break;
-                           }
-                         if (data[1] == 0x12)
-                           {
-                             bufcnt = 0;
-                             int mod = prefixes & (has_data16 | has_rep
-                                                   | has_repne);
-                             if (mod & (mod - 1))
-                               return -1;
-                             str = (mod & has_data16
-                                    ? "movlpd"
-                                    : mod & has_rep
-                                    ? "movsldup"
-                                    : mod & has_repne
-                                    ? "movddup"
-                                    : (data[2] & 0xc0) == 0xc0
-                                    ? "movhlps"
-                                    : "movlps");
-                             break;
-                           }
-                         if (data[1] == 0x13)
-                           {
-                             bufcnt = 0;
-                             int mod = prefixes & has_data16;
-                             if (mod & (mod - 1))
-                               return -1;
-                             str = (mod & has_data16
-                                    ? ((data[2] & 0xc0) == 0xc0
-                                       ? "movhlpd"
-                                       : "movlpd")
-                                    : (data[2] & 0xc0) == 0xc0
-                                    ? "movhlps"
-                                    : "movlps");
-                             break;
-                           }
-                         if (data[1] == 0x14)
-                           {
-                             bufcnt = 0;
-                             int mod = prefixes & has_data16;
-                             if (mod & (mod - 1))
-                               return -1;
-                             str = (mod & has_data16
-                                    ? "unpcklpd" : "unpcklps");
-                             break;
-                           }
-                         if (data[1] == 0x15)
-                           {
-                             bufcnt = 0;
-                             int mod = prefixes & has_data16;
-                             if (mod & (mod - 1))
-                               return -1;
-                             str = (mod & has_data16
-                                    ? "unpckhpd" : "unpckhps");
-                             break;
-                           }
-                         if (data[1] == 0x16)
-                           {
-                             bufcnt = 0;
-                             int mod = prefixes & (has_data16 | has_rep);
-                             if (mod & (mod - 1))
-                               return -1;
-                             str = (mod & has_data16
-                                    ? "movhpd"
-                                    : mod & has_rep
-                                    ? "movshdup"
-                                    : (data[2] & 0xc0) == 0xc0
-                                    ? "movlhps"
-                                    : "movhps");
-                             break;
-                           }
-                         if (data[1] == 0x17)
-                           {
-                             bufcnt = 0;
-                             int mod = prefixes & has_data16;
-                             if (mod & (mod - 1))
-                               return -1;
-                             str = (mod & has_data16
-                                    ? ((data[2] & 0xc0) == 0xc0
-                                       ? "movlhpd" : "movhpd")
-                                    : (data[2] & 0xc0) == 0xc0
-                                    ? "movlhps"
-                                    : "movhps");
-                             break;
-                           }
-                         if (data[1] == 0x28 || data[1] == 0x29)
-                           {
-                             bufcnt = 0;
-                             int mod = prefixes & has_data16;
-                             if (mod & (mod - 1))
-                               return -1;
-                             str = (mod & has_data16) ? "movapd" : "movaps";
-                             break;
-                           }
-                         if (data[1] == 0x2a)
-                           {
-                             bufcnt = 0;
-                             int mod = prefixes & (has_data16 | has_rep
-                                                   | has_repne);
-                             if (mod & (mod - 1))
-                               return -1;
-                             str = (mod & has_data16
-                                    ? "cvtpi2pd"
-                                    : mod & has_rep
-                                    ? "cvtsi2ss"
-                                    : mod & has_repne
-                                    ? "cvtsi2sd"
-                                    : "cvtpi2ps");
-                             break;
-                           }
-                         if (data[1] == 0x2b)
-                           {
-                             bufcnt = 0;
-                             int mod = prefixes & has_data16;
-                             if (mod & (mod - 1))
-                               return -1;
-                             prefixes ^= mod;
-                             str = (mod & has_data16) ? "movntpd" : "movntps";
-                             break;
-                           }
-                         if (data[1] == 0x2c)
-                           {
-                             bufcnt = 0;
-                             int mod = prefixes & (has_data16 | has_rep
-                                                   | has_repne);
-                             if (mod & (mod - 1))
-                               return -1;
-                             str = (mod & has_data16
-                                    ? "cvttpd2pi"
-                                    : mod & has_rep
-                                    ? "cvttss2si"
-                                    : mod & has_repne
-                                    ? "cvttsd2si"
-                                    : "cvttps2pi");
-                             break;
-                           }
-                         if (data[1] == 0x2d)
-                           {
-                             bufcnt = 0;
-                             int mod = prefixes & (has_data16 | has_rep
-                                                   | has_repne);
-                             if (mod & (mod - 1))
-                               return -1;
-                             str = (mod & has_data16
-                                    ? "cvtpd2pi"
-                                    : mod & has_rep
-                                    ? "cvtss2si"
-                                    : mod & has_repne
-                                    ? "cvtsd2si"
-                                    : "cvtps2pi");
-                             break;
-                           }
-                         if (data[1] == 0x2e)
-                           {
-                             int mod = prefixes & has_data16;
-                             if (mod & (mod - 1))
-                               return -1;
-                             str = (mod & has_data16
-                                    ? "ucomisd" : "ucomiss");
-                             break;
-                           }
-                         if (data[1] == 0x2f)
-                           {
-                             int mod = prefixes & has_data16;
-                             if (mod & (mod - 1))
-                               return -1;
-                             str = (mod & has_data16
-                                    ? "comisd" : "comiss");
-                             break;
-                           }
-                         if (data[1] == 0x50)
-                           {
-                             int mod = prefixes & has_data16;
-                             if (mod & (mod - 1))
-                               return -1;
-                             prefixes ^= mod;
-                             str = (mod & has_data16
-                                    ? "movmskpd" : "movmskps");
-                             break;
-                           }
-                         if (data[1] == 0x51)
-                           {
-                             bufcnt = 0;
-                             int mod = prefixes & (has_data16 | has_rep
-                                                   | has_repne);
-                             if (mod & (mod - 1))
-                               return -1;
-                             str = (mod & has_data16
-                                    ? "sqrtpd"
-                                    : mod & has_rep
-                                    ? "sqrtss"
-                                    : mod & has_repne
-                                    ? "sqrtsd"
-                                    : "sqrtps");
-                             break;
-                           }
-                         if (data[1] == 0x52)
-                           {
-                             bufcnt = 0;
-                             int mod = prefixes & has_rep;
-                             if (mod & (mod - 1))
-                               return -1;
-                             str = mod & has_rep ? "rsqrtss" : "rsqrtps";
-                             break;
-                           }
-                         if (data[1] == 0x53)
-                           {
-                             bufcnt = 0;
-                             int mod = prefixes & has_rep;
-                             if (mod & (mod - 1))
-                               return -1;
-                             str = mod & has_rep ? "rcpss" : "rcpps";
-                             break;
-                           }
-                         /* FALLTHROUGH */
-
                        default:
-                         abort ();
+                         assert (! "INVALID not handled");
                        }
                    }
                  else
@@ -778,9 +602,9 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
 #else
                                                           NULL,
 #endif
-                                                          instrtab[cnt].off1_1 + OFF1_1_BIAS,
-                                                          instrtab[cnt].off1_2 + OFF1_2_BIAS,
-                                                          instrtab[cnt].off1_3 + OFF1_3_BIAS,
+                                                          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, &param_start,
                                                           end,
@@ -810,9 +634,9 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
 #else
                                                           NULL,
 #endif
-                                                          instrtab[cnt].off2_1 + OFF2_1_BIAS,
-                                                          instrtab[cnt].off2_2 + OFF2_2_BIAS,
-                                                          instrtab[cnt].off2_3 + OFF2_3_BIAS,
+                                                          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, &param_start,
                                                           end,
@@ -842,14 +666,14 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr,
 #else
                                                           NULL,
 #endif
-                                                          instrtab[cnt].off3_1 + OFF3_1_BIAS,
+                                                          instrtab[cnt].off3_1 + OFF3_1_BIAS - opoff,
 #ifdef OFF3_2_BITS
-                                                          instrtab[cnt].off3_2 + OFF3_2_BIAS,
+                                                          instrtab[cnt].off3_2 + OFF3_2_BIAS - opoff,
 #else
                                                           0,
 #endif
 #ifdef OFF3_3_BITS
-                                                          instrtab[cnt].off3_3 + OFF3_3_BIAS,
+                                                          instrtab[cnt].off3_3 + OFF3_3_BIAS - opoff,
 #else
                                                           0,
 #endif
index ca01db8c9faac59b79acc14dc88ce933e9dcdfe6..a8570f195c7b24fcdf9d08a13baa47bffd433445 100644 (file)
@@ -1,3 +1,33 @@
+/* Generate tables for x86 disassembler.
+   Copyright (C) 2007, 2008 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
+   Written by Ulrich Drepper <drepper@redhat.com>, 2007.
+
+   Red Hat elfutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
 #include <error.h>
 #include <errno.h>
 #include <stdio.h>
index ea121909f8efca93b202e4cea740a5a7720383bc..828c558901f7fcb42336d7ac733ff069ad079793 100644 (file)
@@ -1,16 +1,27 @@
 %{
-/* Copyright (C) 2004, 2005, 2007 Red Hat, Inc.
+/* Copyright (C) 2004, 2005, 2007, 2008 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2004.
 
-   This program is Open Source software; you can redistribute it and/or
-   modify it under the terms of the Open Software License version 1.0 as
-   published by the Open Source Initiative.
-
-   You should have received a copy of the Open Software License along
-   with this program; if not, you may obtain a copy of the Open Software
-   License version 1.0 from http://www.opensource.org/licenses/osl.php or
-   by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
-   3001 King Ranch Road, Ukiah, CA 95482.   */
+   Red Hat elfutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
index 9ad1162248cd77ea296bf6103c501c56b0479eb7..4f434554d7d922c269542075e12c61933b0dbb78 100644 (file)
@@ -1,17 +1,28 @@
 %{
 /* Parser for i386 CPU description.
-   Copyright (C) 2004, 2005, 2007 Red Hat, Inc.
+   Copyright (C) 2004, 2005, 2007, 2008 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2004.
 
-   This program is Open Source software; you can redistribute it and/or
-   modify it under the terms of the Open Software License version 1.0 as
-   published by the Open Source Initiative.
-
-   You should have received a copy of the Open Software License along
-   with this program; if not, you may obtain a copy of the Open Software
-   License version 1.0 from http://www.opensource.org/licenses/osl.php or
-   by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
-   3001 King Ranch Road, Ukiah, CA 95482.   */
+   Red Hat elfutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
index 0d61f4854781aba265d7f2d349df014c50673042..c68eb4a0c3c1926c1fadfe848311223d29f959ec 100644 (file)
@@ -1,16 +1,27 @@
 /* Unaligned memory access functionality.
-   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Red Hat, Inc.
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2008 Red Hat, Inc.
    Written by Ulrich Drepper <drepper@redhat.com>, 2001.
 
-   This program is Open Source software; you can redistribute it and/or
-   modify it under the terms of the Open Software License version 1.0 as
-   published by the Open Source Initiative.
-
-   You should have received a copy of the Open Software License along
-   with this program; if not, you may obtain a copy of the Open Software
-   License version 1.0 from http://www.opensource.org/licenses/osl.php or
-   by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
-   3001 King Ranch Road, Ukiah, CA 95482.   */
+   Red Hat elfutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
 
 #ifndef _MEMORY_ACCESS_H
 #define _MEMORY_ACCESS_H 1
index f6ae7957c4716e5c8764a49d0826b251b52e78c5..b793b78d55ccdb57153886b0317008a0845e4fdc 100644 (file)
@@ -1,3 +1,29 @@
+/* Disassembler for x86-64.
+   Copyright (C) 2007, 2008 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
+   Written by Ulrich Drepper <drepper@redhat.com>, 2007.
+
+   Red Hat elfutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by the
+   Free Software Foundation; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
+
 #define i386_disasm x86_64_disasm
 #define DISFILE "x86_64_dis.h"
 #define MNEFILE "x86_64.mnemonics"