Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Waf build #106

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 18 additions & 22 deletions libudis86/udint.h
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
/* udis86 - libudis86/udint.h -- definitions for internal use only
*
*
* Copyright (c) 2002-2009 Vivek Thampi
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _UDINT_H_
#define _UDINT_H_

#include "types.h"

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif /* HAVE_CONFIG_H */

#if defined(UD_DEBUG) && HAVE_ASSERT_H
# include <assert.h>
# define UD_ASSERT(_x) assert(_x)
Expand Down Expand Up @@ -83,7 +79,7 @@
# define FMT64 "ll"
# elif defined(__amd64__) || defined(__x86_64__)
# define FMT64 "l"
# else
# else
# define FMT64 "ll"
# endif /* !x64 */
#endif
Expand Down
74 changes: 38 additions & 36 deletions scripts/ud_opcode.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# udis86 - scripts/ud_opcode.py
#
#
# Copyright (c) 2009, 2013 Vivek Thampi
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import os
Expand Down Expand Up @@ -75,7 +75,7 @@ def __str__(self):

class UdOpcodeTable:
"""A single table of instruction definitions, indexed by
a decode field.
a decode field.
"""

class CollisionError(Exception):
Expand All @@ -87,7 +87,7 @@ class IndexError(Exception):

@classmethod
def vendor2idx(cls, v):
return (0 if v == 'amd'
return (0 if v == 'amd'
else (1 if v == 'intel'
else 2))

Expand All @@ -96,21 +96,21 @@ def vex2idx(cls, v):
if v.startswith("none_"):
v = v[5:]
vexOpcExtMap = {
'none' : 0x0,
'0f' : 0x1,
'0f38' : 0x2,
'none' : 0x0,
'0f' : 0x1,
'0f38' : 0x2,
'0f3a' : 0x3,
'66' : 0x4,
'66_0f' : 0x5,
'66_0f38' : 0x6,
'66' : 0x4,
'66_0f' : 0x5,
'66_0f38' : 0x6,
'66_0f3a' : 0x7,
'f3' : 0x8,
'f3_0f' : 0x9,
'f3_0f38' : 0xa,
'f3' : 0x8,
'f3_0f' : 0x9,
'f3_0f38' : 0xa,
'f3_0f3a' : 0xb,
'f2' : 0xc,
'f2_0f' : 0xd,
'f2_0f38' : 0xe,
'f2' : 0xc,
'f2_0f' : 0xd,
'f2_0f38' : 0xe,
'f2_0f3a' : 0xf,
}
return vexOpcExtMap[v]
Expand All @@ -130,7 +130,7 @@ def vex2idx(cls, v):
# (16, 32, 64) => (00, 01, 02)
'/o' : lambda v: (int(v) / 32),
'/a' : lambda v: (int(v) / 32),
# Disassembly mode
# Disassembly mode
# (!64, 64) => (00b, 01b)
'/m' : lambda v: 1 if v == '64' else 0,
# SSE
Expand Down Expand Up @@ -211,7 +211,7 @@ def lookup(self, opc):
raise UdOpcodeTable.CollisionError("%s <-> %s" % (self._typ, typ))
return self._entries.get(idx, None)


def entryAt(self, index):
"""Returns the entry at a given index of the table,
None if there is none. Raises an exception if the
Expand Down Expand Up @@ -354,7 +354,7 @@ def genTableList(tbl):
genTableList(e)
self._tables = []
genTableList(self.root)


def patchAvx2byte(self):
# create avx tables
Expand Down Expand Up @@ -546,9 +546,11 @@ def getMnemonicsList(self):


def pprint(self):
def printWalk(tbl, indent=""):
def printWalk(tbl, indent = ""):
entries = tbl.entries()
for k, e in entries:
# Make it work in python 3
k = int(k)
if isinstance(e, UdOpcodeTable):
self.log("%s |-<%02x> %s" % (indent, k, e))
printWalk(e, indent + " |")
Expand Down Expand Up @@ -586,7 +588,7 @@ def parseOptableXML(xml):
tlNode = xmlDoc.firstChild
insns = []

while tlNode and tlNode.localName != "x86optable":
while tlNode and tlNode.localName != "x86optable":
tlNode = tlNode.nextSibling

for insnNode in tlNode.childNodes:
Expand Down
65 changes: 33 additions & 32 deletions udcli/udcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,52 @@
*
* Copyright (c) 2002-2013 Vivek Thampi
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>

#ifdef _MSC_VER
#include "..\udis86.h"
#define PACKAGE_STRING "udis86 pre-1.8"
#else
#include <udis86.h>
#include <config.h>
#define PACKAGE_STRING "udis86 pre-1.8"
#endif

#if defined(__APPLE__)
# define FMT64 "ll"
# define FMT64 "ll"
#elif defined(__amd64__) || defined(__x86_64__)
# define FMT64 "l"
# define FMT64 "l"
# else
# define FMT64 "ll"
# define FMT64 "ll"
#endif

#if defined(__DJGPP__) || defined(_WIN32)
# include <io.h>
# include <fcntl.h>
#endif
#endif

#ifdef __DJGPP__
# include <unistd.h> /* for isatty() */
Expand All @@ -56,7 +57,7 @@
#endif

/* help string */
static char help[] =
static char help[] =
{
"Usage: %s [-option[s]] file\n"
"Options:\n"
Expand All @@ -76,7 +77,7 @@ static char help[] =
" -h : Display this help message.\n"
" --version: Show version.\n"
"\n"
"Udcli is a front-end to the Udis86 Disassembler Library.\n"
"Udcli is a front-end to the Udis86 Disassembler Library.\n"
"http://udis86.sourceforge.net/\n"
};

Expand Down Expand Up @@ -108,7 +109,7 @@ int main(int argc, char **argv)
#endif
#if defined(__DJGPP) || defined(_WIN32)
_setmode(_fileno(stdin), _O_BINARY);
#endif
#endif

fptr = stdin;

Expand Down Expand Up @@ -140,7 +141,7 @@ int main(int argc, char **argv)
s = *(++argv);
if (sscanf(s, "%" FMT64 "u", &o_skip) == 0)
fprintf(stderr, "Invalid value given for -s.\n");
} else {
} else {
fprintf(stderr, "No value given for -s.\n");
printf(help, prog_path);
exit(EXIT_FAILURE);
Expand All @@ -151,7 +152,7 @@ int main(int argc, char **argv)
s = *(++argv);
if (sscanf(s, "%" FMT64 "u", &o_count) == 0)
fprintf(stderr, "Invalid value given for -c.\n");
} else {
} else {
fprintf(stderr, "No value given for -c.\n");
printf(help, prog_path);
exit(EXIT_FAILURE);
Expand All @@ -161,7 +162,7 @@ int main(int argc, char **argv)
s = *(++argv);
if (*s == 'i')
ud_set_vendor(&ud_obj, UD_VENDOR_INTEL);
} else {
} else {
fprintf(stderr, "No value given for -v.\n");
printf(help, prog_path);
exit(EXIT_FAILURE);
Expand All @@ -173,7 +174,7 @@ int main(int argc, char **argv)
if (sscanf(s, "%" FMT64 "x", &pc) == 0)
fprintf(stderr, "Invalid value given for -o.\n");
ud_set_pc(&ud_obj, pc);
} else {
} else {
fprintf(stderr, "No value given for -o.\n");
printf(help, prog_path);
exit(EXIT_FAILURE);
Expand Down Expand Up @@ -202,7 +203,7 @@ int main(int argc, char **argv)

if (o_do_x)
ud_set_input_hook(&ud_obj, input_hook_x);
else ud_set_input_hook(&ud_obj, input_hook_file);
else ud_set_input_hook(&ud_obj, input_hook_file);

if (o_skip) {
o_count += o_skip;
Expand All @@ -224,12 +225,12 @@ int main(int argc, char **argv)
printf("%15s -", "");
printf("%-16s", hex2);
}
}
}
else printf(" %-24s", ud_insn_asm(&ud_obj));

printf("\n");
}

exit(EXIT_SUCCESS);
return 0;
}
Expand All @@ -255,7 +256,7 @@ int input_hook_x(ud_t* u)
if (c > 0xFF)
fprintf(stderr, "Warning: Casting non-8-bit input (%x), to %x.\n", c, c & 0xFF);
return (int) (c & 0xFF);
}
}

int input_hook_file(ud_t* u)
{
Expand Down
Loading