--- libdisasm-0.21pre4.orig/libdisasm/Makefile +++ libdisasm-0.21pre4/libdisasm/Makefile @@ -146,7 +146,7 @@ $(LD) $(LFLAGS) $(OBJ) -o $(LIBNAME) clean: - @$(RM) $(ARCHIVE) $(OBJ) $(LIBNAME) + @$(RM) $(ARCHIVE) $(OBJ) $(LIBNAME) $(BIN_PKG).so install: $(LIBNAME) $(ARCHIVE) [ -d $(INSTALL_LIB) ] || mkdir -p $(INSTALL_LIB) --- libdisasm-0.21pre4.orig/x86dis/Makefile +++ libdisasm-0.21pre4/x86dis/Makefile @@ -58,7 +58,7 @@ $(LD) $(LFLAGS) -o $@ $< clean: - rm $(OBJ) $(PROGRAM) + $(RM) $(OBJ) $(PROGRAM) install: $(PROGRAM) [ -d $(INSTALL_BIN) ] || mkdir $(INSTALL_BIN) --- libdisasm-0.21pre4.orig/Makefile +++ libdisasm-0.21pre4/Makefile @@ -83,7 +83,7 @@ cd libdisasm && make clean cd x86dis && make clean cd test && make clean - cd swig && make clean + #cd swig && make clean # ------------------------------------------------------- INSTALL install: $(LIBDIS) $(X86DIS) --- libdisasm-0.21pre4.orig/test/Makefile +++ libdisasm-0.21pre4/test/Makefile @@ -60,7 +60,7 @@ cd .. && make libdisasm clean: - rm $(TESTDIS_OBJ) $(TESTDIS) $(QUIKDIS_OBJ) $(QUIKDIS) + $(RM) $(TESTDIS_OBJ) $(TESTDIS) $(QUIKDIS_OBJ) $(QUIKDIS) ia32.o dist: mkdir -p $(DISTRIB_SRC)/test --- libdisasm-0.21pre4.orig/debian/patches/compiler-errors.patch +++ libdisasm-0.21pre4/debian/patches/compiler-errors.patch @@ -0,0 +1,12 @@ +diff -urNad libdisasm-0.21~/libdisasm/ia32_insn.h libdisasm-0.21/libdisasm/ia32_insn.h +--- libdisasm-0.21~/libdisasm/ia32_insn.h 2006-04-28 17:16:23.000000000 -0700 ++++ libdisasm-0.21/libdisasm/ia32_insn.h 2007-05-28 03:15:14.888589647 -0700 +@@ -33,7 +33,7 @@ + memcpy( i->bytes, buf, 1 ); + + +-unsigned int ia32_disasm_addr( unsigned char * buf, size_t buf_len, ++size_t ia32_disasm_addr( unsigned char * buf, size_t buf_len, + x86_insn_t *insn); + + --- libdisasm-0.21pre4.orig/debian/patches/libdisasm-invalid-insn-with-size.diff +++ libdisasm-0.21pre4/debian/patches/libdisasm-invalid-insn-with-size.diff @@ -0,0 +1,33 @@ +The released version of libdisasm has a gross bug where it can hit an invalid +opcode in the opcode tables while returning size > 1 to the caller. And +without fully marking the instruction as invalid. + +--- + libdisasm/ia32_insn.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +Index: libdisasm-0.21/libdisasm/ia32_insn.c +=================================================================== +--- libdisasm-0.21.orig/libdisasm/ia32_insn.c ++++ libdisasm-0.21/libdisasm/ia32_insn.c +@@ -474,6 +474,9 @@ size_t ia32_table_lookup( unsigned char + sub_size = ia32_table_lookup( &buf[1], buf_len - 1, table, + raw_insn, prefixes ); + ++ if (sub_size == INVALID_INSN) ++ return INVALID_INSN; ++ + /* a bit of a hack for branch hints */ + if ( prefix & BRANCH_HINT_MASK ) { + if ( INS_GROUP((*raw_insn)->mnem_flag) == INS_EXEC ) { +@@ -491,6 +494,10 @@ size_t ia32_table_lookup( unsigned char + (*prefixes) |= prefix; + } + ++ if (INS_TYPE((*raw_insn)->mnem_flag) == INS_INVALID) { ++ return INVALID_INSN; ++ } ++ + /* if this lookup was in a ModR/M table, then an opcode byte is + * NOT consumed: subtract accordingly. NOTE that if none of the + * operands used the ModR/M, then we need to consume the byte --- libdisasm-0.21pre4.orig/debian/patches/libdisasm-broken-ea.diff +++ libdisasm-0.21pre4/debian/patches/libdisasm-broken-ea.diff @@ -0,0 +1,76 @@ +The released version of libdisasm doesn't emit instructions correctly when +the mod/rm specifies that no base or index registers are to be used. + +As an example, this makes it misdisassemble "FF 25 ED C0 AD DE" as +"ljmp -559038227(,0)" instead of "ljmp *0xDEADC0ED". + +--- + libdisasm/x86_format.c | 48 +++++++++++++++++++++++++++++------------------- + 1 file changed, 29 insertions(+), 19 deletions(-) + +Index: libdisasm-0.21/libdisasm/x86_format.c +=================================================================== +--- libdisasm-0.21.orig/libdisasm/x86_format.c ++++ libdisasm-0.21/libdisasm/x86_format.c +@@ -162,25 +162,28 @@ static int format_expr( x86_ea_t *ea, ch + char str[MAX_OP_STRING]; + + if ( format == att_syntax ) { +- PRINT_DISPLACEMENT(ea); +- STRNCAT( buf, "(", len ); +- +- if ( ea->base.name[0]) { +- STRNCATF( buf, "%%%s", ea->base.name, len ); +- } +- if ( ea->index.name[0]) { +- STRNCATF( buf, ",%%%s", ea->index.name, len ); +- if ( ea->scale > 1 ) { +- STRNCATF( buf, ",%d", ea->scale, len ); +- } +- } +- /* handle the syntactic exception */ +- if ( ! ea->base.name[0] && +- ! ea->index.name[0] ) { +- STRNCATF( buf, ",%d", ea->scale, len ); +- } +- +- STRNCAT( buf, ")", len ); ++ if (ea->base.name[0] || ea->index.name[0] || ea->scale) { ++ PRINT_DISPLACEMENT(ea); ++ STRNCAT( buf, "(", len ); ++ ++ if ( ea->base.name[0]) { ++ STRNCATF( buf, "%%%s", ea->base.name, len ); ++ } ++ if ( ea->index.name[0]) { ++ STRNCATF( buf, ",%%%s", ea->index.name, len ); ++ if ( ea->scale > 1 ) { ++ STRNCATF( buf, ",%d", ea->scale, len ); ++ } ++ } ++ /* handle the syntactic exception */ ++ if ( ! ea->base.name[0] && ++ ! ea->index.name[0] ) { ++ STRNCATF( buf, ",%d", ea->scale, len ); ++ } ++ ++ STRNCAT( buf, ")", len ); ++ } else ++ STRNCATF( buf, "0x%lX", ea->disp, len ); + + } else if ( format == xml_syntax ){ + +@@ -695,6 +698,13 @@ static int format_operand_att( x86_op_t + break; + + case op_expression: ++ /* ATT requires a '*' before absolute JMP/CALL ops */ ++ if (insn->type == insn_jmp || insn->type == insn_call) { ++ if (!op->data.expression.base.name[0] && ++ !op->data.expression.index.name[0] && ++ !op->data.expression.scale) ++ STRNCAT( buf, "*", len ); ++ } + len -= format_seg( op, buf, len, att_syntax ); + len -= format_expr( &op->data.expression, buf, len, + att_syntax ); --- libdisasm-0.21pre4.orig/debian/patches/libdisasm-missing-opcodes.diff +++ libdisasm-0.21pre4/debian/patches/libdisasm-missing-opcodes.diff @@ -0,0 +1,52 @@ +There are a few opcodes missing from the libdisasm ia32 tables. We'll try to +fill those in as we find them. + +--- + libdisasm/ia32_insn.h | 4 +++- + libdisasm/ia32_opcode_tables.c | 4 ++-- + 2 files changed, 5 insertions(+), 3 deletions(-) + +Index: libdisasm-0.21/libdisasm/ia32_insn.h +=================================================================== +--- libdisasm-0.21.orig/libdisasm/ia32_insn.h ++++ libdisasm-0.21/libdisasm/ia32_insn.h +@@ -389,6 +389,7 @@ typedef struct { /* Assembly instructio + #define INS_TRACE (INS_TRAPS | 0x06) /* gen single step trap */ + #define INS_INVALIDOP (INS_TRAPS | 0x07) /* gen invalid insn */ + #define INS_OFLOW (INS_TRAPS | 0x08) /* gen overflow trap */ ++#define INS_ICEBP (INS_TRAPS | 0x09) /* ICE breakpoint */ + + /* INS_SYSTEM */ + #define INS_HALT (INS_SYSTEM | 0x01) /* halt machine */ +@@ -400,7 +401,8 @@ typedef struct { /* Assembly instructio + #define INS_NOP (INS_OTHER | 0x01) + #define INS_BCDCONV (INS_OTHER | 0x02) /* convert to/from BCD */ + #define INS_SZCONV (INS_OTHER | 0x03) /* convert size of operand */ +-#define INS_UNKNOWN (INS_OTHER | 0x04) ++#define INS_SALC (INS_OTHER | 0x04) /* set %al on carry */ ++#define INS_UNKNOWN (INS_OTHER | 0x05) + + + #define INS_TYPE_MASK 0xFFFF +Index: libdisasm-0.21/libdisasm/ia32_opcode_tables.c +=================================================================== +--- libdisasm-0.21.orig/libdisasm/ia32_opcode_tables.c ++++ libdisasm-0.21/libdisasm/ia32_opcode_tables.c +@@ -219,7 +219,7 @@ static ia32_insn_t tbl_Main[] = { /* One + { idx_D3, 0, ADDRMETH_E | OPTYPE_v, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "", 0, 1, 0, 0 , 0 }, + { 0, INS_BCDCONV, ADDRMETH_I | OPTYPE_b | OP_R, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "aam", 0, 0, 0, INS_SET_SIGN|INS_SET_ZERO|INS_SET_PARITY , 0 }, + { 0, INS_BCDCONV, ADDRMETH_I | OPTYPE_b | OP_R, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "aad", 0, 0, 0, INS_SET_SIGN|INS_SET_ZERO|INS_SET_PARITY , 2 }, +- { 0, INS_INVALID, ARG_NONE, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "", 0, 0, 0, 0 , 0 }, ++ { 0, INS_SALC, ARG_NONE, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "salc", 0, 0, 0, 0 , 0 }, + { 0, INS_XLAT, ARG_NONE, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "xlat", 0, 0, 0, 0 , 53 }, + { idx_D8, 0, ARG_NONE, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "", 0, 0, 0, 0 , 0 }, + { idx_D9, 0, ARG_NONE, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "", 0, 0, 0, 0 , 0 }, +@@ -246,7 +246,7 @@ static ia32_insn_t tbl_Main[] = { /* One + { 0, INS_OUT, ADDRMETH_RR | OPTYPE_w| OP_R, ADDRMETH_RR | OPTYPE_b| OP_R, ARG_NONE, cpu_80386 | isa_GP, "out", 2, 0, 0, 0 , 0 }, + { 0, INS_OUT, ADDRMETH_RR | OPTYPE_w| OP_R, ADDRMETH_RR | OPTYPE_v| OP_R, ARG_NONE, cpu_80386 | isa_GP, "out", 2, 0, 0, 0 , 0 }, + { 0, INS_NOTE_PREFIX | PREFIX_LOCK, ARG_NONE, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "", 0, 0, 0, 0 , 0 }, +- { 0, INS_INVALID, ARG_NONE, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "", 0, 0, 0, 0 , 0 }, ++ { 0, INS_ICEBP, ARG_NONE, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "icebp", 0, 0, 0, 0 , 0 }, + { idx_F2, INS_NOTE_PREFIX | PREFIX_REPNZ, ARG_NONE, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "", 0, 0, 0, 0 , 0 }, + { idx_F3, INS_NOTE_PREFIX | PREFIX_REPZ, ARG_NONE, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "", 0, 0, 0, 0 , 0 }, + { 0, INS_HALT, ARG_NONE, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "hlt", 0, 0, 0, 0 , 0 }, --- libdisasm-0.21pre4.orig/debian/patches/libdisasm-clean-oplist-free.diff +++ libdisasm-0.21pre4/debian/patches/libdisasm-clean-oplist-free.diff @@ -0,0 +1,20 @@ +Correctly zero out the ->operands pointer after x86_oplist_free() has freed +the data elements that it pointed at so we don't bomb out by trying to +follow it later. + +--- + libdisasm/x86_operand_list.c | 1 + + 1 file changed, 1 insertion(+) + +Index: libdisasm-0.21/libdisasm/x86_operand_list.c +=================================================================== +--- libdisasm-0.21.orig/libdisasm/x86_operand_list.c ++++ libdisasm-0.21/libdisasm/x86_operand_list.c +@@ -58,6 +58,7 @@ void x86_oplist_free( x86_insn_t *insn ) + free(op); + } + ++ insn->operands = NULL; + insn->operand_count = 0; + insn->explicit_count = 0; + --- libdisasm-0.21pre4.orig/debian/patches/test-fixes.patch +++ libdisasm-0.21pre4/debian/patches/test-fixes.patch @@ -0,0 +1,78 @@ +Index: libdisasm-0.21pre4/test/test_x86dis.pl +=================================================================== +--- libdisasm-0.21pre4.orig/test/test_x86dis.pl 2007-10-29 12:18:27.000000000 -0400 ++++ libdisasm-0.21pre4/test/test_x86dis.pl 2007-10-29 12:19:33.000000000 -0400 +@@ -10,7 +10,7 @@ + + # assembler settings + my $asm_file = 'ia32_test_insn.S'; +-my $obj_file = '/tmp/ia32.o'; ++my $obj_file = 'ia32.o'; + my $text_off = 0x34; # hopefully this won't change :) + my $text_size = 1986; # same + my $as = `which as`; +@@ -18,8 +18,8 @@ + # relative path, ld_library_path for running x86dis from compile dir + my $x86dis = '../x86dis/x86dis'; + # path is not needed now that libtool is being used +-#my $ldpath = 'LD_LIBRARY_PATH="../libdisasm"'; +-my $ldpath = ''; ++my $ldpath = 'LD_LIBRARY_PATH="../libdisasm"'; ++#my $ldpath = ''; + + my $x86dis_opt_str = "-f $obj_file -s att -r %d %d"; + +@@ -76,13 +76,13 @@ + ($a_mnem, $a_op, $jnk) = split / /, $asm_lines[$i]; + ($d_mnem, $d_op, $jnk) = split / /, $disasm_lines[$i]; + if ( $a_mnem eq $d_mnem and +- ($d_mnem =~ /^j/ or $d_mnem =~/call/ or ++ ($d_mnem =~ /^l?j/ or $d_mnem =~/l?call/ or + $d_mnem =~ /loop/ ) and $a_op =~ /^[-0-9]+/ ){ + next; + } + +- print "ERROR: orig '$asm_lines[$i]'\n"; +- print " dis '$disasm_lines[$i]' BYTES $bytes[$i]\n"; ++ print "DIFF: orig '$asm_lines[$i]'\n"; ++ print " dis '$disasm_lines[$i]' (BYTES $bytes[$i])\n"; + $status = 1; + } + } +Index: libdisasm-0.21pre4/test/ia32_test_insn.S +=================================================================== +--- libdisasm-0.21pre4.orig/test/ia32_test_insn.S 2007-10-29 12:18:27.000000000 -0400 ++++ libdisasm-0.21pre4/test/ia32_test_insn.S 2007-10-29 12:18:31.000000000 -0400 +@@ -15,7 +15,7 @@ + push %di + push %sp + push %bp +-push $1 ++push $0x01 + #; modr/m testing + pushw (%eax) + pushw (%ebx) +@@ -128,8 +128,8 @@ + int $0x01 + int3 + into +-invd #; priv +-invlpg (%eax) #; priv ++invd#; priv ++invlpg (%eax)#; priv + iret + ja 0x0 + jbe 0x0 +@@ -139,9 +139,9 @@ + jge 0x0 + jl 0x0 + jle 0x0 +-jmp 0x0 +-jmp -1 +-jmp 0xE000FFFF ++ljmp 0x0 ++ljmp -1 ++ljmp 0xE000FFFF + ljmp *0x80401000 + ljmp *(%eax) + jnc 0x0 --- libdisasm-0.21pre4.orig/debian/patches/libdisasm-opcode-group5.diff +++ libdisasm-0.21pre4/debian/patches/libdisasm-opcode-group5.diff @@ -0,0 +1,23 @@ +The official intel docs specify that FF xx011xxx should be "CALL Mp" and +FF xx101xxx should be "JMP Mp". + +--- + libdisasm/ia32_opcode_tables.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +Index: libdisasm-0.21/libdisasm/ia32_opcode_tables.c +=================================================================== +--- libdisasm-0.21.orig/libdisasm/ia32_opcode_tables.c ++++ libdisasm-0.21/libdisasm/ia32_opcode_tables.c +@@ -1945,9 +1945,9 @@ static ia32_insn_t tbl_FF[] = { /* Group + { 0, INS_INC, ADDRMETH_E | OPTYPE_v | OP_W | OP_R, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "inc", 0, 0, 0, INS_SET_OFLOW|INS_SET_SIGN|INS_SET_ZERO|INS_SET_PARITY , 0 }, + { 0, INS_DEC, ADDRMETH_E | OPTYPE_v | OP_W | OP_R, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "dec", 0, 0, 0, INS_SET_OFLOW|INS_SET_SIGN|INS_SET_ZERO|INS_SET_PARITY , 0 }, + { 0, INS_CALL, ADDRMETH_E | OPTYPE_v | OP_X, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "call", 0, 0, 0, 0 , 3 }, +- { 0, INS_CALL, ADDRMETH_E | OPTYPE_p | OP_X, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "callf", 0, 0, 0, 0 , 0 }, ++ { 0, INS_CALL, ADDRMETH_M | OPTYPE_p | OP_X, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "call", 0, 0, 0, 0 , 0 }, + { 0, INS_BRANCH, ADDRMETH_E | OPTYPE_v | OP_X, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "jmp", 0, 0, 0, 0 , 0 }, +- { 0, INS_BRANCH, ADDRMETH_E | OPTYPE_p | OP_X, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "jmp", 0, 0, 0, 0 , 0 }, ++ { 0, INS_BRANCH, ADDRMETH_M | OPTYPE_p | OP_X, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "jmp", 0, 0, 0, 0 , 0 }, + { 0, INS_PUSH, ADDRMETH_E | OPTYPE_v | OP_R, ARG_NONE, ARG_NONE, cpu_80386 | isa_GP, "push", 0, 0, 0, 0 , 33 } + }; + --- libdisasm-0.21pre4.orig/debian/patches/series +++ libdisasm-0.21pre4/debian/patches/series @@ -0,0 +1,9 @@ +compiler-errors.patch +makefile-errors.patch +test-fixes.patch +libdisasm-invalid-insn-with-size.diff +libdisasm-missing-opcodes.diff +libdisasm-broken-ea.diff +libdisasm-opcode-group5.diff +libdisasm-sign-ext-disp.diff +libdisasm-clean-oplist-free.diff --- libdisasm-0.21pre4.orig/debian/patches/makefile-errors.patch +++ libdisasm-0.21pre4/debian/patches/makefile-errors.patch @@ -0,0 +1,45 @@ +Index: libdisasm-0.21pre4/libdisasm/Makefile +=================================================================== +--- libdisasm-0.21pre4.orig/libdisasm/Makefile 2007-10-29 13:03:18.000000000 -0400 ++++ libdisasm-0.21pre4/libdisasm/Makefile 2007-10-29 13:03:32.000000000 -0400 +@@ -13,7 +13,7 @@ + + INCLUDE = -I. + +-CFLAGS = $(INCLUDE) -O3 $(DEBUG) -Wall -Wno-strict-aliasing ++CFLAGS = $(INCLUDE) $(DEB_HOST_CFLAGS) $(DEBUG) -fPIC -Wall -Wno-strict-aliasing + LFLAGS = $(FLAGS) -fPIC -shared -Wl,-soname,$(LIBNAME) + + ifndef CC +@@ -144,6 +144,7 @@ + $(LIBNAME): $(OBJ) + # make .so + $(LD) $(LFLAGS) $(OBJ) -o $(LIBNAME) ++ if [ ! -e $(BIN_PKG).so ]; then ln -s $(LIBNAME) $(BIN_PKG).so; fi + + clean: + @$(RM) $(ARCHIVE) $(OBJ) $(LIBNAME) $(BIN_PKG).so +@@ -151,8 +152,9 @@ + install: $(LIBNAME) $(ARCHIVE) + [ -d $(INSTALL_LIB) ] || mkdir -p $(INSTALL_LIB) + cp $(BIN_LIB) $(DEV_LIB) $(INSTALL_LIB) ++ if [ ! -e $(INSTALL_LIB)/$(BIN_PKG).so ]; then cd $(INSTALL_LIB); ln -s $(LIBNAME) $(BIN_PKG).so; fi + [ -d $(INSTALL_INC) ] || mkdir -p $(INSTALL_INC) +- cp $(DEV_INC) $(INSTALL_LIB) ++ cp $(DEV_INC) $(INSTALL_INC) + [ -d $(INSTALL_SHARE) ] || mkdir -p $(INSTALL_SHARE)/data + cp $(DEV_SHARE) $(INSTALL_SHARE)/data + +Index: libdisasm-0.21pre4/x86dis/Makefile +=================================================================== +--- libdisasm-0.21pre4.orig/x86dis/Makefile 2007-10-29 13:01:29.000000000 -0400 ++++ libdisasm-0.21pre4/x86dis/Makefile 2007-10-29 13:03:24.000000000 -0400 +@@ -14,7 +14,7 @@ + LD = gcc + + INCLUDE = -I../libdisasm +-CFLAGS = $(INCLUDE) -O3 $(DEBUG) -Wall -Wno-strict-aliasing \ ++CFLAGS = $(INCLUDE) $(DEB_HOST_CFLAGS) $(DEBUG) -Wall \ + -DX86DIS_VERSION=$(X86DIS_VERSION) -DPACKAGE_VERSION=$(X86DIS_VERSION) + LFLAGS = -L../libdisasm -ldisasm + --- libdisasm-0.21pre4.orig/debian/patches/libdisasm-sign-ext-disp.diff +++ libdisasm-0.21pre4/debian/patches/libdisasm-sign-ext-disp.diff @@ -0,0 +1,41 @@ +Need to sign extend the displacement if it's less than a full 32-bits. + +--- + libdisasm/ia32_modrm.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +Index: libdisasm-0.21/libdisasm/ia32_modrm.c +=================================================================== +--- libdisasm-0.21.orig/libdisasm/ia32_modrm.c ++++ libdisasm-0.21/libdisasm/ia32_modrm.c +@@ -163,11 +163,17 @@ static size_t modrm_decode16( unsigned c + + if ( modrm->mod == MOD16_MOD_DISP8 ) { + x86_imm_signsized( buf, buf_len, &ea->disp, sizeof(char) ); ++ /* this is really gross, but we need to sign-extend */ ++ /* the displacement */ ++ ea->disp = *((signed char *)&ea->disp); + ea->disp_sign = (ea->disp < 0) ? 1 : 0; + ea->disp_size = sizeof(char); + size += sizeof(char); + } else if ( modrm->mod == MOD16_MOD_DISP16 ) { + x86_imm_signsized( buf, buf_len, &ea->disp, sizeof(short) ); ++ /* this is really gross, but we need to sign-extend */ ++ /* the displacement */ ++ ea->disp = *((signed short *)&ea->disp); + ea->disp_sign = (ea->disp < 0) ? 1 : 0; + ea->disp_size = sizeof(short); + size += sizeof(short); +@@ -254,9 +260,11 @@ size_t ia32_modrm_decode( unsigned char + /* ELSE mod + r/m specify a disp##[base] or disp##(SIB) */ + if (modrm.mod == MODRM_MOD_DISP8) { /* mod == 01 */ + /* If this is an 8-bit displacement */ +- /* uh, this needs to be sign-extended */ + x86_imm_signsized( buf, buf_len, &ea->disp, + sizeof(char)); ++ /* this is really gross, but we need to sign-extend */ ++ /* the displacement */ ++ ea->disp = *((signed char *)&ea->disp); + ea->disp_size = sizeof(char); + ea->disp_sign = (ea->disp < 0) ? 1 : 0; + size += 1; /* add sizeof disp to count */ --- libdisasm-0.21pre4.orig/debian/libdisasm0.install +++ libdisasm-0.21pre4/debian/libdisasm0.install @@ -0,0 +1 @@ +usr/lib/lib*.so.* --- libdisasm-0.21pre4.orig/debian/libdisasm-dev.docs +++ libdisasm-0.21pre4/debian/libdisasm-dev.docs @@ -0,0 +1 @@ +doc/libdisasm.txt --- libdisasm-0.21pre4.orig/debian/compat +++ libdisasm-0.21pre4/debian/compat @@ -0,0 +1 @@ +5 --- libdisasm-0.21pre4.orig/debian/copyright +++ libdisasm-0.21pre4/debian/copyright @@ -0,0 +1,21 @@ +This package was debianized by Martin Albrecht +on Sat, 8 Oct 2005 17:50:13 +0200. + +It was downloaded from http://bastard.sourceforge.net + +Copyright: (C) 2004 Michael Mondragon + +License: + + The bastard disassembler is released under the Artistic License. This allows + the bastard to be freely distributed and modified. + +On Debian GNU/Linux systems, the complete text of the Artistic License +can be found in `/usr/share/common-licenses/Artistic'. + +The Debian packaging is (C) 2007, Kees Cook , (C) 2005 +Martin Albrecht , and is licensed under the +GPL. + +On Debian GNU/Linux systems, the complete text of the GNU General Public +License can be found in `/usr/share/common-licenses/GPL'. --- libdisasm-0.21pre4.orig/debian/changelog +++ libdisasm-0.21pre4/debian/changelog @@ -0,0 +1,5 @@ +libdisasm (0.21pre4-1) unstable; urgency=low + + * Initial Debian release. + + -- Kees Cook Sun, 28 Oct 2007 11:36:08 -0700 --- libdisasm-0.21pre4.orig/debian/control +++ libdisasm-0.21pre4/debian/control @@ -0,0 +1,43 @@ +Source: libdisasm +Section: libs +Priority: optional +Maintainer: Kees Cook +Build-Depends: debhelper (>= 5.0.0), quilt, perl +Standards-Version: 3.7.2 +XS-Vcs-Browser: http://bastard.cvs.sourceforge.net/bastard/libdisasm/ +XS-Vcs-Cvs: pserver:anonymous@bastard.cvs.sourceforge.net:/cvsroot/bastard + +Package: libdisasm-dev +Section: libdevel +Architecture: any +Depends: libdisasm0 (= ${binary:Version}) +Description: disassembler library for x86 code (development files) + Libdisasm is a disassembler for Intel x86-compatible object code. It compiles + as a shared and static library on Linux, FreeBSD, and Win32 platforms. The + core disassembly engine is contained in files with the prefix "i386", and is + shared with the x86 ARCH extension of the bastard disassembler. + . + This package contains the development files. + +Package: libdisasm0 +Section: libs +Architecture: any +Depends: ${shlibs:Depends} +Suggests: x86dis +Description: disassembler library for x86 code + Libdisasm is a disassembler for Intel x86-compatible object code. It compiles + as a shared and static library on Linux, FreeBSD, and Win32 platforms. The + core disassembly engine is contained in files with the prefix "i386", and is + shared with the x86 ARCH extension of the bastard disassembler. + +Package: x86dis +Section: utils +Architecture: any +Depends: ${shlibs:Depends} +Description: Frontend to libdisasm + Libdisasm is a disassembler for Intel x86-compatible object code. It compiles + as a shared and static library on Linux, FreeBSD, and Win32 platforms. The + core disassembly engine is contained in files with the prefix "i386", and is + shared with the x86 ARCH extension of the bastard disassembler. + . + This package contains the x86dis command-line frontend. --- libdisasm-0.21pre4.orig/debian/rules +++ libdisasm-0.21pre4/debian/rules @@ -0,0 +1,104 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +include /usr/share/quilt/quilt.make + +DEB_HOST_CFLAGS = -Wall -g + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + DEB_HOST_CFLAGS += -O0 +else + DEB_HOST_CFLAGS += -O3 +endif + +LIBNAME = libdisasm.so.0 + +configure: patch configure-stamp +configure-stamp: + dh_testdir + # Add here commands to configure the package. + + touch configure-stamp + +build: build-stamp +build-stamp: configure + dh_testdir + + # Add here commands to compile the package. + cd libdisasm && $(MAKE) DEB_HOST_CFLAGS="$(DEB_HOST_CFLAGS)" LIBNAME="$(LIBNAME)" LIBDIS="../libdisasm/$(LIBNAME)" + cd x86dis && $(MAKE) DEB_HOST_CFLAGS="$(DEB_HOST_CFLAGS)" LIBNAME="$(LIBNAME)" LIBDIS="../libdisasm/$(LIBNAME)" LFLAGS="-L../libdisasm -ldisasm" + + # Report test suite, but don't require that it pass + -cd test && ./test_x86dis.pl + + touch build-stamp + +clean: clean-patched unpatch +clean-patched: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Add here commands to clean up after the build process. + $(MAKE) clean LIBNAME="$(LIBNAME)" + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/$package + mkdir -p $(CURDIR)/debian/tmp/usr $(CURDIR)/debian/x86dis/usr + + cd libdisasm && $(MAKE) install INSTALL=$(CURDIR)/debian/tmp/usr LIBNAME="$(LIBNAME)" + cd x86dis && $(MAKE) install INSTALL=$(CURDIR)/debian/x86dis/usr + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples + dh_install --sourcedir=debian/tmp +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman -p libdisasm-dev man/libdisasm.7 man/x86_disasm.3 man/x86_format_insn.3 man/x86_init.3 + dh_installman -p x86dis man/x86dis.1 + dh_strip + dh_compress + dh_fixperms +# dh_perl +# dh_python + dh_makeshlibs + dh_installdeb + dh_shlibdeps +# dh_shlibdeps -L libdisasm0 -l debian/libdisasm0/usr/lib + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure --- libdisasm-0.21pre4.orig/debian/libdisasm-dev.install +++ libdisasm-0.21pre4/debian/libdisasm-dev.install @@ -0,0 +1,4 @@ +usr/share +usr/include +usr/lib/lib*.a +usr/lib/lib*.so