diff --git a/ANNOUNCE b/ANNOUNCE index b2255e5bf9f..ebdf2dcc090 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,13 +1,14 @@ -This is release 950109 of Wine the MS Windows emulator. This is still a +This is release 950122 of Wine the MS Windows emulator. This is still a developer's only release. There are many bugs and many unimplemented API features. Most applications still do not work. Patches should be submitted to "wine-new@amscons.com". Please don't forget -to include a ChangeLog entry. I'll try to make a new release every Sunday. +to include a ChangeLog entry. I'll make a new release every other Sunday. -WHAT'S NEW with Wine-950109: (see ChangeLog for details) - - Compiling with -Wall. Don't panic if you get many warnings... - - Better StretchBlt() +WHAT'S NEW with Wine-950122: (see ChangeLog for details) + - ELF format support + - New disassembler based on Mach code, replacing the gdb code + - Faster regions - Lots of bug fixes See the README file in the distribution for installation instructions. @@ -16,11 +17,11 @@ Because of lags created by using mirror, this message may reach you before the release is available at the ftp sites. The sources will be available from the following locations: - sunsite.unc.edu:/pub/Linux/ALPHA/wine/Wine-950109.tar.gz - aris.com:/pub/linux/ALPHA/Wine/development/Wine-950109.tar.gz - tsx-11.mit.edu:/pub/linux/ALPHA/Wine/development/Wine-950109.tar.gz - ftp.funet.fi:/pub/OS/Linux/ALPHA/Wine/Wine-950109.tar.gz - ftp.wonderland.org:/Wine/Wine-950109.tar.gz + sunsite.unc.edu:/pub/Linux/ALPHA/wine/Wine-950122.tar.gz + aris.com:/pub/linux/ALPHA/Wine/development/Wine-950122.tar.gz + tsx-11.mit.edu:/pub/linux/ALPHA/Wine/development/Wine-950122.tar.gz + ftp.funet.fi:/pub/OS/Linux/ALPHA/Wine/Wine-950122.tar.gz + ftp.wonderland.org:/Wine/Wine-950122.tar.gz If you submitted a patch, please check to make sure it has been included in the new release. diff --git a/ChangeLog b/ChangeLog index 2ebc86d31d6..7592fc4e9f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,81 @@ +---------------------------------------------------------------------- +Sun Jan 22 18:55:33 1995 Alexandre Julliard (julliard@lamisun.epfl.ch) + + * [loader/resource.c] [objects/dib.c] + Fixed icon loading and drawing, now that BitBlt() works correctly. + + * [objects/clipping.c] [objects/region.c] + Implemented elliptic regions with a set of rectangle. This greatly + simplifies the region code and should boost clipping performance. + + * [objects/color.c] + Fixed bug that caused seg-fault on 24bpp displays. + + * [objects/bitblt.c] + Fixed bug when shrinking a bitmap to more than half its size. + + * [windows/graphics.c] + Fixed bugs in PaintRgn() and Polyline(). + + * [windows/nonclient.c] [windows/painting.c] [windows/winpos.c] + Fixed some problems with window background painting. + +Thu Jan 12 12:20:25 PST 1995 Ross Biro (biro@yggdrasil.com) + + * [tools/build.c] + * [tools/newbuild.c] + * [Imakefile] + * [include/wine.h] + * [loader/call.S] + * [loader/selector.c] + * [include/segmem.h] + * [misc/main.c] + Changed selector code and 16/32 bit xfer code so that wine + no longer has to be loaded low in memory. Changed wine + to work with ELF binary formats under Linux. + +Sat Sep 17 11:08:49 1994 Eric Youngdale (eric@esp22) + + * [debugger/db_disasm.c] + New instruction disassembler - borrowed from Mach kernel. Has a + BSD style of license as opposed to the gdb code we were previously + using which was under the GPL. + +---------------------------------------------------------------------- +Mon Jan 9 18:27:11 1995 Alexandre Julliard (julliard@lamisun.epfl.ch) + + * [Imakefile] + Compiling with -Wall flag. + + * [*/*] + Fixes to minimize the number of compilation warnings. + + * [objects/bitblt.c] + Fixed BitBlt() and used the same code to rewrite PatBlt() and + StretchBlt(). The three *Blt() functions should now be correct in + every case (famous last words). + + * [objects/brush.c] [objects/dither.c] + Merged the two files into brush.c + + * [objects/dc.c] + Fixed bug when the Windows programs forget to re-select the + original bitmap in a memory DC. + + * [objects/font.c] + Tty to use 'fixed' font when the system font can't be found. + + * [windows/dialog.c] + Tentative fix to make dialogs look better when using fixed-width + fonts. + + * [windows/graphics.c] + Partially implemented the PS_INSIDEFRAME pen style. + + * [windows/nonclient.c] + Fix for windows that have the WS_EX_DLGMODALFRAME style bit + without the WS_DLGFRAME style. + Thu Jan 5 13:37:42 1995 Cameron Heide (heide@ee.ualberta.ca) * [memory/global.c] @@ -10,11 +88,13 @@ Thu Jan 5 13:37:42 1995 Cameron Heide (heide@ee.ualberta.ca) Sun Jan 1 23:30:25 1995 Fons Botman - * objects/font.c (GetTextExtentPoint): - Fixed debug output, str is counted string, not zero terminated. + * [objects/font.c] + GetTextExtentPoint: fixed debug output, str is counted string, not + zero terminated. - * if1632/relay.c (DLLRelay): - When debugging_stack got segv, added upper bound for stack dump. + * [if1632/relay.c] + DLLRelay: when debugging_stack got segv, added upper bound for + stack dump. ---------------------------------------------------------------------- Tue Dec 27 13:35:16 1994 Alexandre Julliard (julliard@lamisun.epfl.ch) diff --git a/Imakefile b/Imakefile index f5e2fad4ead..cd14207ea10 100644 --- a/Imakefile +++ b/Imakefile @@ -7,7 +7,11 @@ CC = gcc -D__FreeBSD__ #endif DEFINES = AutoDefines -DUSE_READLINE -DWINESTAT +#ifdef __ELF__ +CDEBUGFLAGS = -O2 -Wall -static +#else CDEBUGFLAGS = -O2 -Wall +#endif /* * This is the second try at using Imakefiles. There are probably many diff --git a/README b/README index d172aa95642..59e768b4c59 100644 --- a/README +++ b/README @@ -8,11 +8,6 @@ API calls to their Unix/X11 equivalent. Wine is free software. See the file LICENSE for the details. Basically, you can do anything with it, except claim that you wrote it. -Important note: current versions of Wine include a built-in debugger -for 16-bit code, that is based on code from gdb. This means that if -you redistribute a version of Wine that includes this debugger, you -must follow the terms of the GNU General Public License. - 2. COMPILATION diff --git a/controls/menu.c b/controls/menu.c index 0647eaf1e15..bfe0fbffa5c 100644 --- a/controls/menu.c +++ b/controls/menu.c @@ -1357,6 +1357,7 @@ void MENU_TrackMouseMenuBar( HWND hwnd, POINT pt ) void MENU_TrackKbdMenuBar( HWND hwnd, WORD wParam ) { WND *wndPtr = WIN_FindWndPtr( hwnd ); + if (!wndPtr->wIDmenu) return; SendMessage( hwnd, WM_ENTERMENULOOP, 0, 0 ); /* Select first selectable item */ MENU_SelectItem( wndPtr->wIDmenu, NO_SELECTED_ITEM ); diff --git a/controls/static.c b/controls/static.c index 85345d8edea..31916045b8a 100644 --- a/controls/static.c +++ b/controls/static.c @@ -134,7 +134,11 @@ LONG StaticWndProc(HWND hWnd, WORD uMsg, WORD wParam, LONG lParam) break; case WM_SETTEXT: - DEFWND_SetText( hWnd, (LPSTR)lParam ); + if (style == SS_ICON) + STATIC_SetIcon( hWnd, LoadIcon( wndPtr->hInstance, + (LPSTR)lParam ) ); + else + DEFWND_SetText( hWnd, (LPSTR)lParam ); InvalidateRect( hWnd, NULL, FALSE ); UpdateWindow( hWnd ); break; diff --git a/debugger/Imakefile b/debugger/Imakefile index a6c260c5cb7..7b7ea9d9296 100644 --- a/debugger/Imakefile +++ b/debugger/Imakefile @@ -6,20 +6,19 @@ MODULE = debugger -SUBDIRS = opcodes readline +SUBDIRS = readline -DEFINES = -DUSE_READLINE -Iopcodes +DEFINES = -DUSE_READLINE SRCS = \ - dbg.tab.c \ break.c \ + db_disasm.c \ + dbg.tab.c \ hash.c \ - lex.yy.c \ - info.c + info.c \ + lex.yy.c -SUBDIRS_OBJS = \ - opcodes/opcodes.o \ - readline/readline.o +SUBDIRS_OBJS = readline/readline.o OBJS = $(SRCS:.c=.o) $(SUBDIRS_OBJS) diff --git a/debugger/db_disasm.c b/debugger/db_disasm.c new file mode 100644 index 00000000000..5cb26fd6060 --- /dev/null +++ b/debugger/db_disasm.c @@ -0,0 +1,1483 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + * HISTORY + * $Log: db_disasm.c,v $ + * Revision 2.6 92/01/03 20:05:00 dbg + * Add a switch to disassemble 16-bit code. + * Fix spelling of 'lods' opcodes. + * [91/10/30 dbg] + * + * Revision 2.5 91/10/09 16:05:58 af + * Supported disassemble of non current task by passing task parameter. + * [91/08/29 tak] + * + * Revision 2.4 91/05/14 16:05:04 mrt + * Correcting copyright + * + * Revision 2.3 91/02/05 17:11:03 mrt + * Changed to new Mach copyright + * [91/02/01 17:31:03 mrt] + * + * Revision 2.2 90/08/27 21:55:56 dbg + * Fix register operand for move to/from control/test/debug + * register instructions. Add i486 instructions. + * [90/08/27 dbg] + * + * Import db_sym.h. Print instruction displacements in + * current radix (signed). Change calling sequence of + * db_disasm. + * [90/08/21 dbg] + * Fix includes. + * [90/08/08 dbg] + * Created. + * [90/07/25 dbg] + * + */ + +/* + * Instruction disassembler. + */ +#if 0 +#include +#include "db_machdep.h" + +#include "db_access.h" +#include "db_sym.h" + +#include +#endif +#include +#include "db_disasm.h" + +/* + * Switch to disassemble 16-bit code. + */ +static boolean_t db_disasm_16 = FALSE; + +/* + * Size attributes + */ +#define BYTE 0 +#define WORD 1 +#define LONG 2 +#define QUAD 3 +#define SNGL 4 +#define DBLR 5 +#define EXTR 6 +#define SDEP 7 +#define NONE 8 + +/* + * Addressing modes + */ +#define E 1 /* general effective address */ +#define Eind 2 /* indirect address (jump, call) */ +#define Ew 3 /* address, word size */ +#define Eb 4 /* address, byte size */ +#define R 5 /* register, in 'reg' field */ +#define Rw 6 /* word register, in 'reg' field */ +#define Ri 7 /* register in instruction */ +#define S 8 /* segment reg, in 'reg' field */ +#define Si 9 /* segment reg, in instruction */ +#define A 10 /* accumulator */ +#define BX 11 /* (bx) */ +#define CL 12 /* cl, for shifts */ +#define DX 13 /* dx, for IO */ +#define SI 14 /* si */ +#define DI 15 /* di */ +#define CR 16 /* control register */ +#define DR 17 /* debug register */ +#define TR 18 /* test register */ +#define I 19 /* immediate, unsigned */ +#define Is 20 /* immediate, signed */ +#define Ib 21 /* byte immediate, unsigned */ +#define Ibs 22 /* byte immediate, signed */ +#define Iw 23 /* word immediate, unsigned */ +#define Il 24 /* long immediate */ +#define O 25 /* direct address */ +#define Db 26 /* byte displacement from EIP */ +#define Dl 27 /* long displacement from EIP */ +#define o1 28 /* constant 1 */ +#define o3 29 /* constant 3 */ +#define OS 30 /* immediate offset/segment */ +#define ST 31 /* FP stack top */ +#define STI 32 /* FP stack */ +#define X 33 /* extended FP op */ +#define XA 34 /* for 'fstcw %ax' */ + +struct inst { + char * i_name; /* name */ + short i_has_modrm; /* has regmodrm byte */ + short i_size; /* operand size */ + int i_mode; /* addressing modes */ + char * i_extra; /* pointer to extra opcode table */ +}; + +#define op1(x) (x) +#define op2(x,y) ((x)|((y)<<8)) +#define op3(x,y,z) ((x)|((y)<<8)|((z)<<16)) + +struct finst { + char * f_name; /* name for memory instruction */ + int f_size; /* size for memory instruction */ + int f_rrmode; /* mode for rr instruction */ + char * f_rrname; /* name for rr instruction + (or pointer to table) */ +}; + +static char * db_Grp6[] = { + "sldt", + "str", + "lldt", + "ltr", + "verr", + "verw", + "", + "" +}; + +static char * db_Grp7[] = { + "sgdt", + "sidt", + "lgdt", + "lidt", + "smsw", + "", + "lmsw", + "invlpg" +}; + +static char * db_Grp8[] = { + "", + "", + "", + "", + "bt", + "bts", + "btr", + "btc" +}; + +static struct inst db_inst_0f0x[] = { +/*00*/ { "", TRUE, NONE, op1(Ew), (char *)db_Grp6 }, +/*01*/ { "", TRUE, NONE, op1(Ew), (char *)db_Grp7 }, +/*02*/ { "lar", TRUE, LONG, op2(E,R), 0 }, +/*03*/ { "lsl", TRUE, LONG, op2(E,R), 0 }, +/*04*/ { "", FALSE, NONE, 0, 0 }, +/*05*/ { "", FALSE, NONE, 0, 0 }, +/*06*/ { "clts", FALSE, NONE, 0, 0 }, +/*07*/ { "", FALSE, NONE, 0, 0 }, + +/*08*/ { "invd", FALSE, NONE, 0, 0 }, +/*09*/ { "wbinvd",FALSE, NONE, 0, 0 }, +/*0a*/ { "", FALSE, NONE, 0, 0 }, +/*0b*/ { "", FALSE, NONE, 0, 0 }, +/*0c*/ { "", FALSE, NONE, 0, 0 }, +/*0d*/ { "", FALSE, NONE, 0, 0 }, +/*0e*/ { "", FALSE, NONE, 0, 0 }, +/*0f*/ { "", FALSE, NONE, 0, 0 }, +}; + +static struct inst db_inst_0f2x[] = { +/*20*/ { "mov", TRUE, LONG, op2(CR,E), 0 }, /* use E for reg */ +/*21*/ { "mov", TRUE, LONG, op2(DR,E), 0 }, /* since mod == 11 */ +/*22*/ { "mov", TRUE, LONG, op2(E,CR), 0 }, +/*23*/ { "mov", TRUE, LONG, op2(E,DR), 0 }, +/*24*/ { "mov", TRUE, LONG, op2(TR,E), 0 }, +/*25*/ { "", FALSE, NONE, 0, 0 }, +/*26*/ { "mov", TRUE, LONG, op2(E,TR), 0 }, +/*27*/ { "", FALSE, NONE, 0, 0 }, + +/*28*/ { "", FALSE, NONE, 0, 0 }, +/*29*/ { "", FALSE, NONE, 0, 0 }, +/*2a*/ { "", FALSE, NONE, 0, 0 }, +/*2b*/ { "", FALSE, NONE, 0, 0 }, +/*2c*/ { "", FALSE, NONE, 0, 0 }, +/*2d*/ { "", FALSE, NONE, 0, 0 }, +/*2e*/ { "", FALSE, NONE, 0, 0 }, +/*2f*/ { "", FALSE, NONE, 0, 0 }, +}; + +static struct inst db_inst_0f8x[] = { +/*80*/ { "jo", FALSE, NONE, op1(Dl), 0 }, +/*81*/ { "jno", FALSE, NONE, op1(Dl), 0 }, +/*82*/ { "jb", FALSE, NONE, op1(Dl), 0 }, +/*83*/ { "jnb", FALSE, NONE, op1(Dl), 0 }, +/*84*/ { "jz", FALSE, NONE, op1(Dl), 0 }, +/*85*/ { "jnz", FALSE, NONE, op1(Dl), 0 }, +/*86*/ { "jbe", FALSE, NONE, op1(Dl), 0 }, +/*87*/ { "jnbe", FALSE, NONE, op1(Dl), 0 }, + +/*88*/ { "js", FALSE, NONE, op1(Dl), 0 }, +/*89*/ { "jns", FALSE, NONE, op1(Dl), 0 }, +/*8a*/ { "jp", FALSE, NONE, op1(Dl), 0 }, +/*8b*/ { "jnp", FALSE, NONE, op1(Dl), 0 }, +/*8c*/ { "jl", FALSE, NONE, op1(Dl), 0 }, +/*8d*/ { "jnl", FALSE, NONE, op1(Dl), 0 }, +/*8e*/ { "jle", FALSE, NONE, op1(Dl), 0 }, +/*8f*/ { "jnle", FALSE, NONE, op1(Dl), 0 }, +}; + +static struct inst db_inst_0f9x[] = { +/*90*/ { "seto", TRUE, NONE, op1(Eb), 0 }, +/*91*/ { "setno", TRUE, NONE, op1(Eb), 0 }, +/*92*/ { "setb", TRUE, NONE, op1(Eb), 0 }, +/*93*/ { "setnb", TRUE, NONE, op1(Eb), 0 }, +/*94*/ { "setz", TRUE, NONE, op1(Eb), 0 }, +/*95*/ { "setnz", TRUE, NONE, op1(Eb), 0 }, +/*96*/ { "setbe", TRUE, NONE, op1(Eb), 0 }, +/*97*/ { "setnbe",TRUE, NONE, op1(Eb), 0 }, + +/*98*/ { "sets", TRUE, NONE, op1(Eb), 0 }, +/*99*/ { "setns", TRUE, NONE, op1(Eb), 0 }, +/*9a*/ { "setp", TRUE, NONE, op1(Eb), 0 }, +/*9b*/ { "setnp", TRUE, NONE, op1(Eb), 0 }, +/*9c*/ { "setl", TRUE, NONE, op1(Eb), 0 }, +/*9d*/ { "setnl", TRUE, NONE, op1(Eb), 0 }, +/*9e*/ { "setle", TRUE, NONE, op1(Eb), 0 }, +/*9f*/ { "setnle",TRUE, NONE, op1(Eb), 0 }, +}; + +static struct inst db_inst_0fax[] = { +/*a0*/ { "push", FALSE, NONE, op1(Si), 0 }, +/*a1*/ { "pop", FALSE, NONE, op1(Si), 0 }, +/*a2*/ { "", FALSE, NONE, 0, 0 }, +/*a3*/ { "bt", TRUE, LONG, op2(E,R), 0 }, +/*a4*/ { "shld", TRUE, LONG, op3(Ib,E,R), 0 }, +/*a5*/ { "shld", TRUE, LONG, op3(CL,E,R), 0 }, +/*a6*/ { "", FALSE, NONE, 0, 0 }, +/*a7*/ { "", FALSE, NONE, 0, 0 }, + +/*a8*/ { "push", FALSE, NONE, op1(Si), 0 }, +/*a9*/ { "pop", FALSE, NONE, op1(Si), 0 }, +/*aa*/ { "", FALSE, NONE, 0, 0 }, +/*ab*/ { "bts", TRUE, LONG, op2(E,R), 0 }, +/*ac*/ { "shrd", TRUE, LONG, op3(Ib,E,R), 0 }, +/*ad*/ { "shrd", TRUE, LONG, op3(CL,E,R), 0 }, +/*a6*/ { "", FALSE, NONE, 0, 0 }, +/*a7*/ { "imul", TRUE, LONG, op2(E,R), 0 }, +}; + +static struct inst db_inst_0fbx[] = { +/*b0*/ { "", FALSE, NONE, 0, 0 }, +/*b1*/ { "", FALSE, NONE, 0, 0 }, +/*b2*/ { "lss", TRUE, LONG, op2(E, R), 0 }, +/*b3*/ { "bts", TRUE, LONG, op2(R, E), 0 }, +/*b4*/ { "lfs", TRUE, LONG, op2(E, R), 0 }, +/*b5*/ { "lgs", TRUE, LONG, op2(E, R), 0 }, +/*b6*/ { "movzb", TRUE, LONG, op2(E, R), 0 }, +/*b7*/ { "movzw", TRUE, LONG, op2(E, R), 0 }, + +/*b8*/ { "", FALSE, NONE, 0, 0 }, +/*b9*/ { "", FALSE, NONE, 0, 0 }, +/*ba*/ { "", TRUE, LONG, op2(Is, E), (char *)db_Grp8 }, +/*bb*/ { "btc", TRUE, LONG, op2(R, E), 0 }, +/*bc*/ { "bsf", TRUE, LONG, op2(E, R), 0 }, +/*bd*/ { "bsr", TRUE, LONG, op2(E, R), 0 }, +/*be*/ { "movsb", TRUE, LONG, op2(E, R), 0 }, +/*bf*/ { "movsw", TRUE, LONG, op2(E, R), 0 }, +}; + +static struct inst db_inst_0fcx[] = { +/*c0*/ { "xadd", TRUE, BYTE, op2(R, E), 0 }, +/*c1*/ { "xadd", TRUE, LONG, op2(R, E), 0 }, +/*c2*/ { "", FALSE, NONE, 0, 0 }, +/*c3*/ { "", FALSE, NONE, 0, 0 }, +/*c4*/ { "", FALSE, NONE, 0, 0 }, +/*c5*/ { "", FALSE, NONE, 0, 0 }, +/*c6*/ { "", FALSE, NONE, 0, 0 }, +/*c7*/ { "", FALSE, NONE, 0, 0 }, +/*c8*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, +/*c9*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, +/*ca*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, +/*cb*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, +/*cc*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, +/*cd*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, +/*ce*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, +/*cf*/ { "bswap", FALSE, LONG, op1(Ri), 0 }, +}; + +static struct inst db_inst_0fdx[] = { +/*c0*/ { "cmpxchg",TRUE, BYTE, op2(R, E), 0 }, +/*c1*/ { "cmpxchg",TRUE, LONG, op2(R, E), 0 }, +/*c2*/ { "", FALSE, NONE, 0, 0 }, +/*c3*/ { "", FALSE, NONE, 0, 0 }, +/*c4*/ { "", FALSE, NONE, 0, 0 }, +/*c5*/ { "", FALSE, NONE, 0, 0 }, +/*c6*/ { "", FALSE, NONE, 0, 0 }, +/*c7*/ { "", FALSE, NONE, 0, 0 }, +/*c8*/ { "", FALSE, NONE, 0, 0 }, +/*c9*/ { "", FALSE, NONE, 0, 0 }, +/*ca*/ { "", FALSE, NONE, 0, 0 }, +/*cb*/ { "", FALSE, NONE, 0, 0 }, +/*cc*/ { "", FALSE, NONE, 0, 0 }, +/*cd*/ { "", FALSE, NONE, 0, 0 }, +/*ce*/ { "", FALSE, NONE, 0, 0 }, +/*cf*/ { "", FALSE, NONE, 0, 0 }, +}; + +static struct inst *db_inst_0f[] = { + db_inst_0f0x, + 0, + db_inst_0f2x, + 0, + 0, + 0, + 0, + 0, + db_inst_0f8x, + db_inst_0f9x, + db_inst_0fax, + db_inst_0fbx, + db_inst_0fcx, + db_inst_0fdx, + 0, + 0 +}; + +static char * db_Esc92[] = { + "fnop", "", "", "", "", "", "", "" +}; +static char * db_Esc93[] = { + "", "", "", "", "", "", "", "" +}; +static char * db_Esc94[] = { + "fchs", "fabs", "", "", "ftst", "fxam", "", "" +}; +static char * db_Esc95[] = { + "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","" +}; +static char * db_Esc96[] = { + "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp", + "fincstp" +}; +static char * db_Esc97[] = { + "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos" +}; + +static char * db_Esca4[] = { + "", "fucompp","", "", "", "", "", "" +}; + +static char * db_Escb4[] = { + "", "", "fnclex","fninit","", "", "", "" +}; + +static char * db_Esce3[] = { + "", "fcompp","", "", "", "", "", "" +}; + +static char * db_Escf4[] = { + "fnstsw","", "", "", "", "", "", "" +}; + +static struct finst db_Esc8[] = { +/*0*/ { "fadd", SNGL, op2(STI,ST), 0 }, +/*1*/ { "fmul", SNGL, op2(STI,ST), 0 }, +/*2*/ { "fcom", SNGL, op2(STI,ST), 0 }, +/*3*/ { "fcomp", SNGL, op2(STI,ST), 0 }, +/*4*/ { "fsub", SNGL, op2(STI,ST), 0 }, +/*5*/ { "fsubr", SNGL, op2(STI,ST), 0 }, +/*6*/ { "fdiv", SNGL, op2(STI,ST), 0 }, +/*7*/ { "fdivr", SNGL, op2(STI,ST), 0 }, +}; + +static struct finst db_Esc9[] = { +/*0*/ { "fld", SNGL, op1(STI), 0 }, +/*1*/ { "", NONE, op1(STI), "fxch" }, +/*2*/ { "fst", SNGL, op1(X), (char *)db_Esc92 }, +/*3*/ { "fstp", SNGL, op1(X), (char *)db_Esc93 }, +/*4*/ { "fldenv", NONE, op1(X), (char *)db_Esc94 }, +/*5*/ { "fldcw", NONE, op1(X), (char *)db_Esc95 }, +/*6*/ { "fnstenv",NONE, op1(X), (char *)db_Esc96 }, +/*7*/ { "fnstcw", NONE, op1(X), (char *)db_Esc97 }, +}; + +static struct finst db_Esca[] = { +/*0*/ { "fiadd", WORD, 0, 0 }, +/*1*/ { "fimul", WORD, 0, 0 }, +/*2*/ { "ficom", WORD, 0, 0 }, +/*3*/ { "ficomp", WORD, 0, 0 }, +/*4*/ { "fisub", WORD, op1(X), (char *)db_Esca4 }, +/*5*/ { "fisubr", WORD, 0, 0 }, +/*6*/ { "fidiv", WORD, 0, 0 }, +/*7*/ { "fidivr", WORD, 0, 0 } +}; + +static struct finst db_Escb[] = { +/*0*/ { "fild", WORD, 0, 0 }, +/*1*/ { "", NONE, 0, 0 }, +/*2*/ { "fist", WORD, 0, 0 }, +/*3*/ { "fistp", WORD, 0, 0 }, +/*4*/ { "", WORD, op1(X), (char *)db_Escb4 }, +/*5*/ { "fld", EXTR, 0, 0 }, +/*6*/ { "", WORD, 0, 0 }, +/*7*/ { "fstp", EXTR, 0, 0 }, +}; + +static struct finst db_Escc[] = { +/*0*/ { "fadd", DBLR, op2(ST,STI), 0 }, +/*1*/ { "fmul", DBLR, op2(ST,STI), 0 }, +/*2*/ { "fcom", DBLR, op2(ST,STI), 0 }, +/*3*/ { "fcomp", DBLR, op2(ST,STI), 0 }, +/*4*/ { "fsub", DBLR, op2(ST,STI), "fsubr" }, +/*5*/ { "fsubr", DBLR, op2(ST,STI), "fsub" }, +/*6*/ { "fdiv", DBLR, op2(ST,STI), "fdivr" }, +/*7*/ { "fdivr", DBLR, op2(ST,STI), "fdiv" }, +}; + +static struct finst db_Escd[] = { +/*0*/ { "fld", DBLR, op1(STI), "ffree" }, +/*1*/ { "", NONE, 0, 0 }, +/*2*/ { "fst", DBLR, op1(STI), 0 }, +/*3*/ { "fstp", DBLR, op1(STI), 0 }, +/*4*/ { "frstor", NONE, op1(STI), "fucom" }, +/*5*/ { "", NONE, op1(STI), "fucomp" }, +/*6*/ { "fnsave", NONE, 0, 0 }, +/*7*/ { "fnstsw", NONE, 0, 0 }, +}; + +static struct finst db_Esce[] = { +/*0*/ { "fiadd", LONG, op2(ST,STI), "faddp" }, +/*1*/ { "fimul", LONG, op2(ST,STI), "fmulp" }, +/*2*/ { "ficom", LONG, 0, 0 }, +/*3*/ { "ficomp", LONG, op1(X), (char *)db_Esce3 }, +/*4*/ { "fisub", LONG, op2(ST,STI), "fsubrp" }, +/*5*/ { "fisubr", LONG, op2(ST,STI), "fsubp" }, +/*6*/ { "fidiv", LONG, op2(ST,STI), "fdivrp" }, +/*7*/ { "fidivr", LONG, op2(ST,STI), "fdivp" }, +}; + +static struct finst db_Escf[] = { +/*0*/ { "fild", LONG, 0, 0 }, +/*1*/ { "", LONG, 0, 0 }, +/*2*/ { "fist", LONG, 0, 0 }, +/*3*/ { "fistp", LONG, 0, 0 }, +/*4*/ { "fbld", NONE, op1(XA), (char *)db_Escf4 }, +/*5*/ { "fld", QUAD, 0, 0 }, +/*6*/ { "fbstp", NONE, 0, 0 }, +/*7*/ { "fstp", QUAD, 0, 0 }, +}; + +static struct finst *db_Esc_inst[] = { + db_Esc8, db_Esc9, db_Esca, db_Escb, + db_Escc, db_Escd, db_Esce, db_Escf +}; + +static char * db_Grp1[] = { + "add", + "or", + "adc", + "sbb", + "and", + "sub", + "xor", + "cmp" +}; + +static char * db_Grp2[] = { + "rol", + "ror", + "rcl", + "rcr", + "shl", + "shr", + "shl", + "sar" +}; + +static struct inst db_Grp3[] = { + { "test", TRUE, NONE, op2(I,E), 0 }, + { "test", TRUE, NONE, op2(I,E), 0 }, + { "not", TRUE, NONE, op1(E), 0 }, + { "neg", TRUE, NONE, op1(E), 0 }, + { "mul", TRUE, NONE, op2(E,A), 0 }, + { "imul", TRUE, NONE, op2(E,A), 0 }, + { "div", TRUE, NONE, op2(E,A), 0 }, + { "idiv", TRUE, NONE, op2(E,A), 0 }, +}; + +static struct inst db_Grp4[] = { + { "inc", TRUE, BYTE, op1(E), 0 }, + { "dec", TRUE, BYTE, op1(E), 0 }, + { "", TRUE, NONE, 0, 0 }, + { "", TRUE, NONE, 0, 0 }, + { "", TRUE, NONE, 0, 0 }, + { "", TRUE, NONE, 0, 0 }, + { "", TRUE, NONE, 0, 0 }, + { "", TRUE, NONE, 0, 0 } +}; + +static struct inst db_Grp5[] = { + { "inc", TRUE, LONG, op1(E), 0 }, + { "dec", TRUE, LONG, op1(E), 0 }, + { "call", TRUE, NONE, op1(Eind),0 }, + { "lcall", TRUE, NONE, op1(Eind),0 }, + { "jmp", TRUE, NONE, op1(Eind),0 }, + { "ljmp", TRUE, NONE, op1(Eind),0 }, + { "push", TRUE, LONG, op1(E), 0 }, + { "", TRUE, NONE, 0, 0 } +}; + +static struct inst db_inst_table[256] = { +/*00*/ { "add", TRUE, BYTE, op2(R, E), 0 }, +/*01*/ { "add", TRUE, LONG, op2(R, E), 0 }, +/*02*/ { "add", TRUE, BYTE, op2(E, R), 0 }, +/*03*/ { "add", TRUE, LONG, op2(E, R), 0 }, +/*04*/ { "add", FALSE, BYTE, op2(Is, A), 0 }, +/*05*/ { "add", FALSE, LONG, op2(Is, A), 0 }, +/*06*/ { "push", FALSE, NONE, op1(Si), 0 }, +/*07*/ { "pop", FALSE, NONE, op1(Si), 0 }, + +/*08*/ { "or", TRUE, BYTE, op2(R, E), 0 }, +/*09*/ { "or", TRUE, LONG, op2(R, E), 0 }, +/*0a*/ { "or", TRUE, BYTE, op2(E, R), 0 }, +/*0b*/ { "or", TRUE, LONG, op2(E, R), 0 }, +/*0c*/ { "or", FALSE, BYTE, op2(I, A), 0 }, +/*0d*/ { "or", FALSE, LONG, op2(I, A), 0 }, +/*0e*/ { "push", FALSE, NONE, op1(Si), 0 }, +/*0f*/ { "", FALSE, NONE, 0, 0 }, + +/*10*/ { "adc", TRUE, BYTE, op2(R, E), 0 }, +/*11*/ { "adc", TRUE, LONG, op2(R, E), 0 }, +/*12*/ { "adc", TRUE, BYTE, op2(E, R), 0 }, +/*13*/ { "adc", TRUE, LONG, op2(E, R), 0 }, +/*14*/ { "adc", FALSE, BYTE, op2(Is, A), 0 }, +/*15*/ { "adc", FALSE, LONG, op2(Is, A), 0 }, +/*16*/ { "push", FALSE, NONE, op1(Si), 0 }, +/*17*/ { "pop", FALSE, NONE, op1(Si), 0 }, + +/*18*/ { "sbb", TRUE, BYTE, op2(R, E), 0 }, +/*19*/ { "sbb", TRUE, LONG, op2(R, E), 0 }, +/*1a*/ { "sbb", TRUE, BYTE, op2(E, R), 0 }, +/*1b*/ { "sbb", TRUE, LONG, op2(E, R), 0 }, +/*1c*/ { "sbb", FALSE, BYTE, op2(Is, A), 0 }, +/*1d*/ { "sbb", FALSE, LONG, op2(Is, A), 0 }, +/*1e*/ { "push", FALSE, NONE, op1(Si), 0 }, +/*1f*/ { "pop", FALSE, NONE, op1(Si), 0 }, + +/*20*/ { "and", TRUE, BYTE, op2(R, E), 0 }, +/*21*/ { "and", TRUE, LONG, op2(R, E), 0 }, +/*22*/ { "and", TRUE, BYTE, op2(E, R), 0 }, +/*23*/ { "and", TRUE, LONG, op2(E, R), 0 }, +/*24*/ { "and", FALSE, BYTE, op2(I, A), 0 }, +/*25*/ { "and", FALSE, LONG, op2(I, A), 0 }, +/*26*/ { "", FALSE, NONE, 0, 0 }, +/*27*/ { "aaa", FALSE, NONE, 0, 0 }, + +/*28*/ { "sub", TRUE, BYTE, op2(R, E), 0 }, +/*29*/ { "sub", TRUE, LONG, op2(R, E), 0 }, +/*2a*/ { "sub", TRUE, BYTE, op2(E, R), 0 }, +/*2b*/ { "sub", TRUE, LONG, op2(E, R), 0 }, +/*2c*/ { "sub", FALSE, BYTE, op2(Is, A), 0 }, +/*2d*/ { "sub", FALSE, LONG, op2(Is, A), 0 }, +/*2e*/ { "", FALSE, NONE, 0, 0 }, +/*2f*/ { "das", FALSE, NONE, 0, 0 }, + +/*30*/ { "xor", TRUE, BYTE, op2(R, E), 0 }, +/*31*/ { "xor", TRUE, LONG, op2(R, E), 0 }, +/*32*/ { "xor", TRUE, BYTE, op2(E, R), 0 }, +/*33*/ { "xor", TRUE, LONG, op2(E, R), 0 }, +/*34*/ { "xor", FALSE, BYTE, op2(I, A), 0 }, +/*35*/ { "xor", FALSE, LONG, op2(I, A), 0 }, +/*36*/ { "", FALSE, NONE, 0, 0 }, +/*37*/ { "daa", FALSE, NONE, 0, 0 }, + +/*38*/ { "cmp", TRUE, BYTE, op2(R, E), 0 }, +/*39*/ { "cmp", TRUE, LONG, op2(R, E), 0 }, +/*3a*/ { "cmp", TRUE, BYTE, op2(E, R), 0 }, +/*3b*/ { "cmp", TRUE, LONG, op2(E, R), 0 }, +/*3c*/ { "cmp", FALSE, BYTE, op2(Is, A), 0 }, +/*3d*/ { "cmp", FALSE, LONG, op2(Is, A), 0 }, +/*3e*/ { "", FALSE, NONE, 0, 0 }, +/*3f*/ { "aas", FALSE, NONE, 0, 0 }, + +/*40*/ { "inc", FALSE, LONG, op1(Ri), 0 }, +/*41*/ { "inc", FALSE, LONG, op1(Ri), 0 }, +/*42*/ { "inc", FALSE, LONG, op1(Ri), 0 }, +/*43*/ { "inc", FALSE, LONG, op1(Ri), 0 }, +/*44*/ { "inc", FALSE, LONG, op1(Ri), 0 }, +/*45*/ { "inc", FALSE, LONG, op1(Ri), 0 }, +/*46*/ { "inc", FALSE, LONG, op1(Ri), 0 }, +/*47*/ { "inc", FALSE, LONG, op1(Ri), 0 }, + +/*48*/ { "dec", FALSE, LONG, op1(Ri), 0 }, +/*49*/ { "dec", FALSE, LONG, op1(Ri), 0 }, +/*4a*/ { "dec", FALSE, LONG, op1(Ri), 0 }, +/*4b*/ { "dec", FALSE, LONG, op1(Ri), 0 }, +/*4c*/ { "dec", FALSE, LONG, op1(Ri), 0 }, +/*4d*/ { "dec", FALSE, LONG, op1(Ri), 0 }, +/*4e*/ { "dec", FALSE, LONG, op1(Ri), 0 }, +/*4f*/ { "dec", FALSE, LONG, op1(Ri), 0 }, + +/*50*/ { "push", FALSE, LONG, op1(Ri), 0 }, +/*51*/ { "push", FALSE, LONG, op1(Ri), 0 }, +/*52*/ { "push", FALSE, LONG, op1(Ri), 0 }, +/*53*/ { "push", FALSE, LONG, op1(Ri), 0 }, +/*54*/ { "push", FALSE, LONG, op1(Ri), 0 }, +/*55*/ { "push", FALSE, LONG, op1(Ri), 0 }, +/*56*/ { "push", FALSE, LONG, op1(Ri), 0 }, +/*57*/ { "push", FALSE, LONG, op1(Ri), 0 }, + +/*58*/ { "pop", FALSE, LONG, op1(Ri), 0 }, +/*59*/ { "pop", FALSE, LONG, op1(Ri), 0 }, +/*5a*/ { "pop", FALSE, LONG, op1(Ri), 0 }, +/*5b*/ { "pop", FALSE, LONG, op1(Ri), 0 }, +/*5c*/ { "pop", FALSE, LONG, op1(Ri), 0 }, +/*5d*/ { "pop", FALSE, LONG, op1(Ri), 0 }, +/*5e*/ { "pop", FALSE, LONG, op1(Ri), 0 }, +/*5f*/ { "pop", FALSE, LONG, op1(Ri), 0 }, + +/*60*/ { "pusha", FALSE, LONG, 0, 0 }, +/*61*/ { "popa", FALSE, LONG, 0, 0 }, +/*62*/ { "bound", TRUE, LONG, op2(E, R), 0 }, +/*63*/ { "arpl", TRUE, NONE, op2(Ew,Rw), 0 }, + +/*64*/ { "", FALSE, NONE, 0, 0 }, +/*65*/ { "", FALSE, NONE, 0, 0 }, +/*66*/ { "", FALSE, NONE, 0, 0 }, +/*67*/ { "", FALSE, NONE, 0, 0 }, + +/*68*/ { "push", FALSE, LONG, op1(I), 0 }, +/*69*/ { "imul", TRUE, LONG, op3(I,E,R), 0 }, +/*6a*/ { "push", FALSE, LONG, op1(Ib), 0 }, +/*6b*/ { "imul", TRUE, LONG, op3(Ibs,E,R),0 }, +/*6c*/ { "ins", FALSE, BYTE, op2(DX, DI), 0 }, +/*6d*/ { "ins", FALSE, LONG, op2(DX, DI), 0 }, +/*6e*/ { "outs", FALSE, BYTE, op2(SI, DX), 0 }, +/*6f*/ { "outs", FALSE, LONG, op2(SI, DX), 0 }, + +/*70*/ { "jo", FALSE, NONE, op1(Db), 0 }, +/*71*/ { "jno", FALSE, NONE, op1(Db), 0 }, +/*72*/ { "jb", FALSE, NONE, op1(Db), 0 }, +/*73*/ { "jnb", FALSE, NONE, op1(Db), 0 }, +/*74*/ { "jz", FALSE, NONE, op1(Db), 0 }, +/*75*/ { "jnz", FALSE, NONE, op1(Db), 0 }, +/*76*/ { "jbe", FALSE, NONE, op1(Db), 0 }, +/*77*/ { "jnbe", FALSE, NONE, op1(Db), 0 }, + +/*78*/ { "js", FALSE, NONE, op1(Db), 0 }, +/*79*/ { "jns", FALSE, NONE, op1(Db), 0 }, +/*7a*/ { "jp", FALSE, NONE, op1(Db), 0 }, +/*7b*/ { "jnp", FALSE, NONE, op1(Db), 0 }, +/*7c*/ { "jl", FALSE, NONE, op1(Db), 0 }, +/*7d*/ { "jnl", FALSE, NONE, op1(Db), 0 }, +/*7e*/ { "jle", FALSE, NONE, op1(Db), 0 }, +/*7f*/ { "jnle", FALSE, NONE, op1(Db), 0 }, + +/*80*/ { "", TRUE, BYTE, op2(I, E), (char *)db_Grp1 }, +/*81*/ { "", TRUE, LONG, op2(I, E), (char *)db_Grp1 }, +/*82*/ { "", TRUE, BYTE, op2(Is,E), (char *)db_Grp1 }, +/*83*/ { "", TRUE, LONG, op2(Ibs,E), (char *)db_Grp1 }, +/*84*/ { "test", TRUE, BYTE, op2(R, E), 0 }, +/*85*/ { "test", TRUE, LONG, op2(R, E), 0 }, +/*86*/ { "xchg", TRUE, BYTE, op2(R, E), 0 }, +/*87*/ { "xchg", TRUE, LONG, op2(R, E), 0 }, + +/*88*/ { "mov", TRUE, BYTE, op2(R, E), 0 }, +/*89*/ { "mov", TRUE, LONG, op2(R, E), 0 }, +/*8a*/ { "mov", TRUE, BYTE, op2(E, R), 0 }, +/*8b*/ { "mov", TRUE, LONG, op2(E, R), 0 }, +/*8c*/ { "mov", TRUE, NONE, op2(S, Ew), 0 }, +/*8d*/ { "lea", TRUE, LONG, op2(E, R), 0 }, +/*8e*/ { "mov", TRUE, NONE, op2(Ew, S), 0 }, +/*8f*/ { "pop", TRUE, LONG, op1(E), 0 }, + +/*90*/ { "nop", FALSE, NONE, 0, 0 }, +/*91*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, +/*92*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, +/*93*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, +/*94*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, +/*95*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, +/*96*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, +/*97*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 }, + +/*98*/ { "cbw", FALSE, SDEP, 0, "cwde" }, /* cbw/cwde */ +/*99*/ { "cwd", FALSE, SDEP, 0, "cdq" }, /* cwd/cdq */ +/*9a*/ { "lcall", FALSE, NONE, op1(OS), 0 }, +/*9b*/ { "wait", FALSE, NONE, 0, 0 }, +/*9c*/ { "pushf", FALSE, LONG, 0, 0 }, +/*9d*/ { "popf", FALSE, LONG, 0, 0 }, +/*9e*/ { "sahf", FALSE, NONE, 0, 0 }, +/*9f*/ { "lahf", FALSE, NONE, 0, 0 }, + +/*a0*/ { "mov", FALSE, BYTE, op2(O, A), 0 }, +/*a1*/ { "mov", FALSE, LONG, op2(O, A), 0 }, +/*a2*/ { "mov", FALSE, BYTE, op2(A, O), 0 }, +/*a3*/ { "mov", FALSE, LONG, op2(A, O), 0 }, +/*a4*/ { "movs", FALSE, BYTE, op2(SI,DI), 0 }, +/*a5*/ { "movs", FALSE, LONG, op2(SI,DI), 0 }, +/*a6*/ { "cmps", FALSE, BYTE, op2(SI,DI), 0 }, +/*a7*/ { "cmps", FALSE, LONG, op2(SI,DI), 0 }, + +/*a8*/ { "test", FALSE, BYTE, op2(I, A), 0 }, +/*a9*/ { "test", FALSE, LONG, op2(I, A), 0 }, +/*aa*/ { "stos", FALSE, BYTE, op1(DI), 0 }, +/*ab*/ { "stos", FALSE, LONG, op1(DI), 0 }, +/*ac*/ { "lods", FALSE, BYTE, op1(SI), 0 }, +/*ad*/ { "lods", FALSE, LONG, op1(SI), 0 }, +/*ae*/ { "scas", FALSE, BYTE, op1(SI), 0 }, +/*af*/ { "scas", FALSE, LONG, op1(SI), 0 }, + +/*b0*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, +/*b1*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, +/*b2*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, +/*b3*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, +/*b4*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, +/*b5*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, +/*b6*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, +/*b7*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 }, + +/*b8*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, +/*b9*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, +/*ba*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, +/*bb*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, +/*bc*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, +/*bd*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, +/*be*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, +/*bf*/ { "mov", FALSE, LONG, op2(I, Ri), 0 }, + +/*c0*/ { "", TRUE, BYTE, op2(Ib, E), (char *)db_Grp2 }, +/*c1*/ { "", TRUE, LONG, op2(Ib, E), (char *)db_Grp2 }, +/*c2*/ { "ret", FALSE, NONE, op1(Iw), 0 }, +/*c3*/ { "ret", FALSE, NONE, 0, 0 }, +/*c4*/ { "les", TRUE, LONG, op2(E, R), 0 }, +/*c5*/ { "lds", TRUE, LONG, op2(E, R), 0 }, +/*c6*/ { "mov", TRUE, BYTE, op2(I, E), 0 }, +/*c7*/ { "mov", TRUE, LONG, op2(I, E), 0 }, + +/*c8*/ { "enter", FALSE, NONE, op2(Ib, Iw), 0 }, +/*c9*/ { "leave", FALSE, NONE, 0, 0 }, +/*ca*/ { "lret", FALSE, NONE, op1(Iw), 0 }, +/*cb*/ { "lret", FALSE, NONE, 0, 0 }, +/*cc*/ { "int", FALSE, NONE, op1(o3), 0 }, +/*cd*/ { "int", FALSE, NONE, op1(Ib), 0 }, +/*ce*/ { "into", FALSE, NONE, 0, 0 }, +/*cf*/ { "iret", FALSE, NONE, 0, 0 }, + +/*d0*/ { "", TRUE, BYTE, op2(o1, E), (char *)db_Grp2 }, +/*d1*/ { "", TRUE, LONG, op2(o1, E), (char *)db_Grp2 }, +/*d2*/ { "", TRUE, BYTE, op2(CL, E), (char *)db_Grp2 }, +/*d3*/ { "", TRUE, LONG, op2(CL, E), (char *)db_Grp2 }, +/*d4*/ { "aam", TRUE, NONE, 0, 0 }, +/*d5*/ { "aad", TRUE, NONE, 0, 0 }, +/*d6*/ { "", FALSE, NONE, 0, 0 }, +/*d7*/ { "xlat", FALSE, BYTE, op1(BX), 0 }, + +/*d8*/ { "", TRUE, NONE, 0, (char *)db_Esc8 }, +/*d9*/ { "", TRUE, NONE, 0, (char *)db_Esc9 }, +/*da*/ { "", TRUE, NONE, 0, (char *)db_Esca }, +/*db*/ { "", TRUE, NONE, 0, (char *)db_Escb }, +/*dc*/ { "", TRUE, NONE, 0, (char *)db_Escc }, +/*dd*/ { "", TRUE, NONE, 0, (char *)db_Escd }, +/*de*/ { "", TRUE, NONE, 0, (char *)db_Esce }, +/*df*/ { "", TRUE, NONE, 0, (char *)db_Escf }, + +/*e0*/ { "loopne",FALSE, NONE, op1(Db), 0 }, +/*e1*/ { "loope", FALSE, NONE, op1(Db), 0 }, +/*e2*/ { "loop", FALSE, NONE, op1(Db), 0 }, +/*e3*/ { "jcxz", FALSE, SDEP, op1(Db), "jecxz" }, +/*e4*/ { "in", FALSE, BYTE, op2(Ib, A), 0 }, +/*e5*/ { "in", FALSE, LONG, op2(Ib, A) , 0 }, +/*e6*/ { "out", FALSE, BYTE, op2(A, Ib), 0 }, +/*e7*/ { "out", FALSE, LONG, op2(A, Ib) , 0 }, + +/*e8*/ { "call", FALSE, NONE, op1(Dl), 0 }, +/*e9*/ { "jmp", FALSE, NONE, op1(Dl), 0 }, +/*ea*/ { "ljmp", FALSE, NONE, op1(OS), 0 }, +/*eb*/ { "jmp", FALSE, NONE, op1(Db), 0 }, +/*ec*/ { "in", FALSE, BYTE, op2(DX, A), 0 }, +/*ed*/ { "in", FALSE, LONG, op2(DX, A) , 0 }, +/*ee*/ { "out", FALSE, BYTE, op2(A, DX), 0 }, +/*ef*/ { "out", FALSE, LONG, op2(A, DX) , 0 }, + +/*f0*/ { "", FALSE, NONE, 0, 0 }, +/*f1*/ { "", FALSE, NONE, 0, 0 }, +/*f2*/ { "", FALSE, NONE, 0, 0 }, +/*f3*/ { "", FALSE, NONE, 0, 0 }, +/*f4*/ { "hlt", FALSE, NONE, 0, 0 }, +/*f5*/ { "cmc", FALSE, NONE, 0, 0 }, +/*f6*/ { "", TRUE, BYTE, 0, (char *)db_Grp3 }, +/*f7*/ { "", TRUE, LONG, 0, (char *)db_Grp3 }, + +/*f8*/ { "clc", FALSE, NONE, 0, 0 }, +/*f9*/ { "stc", FALSE, NONE, 0, 0 }, +/*fa*/ { "cli", FALSE, NONE, 0, 0 }, +/*fb*/ { "sti", FALSE, NONE, 0, 0 }, +/*fc*/ { "cld", FALSE, NONE, 0, 0 }, +/*fd*/ { "std", FALSE, NONE, 0, 0 }, +/*fe*/ { "", TRUE, NONE, 0, (char *)db_Grp4 }, +/*ff*/ { "", TRUE, NONE, 0, (char *)db_Grp5 }, +}; + +static struct inst db_bad_inst = + { "???", FALSE, NONE, 0, 0 } +; + +#define f_mod(byte) ((byte)>>6) +#define f_reg(byte) (((byte)>>3)&0x7) +#define f_rm(byte) ((byte)&0x7) + +#define sib_ss(byte) ((byte)>>6) +#define sib_index(byte) (((byte)>>3)&0x7) +#define sib_base(byte) ((byte)&0x7) + +struct i_addr { + int is_reg; /* if reg, reg number is in 'disp' */ + int disp; + char * base; + char * index; + int ss; +}; + +static char * db_index_reg_16[8] = { + "%bx,%si", + "%bx,%di", + "%bp,%si", + "%bp,%di", + "%si", + "%di", + "%bp", + "%bx" +}; + +static char * db_reg[3][8] = { + { "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh" }, + { "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di" }, + { "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi" } +}; + +static char * db_seg_reg[8] = { + "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", "" +}; + +/* + * lengths for size attributes + */ +static int db_lengths[] = { + 1, /* BYTE */ + 2, /* WORD */ + 4, /* LONG */ + 8, /* QUAD */ + 4, /* SNGL */ + 8, /* DBLR */ + 10, /* EXTR */ +}; + +unsigned int db_get_task_value(unsigned int loc, int size, int is_signed) +{ + unsigned int result; + switch(size) + { + case 4: + if (is_signed) + result = (unsigned int) *((int *) loc); + else + result = (unsigned int) *((unsigned int *) loc); + break; + case 2: + if (is_signed) + result = (unsigned int) *((short int *) loc); + else + result = *((unsigned short int *) loc); + break; + case 1: + if (is_signed) + result = (unsigned int) *((char *) loc); + else + result = *((unsigned char *) loc); + break; + default: + fprintf(stderr, "Illegal size specified\n"); + result = 0; + break; + } + return result; +} + +#define get_value_inc(result, loc, size, is_signed) \ + result = db_get_task_value((loc), (size), (is_signed)); \ + (loc) += (size); + +/* + * Read address at location and return updated location. + */ +db_addr_t +db_read_address(loc, short_addr, regmodrm, addrp) + db_addr_t loc; + int short_addr; + int regmodrm; + struct i_addr *addrp; /* out */ +{ + int mod, rm, sib, index, disp; + + mod = f_mod(regmodrm); + rm = f_rm(regmodrm); + + if (mod == 3) { + addrp->is_reg = TRUE; + addrp->disp = rm; + return (loc); + } + addrp->is_reg = FALSE; + addrp->index = 0; + + if (short_addr) { + addrp->index = 0; + addrp->ss = 0; + switch (mod) { + case 0: + if (rm == 6) { + get_value_inc(disp, loc, 2, TRUE); + addrp->disp = disp; + addrp->base = 0; + } + else { + addrp->disp = 0; + addrp->base = db_index_reg_16[rm]; + } + break; + case 1: + get_value_inc(disp, loc, 1, TRUE); + addrp->disp = disp; + addrp->base = db_index_reg_16[rm]; + break; + case 2: + get_value_inc(disp, loc, 2, TRUE); + addrp->disp = disp; + addrp->base = db_index_reg_16[rm]; + break; + } + } + else { + if (mod != 3 && rm == 4) { + get_value_inc(sib, loc, 1, FALSE); + rm = sib_base(sib); + index = sib_index(sib); + if (index != 4) + addrp->index = db_reg[LONG][index]; + addrp->ss = sib_ss(sib); + } + + switch (mod) { + case 0: + if (rm == 5) { + get_value_inc(addrp->disp, loc, 4, FALSE); + addrp->base = 0; + } + else { + addrp->disp = 0; + addrp->base = db_reg[LONG][rm]; + } + break; + + case 1: + get_value_inc(disp, loc, 1, TRUE); + addrp->disp = disp; + addrp->base = db_reg[LONG][rm]; + break; + + case 2: + get_value_inc(disp, loc, 4, FALSE); + addrp->disp = disp; + addrp->base = db_reg[LONG][rm]; + break; + } + } + return (loc); +} + +void +db_print_address(seg, size, addrp) + char * seg; + int size; + struct i_addr *addrp; +{ + if (addrp->is_reg) { + fprintf(stderr,"%s", db_reg[size][addrp->disp]); + return; + } + + if (seg) { + fprintf(stderr,"%s:", seg); + } + + if (addrp->base != 0 || addrp->index != 0) { + fprintf(stderr,"0x%x", addrp->disp); + fprintf(stderr,"("); + if (addrp->base) + fprintf(stderr,"%s", addrp->base); + if (addrp->index) + fprintf(stderr,",%s,%d", addrp->index, 1<ss); + fprintf(stderr,")"); + } else + db_task_printsym((db_addr_t)addrp->disp); +} + +/* + * Disassemble floating-point ("escape") instruction + * and return updated location. + */ +db_addr_t +db_disasm_esc(loc, inst, short_addr, size, seg) + db_addr_t loc; + int inst; + int short_addr; + int size; + char * seg; +{ + int regmodrm; + struct finst *fp; + int mod; + struct i_addr address; + char * name; + + get_value_inc(regmodrm, loc, 1, FALSE); + fp = &db_Esc_inst[inst - 0xd8][f_reg(regmodrm)]; + mod = f_mod(regmodrm); + if (mod != 3) { + /* + * Normal address modes. + */ + loc = db_read_address(loc, short_addr, regmodrm, &address); + fprintf(stderr,fp->f_name); + switch(fp->f_size) { + case SNGL: + fprintf(stderr,"s"); + break; + case DBLR: + fprintf(stderr,"l"); + break; + case EXTR: + fprintf(stderr,"t"); + break; + case WORD: + fprintf(stderr,"s"); + break; + case LONG: + fprintf(stderr,"l"); + break; + case QUAD: + fprintf(stderr,"q"); + break; + default: + break; + } + fprintf(stderr,"\t"); + db_print_address(seg, BYTE, &address); + } + else { + /* + * 'reg-reg' - special formats + */ + switch (fp->f_rrmode) { + case op2(ST,STI): + name = (fp->f_rrname) ? fp->f_rrname : fp->f_name; + fprintf(stderr,"%s\t%%st,%%st(%d)",name,f_rm(regmodrm)); + break; + case op2(STI,ST): + name = (fp->f_rrname) ? fp->f_rrname : fp->f_name; + fprintf(stderr,"%s\t%%st(%d),%%st",name, f_rm(regmodrm)); + break; + case op1(STI): + name = (fp->f_rrname) ? fp->f_rrname : fp->f_name; + fprintf(stderr,"%s\t%%st(%d)",name, f_rm(regmodrm)); + break; + case op1(X): + fprintf(stderr,"%s", ((char **)fp->f_rrname)[f_rm(regmodrm)]); + break; + case op1(XA): + fprintf(stderr,"%s\t%%ax", + ((char **)fp->f_rrname)[f_rm(regmodrm)]); + break; + default: + fprintf(stderr,""); + break; + } + } + + return (loc); +} + +/* + * Disassemble instruction at 'loc'. 'altfmt' specifies an + * (optional) alternate format. Return address of start of + * next instruction. + */ +db_addr_t +db_disasm(loc, altfmt, flag16) + db_addr_t loc; + boolean_t altfmt; + boolean_t flag16; +{ + int inst; + int size; + int short_addr; + char * seg; + struct inst * ip; + char * i_name; + int i_size; + int i_mode; + int regmodrm; + boolean_t first; + int displ; + int prefix; + int imm; + int imm2; + int len; + struct i_addr address; + + db_disasm_16 = flag16; + + get_value_inc(inst, loc, 1, FALSE); + + if (db_disasm_16) { + short_addr = TRUE; + size = WORD; + } + else { + short_addr = FALSE; + size = LONG; + } + seg = 0; + + /* + * Get prefixes + */ + prefix = TRUE; + do { + switch (inst) { + case 0x66: /* data16 */ + if (size == LONG) + size = WORD; + else + size = LONG; + break; + case 0x67: + short_addr = !short_addr; + break; + case 0x26: + seg = "%es"; + break; + case 0x36: + seg = "%ss"; + break; + case 0x2e: + seg = "%cs"; + break; + case 0x3e: + seg = "%ds"; + break; + case 0x64: + seg = "%fs"; + break; + case 0x65: + seg = "%gs"; + break; + case 0xf0: + fprintf(stderr,"lock "); + break; + case 0xf2: + fprintf(stderr,"repne "); + break; + case 0xf3: + fprintf(stderr,"repe "); /* XXX repe VS rep */ + break; + default: + prefix = FALSE; + break; + } + if (prefix) { + get_value_inc(inst, loc, 1, FALSE); + } + } while (prefix); + + if (inst >= 0xd8 && inst <= 0xdf) { + loc = db_disasm_esc(loc, inst, short_addr, size, seg); + fprintf(stderr,"\n"); + return (loc); + } + + if (inst == 0x0f) { + get_value_inc(inst, loc, 1, FALSE); + ip = db_inst_0f[inst>>4]; + if (ip == 0) { + ip = &db_bad_inst; + } + else { + ip = &ip[inst&0xf]; + } + } + else + ip = &db_inst_table[inst]; + + if (ip->i_has_modrm) { + get_value_inc(regmodrm, loc, 1, FALSE); + loc = db_read_address(loc, short_addr, regmodrm, &address); + } + + i_name = ip->i_name; + i_size = ip->i_size; + i_mode = ip->i_mode; + + if (ip->i_extra == (char *)db_Grp1 || + ip->i_extra == (char *)db_Grp2 || + ip->i_extra == (char *)db_Grp6 || + ip->i_extra == (char *)db_Grp7 || + ip->i_extra == (char *)db_Grp8) { + i_name = ((char **)ip->i_extra)[f_reg(regmodrm)]; + } + else if (ip->i_extra == (char *)db_Grp3) { + ip = (struct inst *)ip->i_extra; + ip = &ip[f_reg(regmodrm)]; + i_name = ip->i_name; + i_mode = ip->i_mode; + } + else if (ip->i_extra == (char *)db_Grp4 || + ip->i_extra == (char *)db_Grp5) { + ip = (struct inst *)ip->i_extra; + ip = &ip[f_reg(regmodrm)]; + i_name = ip->i_name; + i_mode = ip->i_mode; + i_size = ip->i_size; + } + + if (i_size == SDEP) { + if (size == WORD) + fprintf(stderr,i_name); + else + fprintf(stderr,ip->i_extra); + } + else { + fprintf(stderr,i_name); + if (i_size != NONE) { + if (i_size == BYTE) { + fprintf(stderr,"b"); + size = BYTE; + } + else if (i_size == WORD) { + fprintf(stderr,"w"); + size = WORD; + } + else if (size == WORD) + fprintf(stderr,"w"); + else + fprintf(stderr,"l"); + } + } + fprintf(stderr,"\t"); + for (first = TRUE; + i_mode != 0; + i_mode >>= 8, first = FALSE) + { + if (!first) + fprintf(stderr,","); + + switch (i_mode & 0xFF) { + + case E: + db_print_address(seg, size, &address); + break; + + case Eind: + fprintf(stderr,"*"); + db_print_address(seg, size, &address); + break; + + case Ew: + db_print_address(seg, WORD, &address); + break; + + case Eb: + db_print_address(seg, BYTE, &address); + break; + + case R: + fprintf(stderr,"%s", db_reg[size][f_reg(regmodrm)]); + break; + + case Rw: + fprintf(stderr,"%s", db_reg[WORD][f_reg(regmodrm)]); + break; + + case Ri: + fprintf(stderr,"%s", db_reg[size][f_rm(inst)]); + break; + + case S: + fprintf(stderr,"%s", db_seg_reg[f_reg(regmodrm)]); + break; + + case Si: + fprintf(stderr,"%s", db_seg_reg[f_reg(inst)]); + break; + + case A: + fprintf(stderr,"%s", db_reg[size][0]); /* acc */ + break; + + case BX: + if (seg) + fprintf(stderr,"%s:", seg); + fprintf(stderr,"(%s)", short_addr ? "%bx" : "%ebx"); + break; + + case CL: + fprintf(stderr,"%%cl"); + break; + + case DX: + fprintf(stderr,"%%dx"); + break; + + case SI: + if (seg) + fprintf(stderr,"%s:", seg); + fprintf(stderr,"(%s)", short_addr ? "%si" : "%esi"); + break; + + case DI: + fprintf(stderr,"%%es:(%s)", short_addr ? "%di" : "%edi"); + break; + + case CR: + fprintf(stderr,"%%cr%d", f_reg(regmodrm)); + break; + + case DR: + fprintf(stderr,"%%dr%d", f_reg(regmodrm)); + break; + + case TR: + fprintf(stderr,"%%tr%d", f_reg(regmodrm)); + break; + + case I: + len = db_lengths[size]; + get_value_inc(imm, loc, len, FALSE);/* unsigned */ + fprintf(stderr,"$0x%x", imm); + break; + + case Is: + len = db_lengths[size]; + get_value_inc(imm, loc, len, TRUE); /* signed */ + fprintf(stderr,"$%d", imm); + break; + + case Ib: + get_value_inc(imm, loc, 1, FALSE); /* unsigned */ + fprintf(stderr,"$0x%x", imm); + break; + + case Ibs: + get_value_inc(imm, loc, 1, TRUE); /* signed */ + fprintf(stderr,"$%d", imm); + break; + + case Iw: + get_value_inc(imm, loc, 2, FALSE); /* unsigned */ + fprintf(stderr,"$0x%x", imm); + break; + + case Il: + get_value_inc(imm, loc, 4, FALSE); + fprintf(stderr,"$0x%x", imm); + break; + + case O: + if (short_addr) { + get_value_inc(displ, loc, 2, TRUE); + } + else { + get_value_inc(displ, loc, 4, TRUE); + } + if (seg) + fprintf(stderr,"%s:%d",seg, displ); + else + db_task_printsym((db_addr_t)displ); + break; + + case Db: + get_value_inc(displ, loc, 1, TRUE); + if (short_addr) { + /* offset only affects low 16 bits */ + displ = (loc & 0xffff0000) + | ((loc + displ) & 0xffff); + } + else + displ = displ + loc; + db_task_printsym((db_addr_t)displ); + break; + + case Dl: + if (short_addr) { + get_value_inc(displ, loc, 2, TRUE); + /* offset only affects low 16 bits */ + displ = (loc & 0xffff0000) + | ((loc + displ) & 0xffff); + } + else { + get_value_inc(displ, loc, 4, TRUE); + displ = displ + loc; + } + db_task_printsym((db_addr_t)displ); + break; + + case o1: + fprintf(stderr,"$1"); + break; + + case o3: + fprintf(stderr,"$3"); + break; + + case OS: + if (short_addr) { + get_value_inc(imm, loc, 2, FALSE); /* offset */ + } + else { + get_value_inc(imm, loc, 4, FALSE); /* offset */ + } + get_value_inc(imm2, loc, 2, FALSE); /* segment */ + fprintf(stderr,"$%d,%d", imm2, imm); + break; + } + } + + if (altfmt == 0 && !db_disasm_16) { + if (inst == 0xe9 || inst == 0xeb) { + /* + * GAS pads to longword boundary after unconditional jumps. + */ +#if 0 + loc = (loc + (4-1)) & ~(4-1); +#endif + } + } + return (loc); +} + diff --git a/debugger/db_disasm.h b/debugger/db_disasm.h new file mode 100644 index 00000000000..8192e0dce8e --- /dev/null +++ b/debugger/db_disasm.h @@ -0,0 +1,7 @@ +#define FALSE 0 +#define TRUE 1 + +typedef unsigned char boolean_t; +typedef unsigned long db_addr_t; + +extern db_addr_t db_disasm(db_addr_t loc, boolean_t altfmt, boolean_t flag16); diff --git a/debugger/dbg.y b/debugger/dbg.y index b2d2ab87f14..3ac7b7ef3f5 100644 --- a/debugger/dbg.y +++ b/debugger/dbg.y @@ -57,8 +57,8 @@ void mode_command(int); | QUIT '\n' { exit(0); } | 'q' '\n' { exit(0); } | HELP '\n' { dbg_help(); } - | CONT '\n' { return; } - | 'c' '\n' { return; } + | CONT '\n' { return 0; } + | 'c' '\n' { return 0; } | ABORT '\n' { kill(getpid(), SIGABRT); } | SYMBOLFILE IDENTIFIER '\n' { read_symboltable($2); } | DEFINE IDENTIFIER expr '\n' { add_hash($2, $3); } @@ -150,7 +150,6 @@ void wine_debug(int signal, int * regs) { static int dummy_regs[32]; - int i; #ifdef YYDEBUG yydebug = 0; #endif @@ -223,7 +222,9 @@ wine_debug(int signal, int * regs) } -yyerror(char * s){ +int yyerror(char * s) +{ fprintf(stderr,"%s\n", s); + return 0; } diff --git a/debugger/debug.l b/debugger/debug.l index fb5c4fb7d5c..3a1a92e4cc6 100644 --- a/debugger/debug.l +++ b/debugger/debug.l @@ -142,6 +142,25 @@ int yywrap(void) { return 1; } #include "readline/chardefs.h" #endif +/* Strip whitespace from the start and end of STRING. */ +static void stripwhite (char *string) +{ + register int i = 0; + + while (whitespace (string[i])) + i++; + + if (i) + strcpy (string, string + i); + + i = strlen (string) - 1; + + while (i > 0 && whitespace (string[i])) + i--; + + string[++i] = '\0'; +} + dbg_read(char * buf, int size){ char * line; int len; @@ -180,25 +199,6 @@ dbg_read(char * buf, int size){ } while (1==1); } -/* Strip whitespace from the start and end of STRING. */ -void stripwhite (char *string) -{ - register int i = 0; - - while (whitespace (string[i])) - i++; - - if (i) - strcpy (string, string + i); - - i = strlen (string) - 1; - - while (i > 0 && whitespace (string[i])) - i--; - - string[++i] = '\0'; -} - static char *local_symbols[10]; static int next_symbol; diff --git a/debugger/info.c b/debugger/info.c index e4e443212d8..3f640dab5b6 100644 --- a/debugger/info.c +++ b/debugger/info.c @@ -6,7 +6,7 @@ #include #include -#include "opcodes/dis-asm.h" +#include "db_disasm.h" #include "regpos.h" extern int * regval; @@ -30,6 +30,7 @@ void print_address(unsigned int addr, FILE * outfile){ } +#ifdef GNU_DISASM void print_address_info(bfd_vma addr, disassemble_info * info){ print_address((unsigned int) addr, info->stream); } @@ -54,6 +55,23 @@ int print_insn(char *realmemaddr, char *memaddr, FILE *stream, int addrlen){ fprintf(stderr, "invalid address length %d.\n", addrlen); return 0; } +#else +void db_task_printsym(unsigned int addr){ + print_address(addr, stderr); +} + +int print_insn(char *realmemaddr, char *memaddr, FILE *stream, int addrlen) +{ + if (addrlen == 16) + return db_disasm((unsigned int) realmemaddr, 0, 1) - + ((unsigned int) realmemaddr); + if (addrlen == 32) + return db_disasm((unsigned int) realmemaddr, 0, 0) - + ((unsigned int) realmemaddr); + fprintf(stderr, "invalid address length %d.\n", addrlen); + return 0; +} +#endif void info_reg(){ @@ -191,7 +209,7 @@ void examine_memory(int addr, int count, char format){ fprintf(stderr," %c", *pnt++); if ((i % 32) == 7) { fprintf(stderr,"\n"); - print_address((unsigned int) dump, stderr); + print_address((unsigned int) pnt, stderr); fprintf(stderr,": "); }; } @@ -222,21 +240,14 @@ char * helptext[] = { "The commands accepted by the Wine debugger are a small subset", "of the commands that gdb would accept. The commands currently", "are:\n", -" info [reg,stack,break]", -" break *", -" enable bpnum", -" disable bpnum", -" help", -" quit", -" print ", -" bt", -" mode [16,32]", -" symbolfile ", +" break * bt", +" disable bpnum enable bpnum", +" help quit", +" x cont", +" mode [16,32] print ", +" set = set * = ", +" info [reg,stack,break,segments] symbolfile ", " define ", -" x ", -" cont", -" set = ", -" set * = ", "", "The 'x' command accepts repeat counts and formats (including 'i') in the", "same way that gdb does.", @@ -282,19 +293,19 @@ void dbg_bt(){ return; } + frame = (struct frame *) ((SC_EBP(dbg_mask) & ~1) | (SC_SS << 16)); + fprintf(stderr,"Backtrace:\n"); fprintf(stderr,"%d ",frameno); print_address(frame->u.win32.saved_ip,stderr); cs = SC_CS; - - frame = (struct frame *) ((SC_EBP(dbg_mask) & ~1) | (SC_SS << 16)); while((cs & 3) == 3) { /* See if in 32 bit mode or not. Assume GDT means 32 bit. */ if ((cs & 7) != 7) { void CallTo32(); fprintf(stderr,"\n%d ",frameno++); print_address(frame->u.win32.saved_ip,stderr); - if(frame->u.win32.saved_ip<((char*)CallTo32+1000))break; + if(frame->u.win32.saved_ip<((unsigned long)CallTo32+1000))break; frame = (struct frame *) frame->u.win32.saved_bp; } else { cs = frame->u.win16.saved_cs; diff --git a/debugger/opcodes/Imakefile b/debugger/opcodes/Imakefile deleted file mode 100644 index 0d94d3f55f3..00000000000 --- a/debugger/opcodes/Imakefile +++ /dev/null @@ -1,26 +0,0 @@ -#include "../../Wine.tmpl" - -MODULE = opcodes - -#ifdef i386 -#define xi386 1 -#undef i386 -#endif - -SRCS = \ - dis-buf.c \ - i386-dis.c - -OBJS = $(SRCS:.c=.o) - -#ifdef xi386 -#define i386 1 -#undef xi386 -#endif - -WineRelocatableTarget($(MODULE),,$(OBJS)) -DependTarget() - -includes:: - -install:: diff --git a/debugger/opcodes/ansidecl.h b/debugger/opcodes/ansidecl.h deleted file mode 100644 index 3c0dcb3d9fc..00000000000 --- a/debugger/opcodes/ansidecl.h +++ /dev/null @@ -1,141 +0,0 @@ -/* ANSI and traditional C compatability macros - Copyright 1991, 1992 Free Software Foundation, Inc. - This file is part of the GNU C Library. - -This program 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; either version 2 of the License, or -(at your option) any later version. - -This program 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 this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* ANSI and traditional C compatibility macros - - ANSI C is assumed if __STDC__ is #defined. - - Macro ANSI C definition Traditional C definition - ----- ---- - ---------- ----------- - ---------- - PTR `void *' `char *' - LONG_DOUBLE `long double' `double' - VOLATILE `volatile' `' - SIGNED `signed' `' - PTRCONST `void *const' `char *' - ANSI_PROTOTYPES 1 not defined - - CONST is also defined, but is obsolete. Just use const. - - DEFUN (name, arglist, args) - - Defines function NAME. - - ARGLIST lists the arguments, separated by commas and enclosed in - parentheses. ARGLIST becomes the argument list in traditional C. - - ARGS list the arguments with their types. It becomes a prototype in - ANSI C, and the type declarations in traditional C. Arguments should - be separated with `AND'. For functions with a variable number of - arguments, the last thing listed should be `DOTS'. - - DEFUN_VOID (name) - - Defines a function NAME, which takes no arguments. - - obsolete -- EXFUN (name, (prototype)) -- obsolete. - - Replaced by PARAMS. Do not use; will disappear someday soon. - Was used in external function declarations. - In ANSI C it is `NAME PROTOTYPE' (so PROTOTYPE should be enclosed in - parentheses). In traditional C it is `NAME()'. - For a function that takes no arguments, PROTOTYPE should be `(void)'. - - PARAMS ((args)) - - We could use the EXFUN macro to handle prototype declarations, but - the name is misleading and the result is ugly. So we just define a - simple macro to handle the parameter lists, as in: - - static int foo PARAMS ((int, char)); - - This produces: `static int foo();' or `static int foo (int, char);' - - EXFUN would have done it like this: - - static int EXFUN (foo, (int, char)); - - but the function is not external...and it's hard to visually parse - the function name out of the mess. EXFUN should be considered - obsolete; new code should be written to use PARAMS. - - For example: - extern int printf PARAMS ((CONST char *format DOTS)); - int DEFUN(fprintf, (stream, format), - FILE *stream AND CONST char *format DOTS) { ... } - void DEFUN_VOID(abort) { ... } -*/ - -#ifndef _ANSIDECL_H - -#define _ANSIDECL_H 1 - - -/* Every source file includes this file, - so they will all get the switch for lint. */ -/* LINTLIBRARY */ - - -#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) -/* All known AIX compilers implement these things (but don't always - define __STDC__). The RISC/OS MIPS compiler defines these things - in SVR4 mode, but does not define __STDC__. */ - -#define PTR void * -#define PTRCONST void *CONST -#define LONG_DOUBLE long double - -#define AND , -#define NOARGS void -#define CONST const -#define VOLATILE volatile -#define SIGNED signed -#define DOTS , ... - -#define EXFUN(name, proto) name proto -#define DEFUN(name, arglist, args) name(args) -#define DEFUN_VOID(name) name(void) - -#define PROTO(type, name, arglist) type name arglist -#define PARAMS(paramlist) paramlist -#define ANSI_PROTOTYPES 1 - -#else /* Not ANSI C. */ - -#define PTR char * -#define PTRCONST PTR -#define LONG_DOUBLE double - -#define AND ; -#define NOARGS -#define CONST -#ifndef const /* some systems define it in header files for non-ansi mode */ -#define const -#endif -#define VOLATILE -#define SIGNED -#define DOTS - -#define EXFUN(name, proto) name() -#define DEFUN(name, arglist, args) name arglist args; -#define DEFUN_VOID(name) name() -#define PROTO(type, name, arglist) type name () -#define PARAMS(paramlist) () - -#endif /* ANSI C. */ - -#endif /* ansidecl.h */ diff --git a/debugger/opcodes/bfd.h b/debugger/opcodes/bfd.h deleted file mode 100644 index ed068d92e43..00000000000 --- a/debugger/opcodes/bfd.h +++ /dev/null @@ -1,2171 +0,0 @@ -/* Main header file for the bfd library -- portable access to object files. - Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. - Contributed by Cygnus Support. - -** NOTE: bfd.h and bfd-in2.h are GENERATED files. Don't change them; -** instead, change bfd-in.h or the other BFD source files processed to -** generate these files. - -This file is part of BFD, the Binary File Descriptor library. - -This program 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; either version 2 of the License, or -(at your option) any later version. - -This program 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 this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* bfd.h -- The only header file required by users of the bfd library - -The bfd.h file is generated from bfd-in.h and various .c files; if you -change it, your changes will probably be lost. - -All the prototypes and definitions following the comment "THE FOLLOWING -IS EXTRACTED FROM THE SOURCE" are extracted from the source files for -BFD. If you change it, someone oneday will extract it from the source -again, and your changes will be lost. To save yourself from this bind, -change the definitions in the source in the bfd directory. Type "make -docs" and then "make headers" in that directory, and magically this file -will change to reflect your changes. - -If you don't have the tools to perform the extraction, then you are -safe from someone on your system trampling over your header files. -You should still maintain the equivalence between the source and this -file though; every change you make to the .c file should be reflected -here. */ - -#ifndef __BFD_H_SEEN__ -#define __BFD_H_SEEN__ - -#include "ansidecl.h" -#include "obstack.h" - -/* These two lines get substitutions done by commands in Makefile.in. */ -#define BFD_VERSION "cygnus-2.3" -#define BFD_ARCH_SIZE 32 - -#if BFD_ARCH_SIZE >= 64 -#define BFD64 -#endif - -#ifndef INLINE -#if __GNUC__ >= 2 -#define INLINE __inline__ -#else -#define INLINE -#endif -#endif - -/* 64-bit type definition (if any) from bfd's sysdep.h goes here */ - - -/* forward declaration */ -typedef struct _bfd bfd; - -/* To squelch erroneous compiler warnings ("illegal pointer - combination") from the SVR3 compiler, we would like to typedef - boolean to int (it doesn't like functions which return boolean. - Making sure they are never implicitly declared to return int - doesn't seem to help). But this file is not configured based on - the host. */ -/* General rules: functions which are boolean return true on success - and false on failure (unless they're a predicate). -- bfd.doc */ -/* I'm sure this is going to break something and someone is going to - force me to change it. */ -/* typedef enum boolean {false, true} boolean; */ -/* Yup, SVR4 has a "typedef enum boolean" in -fnf */ -/* It gets worse if the host also defines a true/false enum... -sts */ -#ifndef TRUE_FALSE_ALREADY_DEFINED -typedef enum bfd_boolean {false, true} boolean; -#define BFD_TRUE_FALSE -#else -typedef enum bfd_boolean {bfd_false, bfd_true} boolean; -#endif - -/* A pointer to a position in a file. */ -/* FIXME: This should be using off_t from . - For now, try to avoid breaking stuff by not including here. - This will break on systems with 64-bit file offsets (e.g. 4.4BSD). - Probably the best long-term answer is to avoid using file_ptr AND off_t - in this header file, and to handle this in the BFD implementation - rather than in its interface. */ -/* typedef off_t file_ptr; */ -typedef long int file_ptr; - -/* Support for different sizes of target format ints and addresses. If the - host implements 64-bit values, it defines BFD_HOST_64_BIT to be the appropriate - type. Otherwise, this code will fall back on gcc's "long long" type if gcc - is being used. BFD_HOST_64_BIT must be defined in such a way as to be a valid - type name by itself or with "unsigned" prefixed. It should be a signed - type by itself. - - If neither is the case, then compilation will fail if 64-bit targets are - requested. If you don't request any 64-bit targets, you should be safe. */ - -#ifdef BFD64 - -#if defined (__GNUC__) && !defined (BFD_HOST_64_BIT) -#define BFD_HOST_64_BIT long long -typedef BFD_HOST_64_BIT int64_type; -typedef unsigned BFD_HOST_64_BIT uint64_type; -#endif - -#if !defined (uint64_type) && defined (__GNUC__) -#define uint64_type unsigned long long -#define int64_type long long -#endif -#ifndef uint64_typeLOW -#define uint64_typeLOW(x) ((unsigned long)(((x) & 0xffffffff))) -#define uint64_typeHIGH(x) ((unsigned long)(((x) >> 32) & 0xffffffff)) -#endif - -typedef unsigned BFD_HOST_64_BIT bfd_vma; -typedef BFD_HOST_64_BIT bfd_signed_vma; -typedef unsigned BFD_HOST_64_BIT bfd_size_type; -typedef unsigned BFD_HOST_64_BIT symvalue; -#ifndef fprintf_vma -#define fprintf_vma(s,x) \ - fprintf(s,"%08lx%08lx", uint64_typeHIGH(x), uint64_typeLOW(x)) -#define sprintf_vma(s,x) \ - sprintf(s,"%08lx%08lx", uint64_typeHIGH(x), uint64_typeLOW(x)) -#endif -#else /* not BFD64 */ - -/* Represent a target address. Also used as a generic unsigned type - which is guaranteed to be big enough to hold any arithmetic types - we need to deal with. */ -typedef unsigned long bfd_vma; - -/* A generic signed type which is guaranteed to be big enough to hold any - arithmetic types we need to deal with. Can be assumed to be compatible - with bfd_vma in the same way that signed and unsigned ints are compatible - (as parameters, in assignment, etc). */ -typedef long bfd_signed_vma; - -typedef unsigned long symvalue; -typedef unsigned long bfd_size_type; - -/* Print a bfd_vma x on stream s. */ -#define fprintf_vma(s,x) fprintf(s, "%08lx", x) -#define sprintf_vma(s,x) sprintf(s, "%08lx", x) -#endif /* not BFD64 */ -#define printf_vma(x) fprintf_vma(stdout,x) - -typedef unsigned int flagword; /* 32 bits of flags */ - -/** File formats */ - -typedef enum bfd_format { - bfd_unknown = 0, /* file format is unknown */ - bfd_object, /* linker/assember/compiler output */ - bfd_archive, /* object archive file */ - bfd_core, /* core dump */ - bfd_type_end} /* marks the end; don't use it! */ - bfd_format; - -/* Values that may appear in the flags field of a BFD. These also - appear in the object_flags field of the bfd_target structure, where - they indicate the set of flags used by that backend (not all flags - are meaningful for all object file formats) (FIXME: at the moment, - the object_flags values have mostly just been copied from backend - to another, and are not necessarily correct). */ - -/* No flags. */ -#define NO_FLAGS 0x00 - -/* BFD contains relocation entries. */ -#define HAS_RELOC 0x01 - -/* BFD is directly executable. */ -#define EXEC_P 0x02 - -/* BFD has line number information (basically used for F_LNNO in a - COFF header). */ -#define HAS_LINENO 0x04 - -/* BFD has debugging information. */ -#define HAS_DEBUG 0x08 - -/* BFD has symbols. */ -#define HAS_SYMS 0x10 - -/* BFD has local symbols (basically used for F_LSYMS in a COFF - header). */ -#define HAS_LOCALS 0x20 - -/* BFD is a dynamic object. */ -#define DYNAMIC 0x40 - -/* Text section is write protected (if D_PAGED is not set, this is - like an a.out NMAGIC file) (the linker sets this by default, but - clears it for -r or -N). */ -#define WP_TEXT 0x80 - -/* BFD is dynamically paged (this is like an a.out ZMAGIC file) (the - linker sets this by default, but clears it for -r or -n or -N). */ -#define D_PAGED 0x100 - -/* BFD is relaxable (this means that bfd_relax_section may be able to - do something). */ -#define BFD_IS_RELAXABLE 0x200 - -/* symbols and relocation */ - -/* A count of carsyms (canonical archive symbols). */ -typedef unsigned long symindex; - -#define BFD_NO_MORE_SYMBOLS ((symindex) ~0) - -/* General purpose part of a symbol X; - target specific parts are in libcoff.h, libaout.h, etc. */ - -#define bfd_get_section(x) ((x)->section) -#define bfd_get_output_section(x) ((x)->section->output_section) -#define bfd_set_section(x,y) ((x)->section) = (y) -#define bfd_asymbol_base(x) ((x)->section->vma) -#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + (x)->value) -#define bfd_asymbol_name(x) ((x)->name) -/*Perhaps future: #define bfd_asymbol_bfd(x) ((x)->section->owner)*/ -#define bfd_asymbol_bfd(x) ((x)->the_bfd) -#define bfd_asymbol_flavour(x) (bfd_asymbol_bfd(x)->xvec->flavour) - -/* A canonical archive symbol. */ -/* This is a type pun with struct ranlib on purpose! */ -typedef struct carsym { - char *name; - file_ptr file_offset; /* look here to find the file */ -} carsym; /* to make these you call a carsymogen */ - - -/* Used in generating armaps (archive tables of contents). - Perhaps just a forward definition would do? */ -struct orl { /* output ranlib */ - char **name; /* symbol name */ - file_ptr pos; /* bfd* or file position */ - int namidx; /* index into string table */ -}; - - - -/* Linenumber stuff */ -typedef struct lineno_cache_entry { - unsigned int line_number; /* Linenumber from start of function*/ - union { - struct symbol_cache_entry *sym; /* Function name */ - unsigned long offset; /* Offset into section */ - } u; -} alent; - -/* object and core file sections */ - - -#define align_power(addr, align) \ - ( ((addr) + ((1<<(align))-1)) & (-1 << (align))) - -typedef struct sec *sec_ptr; - -#define bfd_get_section_name(bfd, ptr) ((ptr)->name + 0) -#define bfd_get_section_vma(bfd, ptr) ((ptr)->vma + 0) -#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0) -#define bfd_section_name(bfd, ptr) ((ptr)->name) -#define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr)) -#define bfd_section_vma(bfd, ptr) ((ptr)->vma) -#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power) -#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags + 0) -#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata) - -#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0) - -#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma= (val)), ((ptr)->user_set_vma = true), true) -#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true) -#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true) - -typedef struct stat stat_type; - -typedef enum bfd_print_symbol -{ - bfd_print_symbol_name, - bfd_print_symbol_more, - bfd_print_symbol_all -} bfd_print_symbol_type; - -/* Information about a symbol that nm needs. */ - -typedef struct _symbol_info -{ - symvalue value; - char type; - CONST char *name; /* Symbol name. */ - char stab_other; /* Unused. */ - short stab_desc; /* Info for N_TYPE. */ - CONST char *stab_name; -} symbol_info; - -/* Hash table routines. There is no way to free up a hash table. */ - -/* An element in the hash table. Most uses will actually use a larger - structure, and an instance of this will be the first field. */ - -struct bfd_hash_entry -{ - /* Next entry for this hash code. */ - struct bfd_hash_entry *next; - /* String being hashed. */ - const char *string; - /* Hash code. This is the full hash code, not the index into the - table. */ - unsigned long hash; -}; - -/* A hash table. */ - -struct bfd_hash_table -{ - /* The hash array. */ - struct bfd_hash_entry **table; - /* The number of slots in the hash table. */ - unsigned int size; - /* A function used to create new elements in the hash table. The - first entry is itself a pointer to an element. When this - function is first invoked, this pointer will be NULL. However, - having the pointer permits a hierarchy of method functions to be - built each of which calls the function in the superclass. Thus - each function should be written to allocate a new block of memory - only if the argument is NULL. */ - struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *, - struct bfd_hash_table *, - const char *)); - /* An obstack for this hash table. */ - struct obstack memory; -}; - -/* Initialize a hash table. */ -extern boolean bfd_hash_table_init - PARAMS ((struct bfd_hash_table *, - struct bfd_hash_entry *(*) (struct bfd_hash_entry *, - struct bfd_hash_table *, - const char *))); - -/* Initialize a hash table specifying a size. */ -extern boolean bfd_hash_table_init_n - PARAMS ((struct bfd_hash_table *, - struct bfd_hash_entry *(*) (struct bfd_hash_entry *, - struct bfd_hash_table *, - const char *), - unsigned int size)); - -/* Free up a hash table. */ -extern void bfd_hash_table_free PARAMS ((struct bfd_hash_table *)); - -/* Look up a string in a hash table. If CREATE is true, a new entry - will be created for this string if one does not already exist. The - COPY argument must be true if this routine should copy the string - into newly allocated memory when adding an entry. */ -extern struct bfd_hash_entry *bfd_hash_lookup - PARAMS ((struct bfd_hash_table *, const char *, boolean create, - boolean copy)); - -/* Base method for creating a hash table entry. */ -extern struct bfd_hash_entry *bfd_hash_newfunc - PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, - const char *)); - -/* Grab some space for a hash table entry. */ -extern PTR bfd_hash_allocate PARAMS ((struct bfd_hash_table *, - unsigned int)); - -/* Traverse a hash table in a random order, calling a function on each - element. If the function returns false, the traversal stops. The - INFO argument is passed to the function. */ -extern void bfd_hash_traverse PARAMS ((struct bfd_hash_table *, - boolean (*) (struct bfd_hash_entry *, - PTR), - PTR info)); - -/* Semi-portable string concatenation in cpp. - The CAT4 hack is to avoid a problem with some strict ANSI C preprocessors. - The problem is, "32_" is not a valid preprocessing token, and we don't - want extra underscores (e.g., "nlm_32_"). The XCAT2 macro will cause the - inner CAT macros to be evaluated first, producing still-valid pp-tokens. - Then the final concatenation can be done. (Sigh.) */ -#ifndef CAT -#ifdef SABER -#define CAT(a,b) a##b -#define CAT3(a,b,c) a##b##c -#define CAT4(a,b,c,d) a##b##c##d -#else -#if defined(__STDC__) || defined(ALMOST_STDC) -#define CAT(a,b) a##b -#define CAT3(a,b,c) a##b##c -#define XCAT2(a,b) CAT(a,b) -#define CAT4(a,b,c,d) XCAT2(CAT(a,b),CAT(c,d)) -#else -#define CAT(a,b) a/**/b -#define CAT3(a,b,c) a/**/b/**/c -#define CAT4(a,b,c,d) a/**/b/**/c/**/d -#endif -#endif -#endif - -#define COFF_SWAP_TABLE (PTR) &bfd_coff_std_swap_table - -/* User program access to BFD facilities */ - -/* Cast from const char * to char * so that caller can assign to - a char * without a warning. */ -#define bfd_get_filename(abfd) ((char *) (abfd)->filename) -#define bfd_get_cacheable(abfd) ((abfd)->cacheable) -#define bfd_get_format(abfd) ((abfd)->format) -#define bfd_get_target(abfd) ((abfd)->xvec->name) -#define bfd_get_flavour(abfd) ((abfd)->xvec->flavour) -#define bfd_get_file_flags(abfd) ((abfd)->flags) -#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags) -#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags) -#define bfd_my_archive(abfd) ((abfd)->my_archive) -#define bfd_has_map(abfd) ((abfd)->has_armap) - -#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types) -#define bfd_usrdata(abfd) ((abfd)->usrdata) - -#define bfd_get_start_address(abfd) ((abfd)->start_address) -#define bfd_get_symcount(abfd) ((abfd)->symcount) -#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols) -#define bfd_count_sections(abfd) ((abfd)->section_count) - -#define bfd_get_symbol_leading_char(abfd) ((abfd)->xvec->symbol_leading_char) - -#define bfd_set_cacheable(abfd,bool) (((abfd)->cacheable = (bool)), true) - -/* Byte swapping routines. */ - -bfd_vma bfd_getb64 PARAMS ((const unsigned char *)); -bfd_vma bfd_getl64 PARAMS ((const unsigned char *)); -bfd_signed_vma bfd_getb_signed_64 PARAMS ((const unsigned char *)); -bfd_signed_vma bfd_getl_signed_64 PARAMS ((const unsigned char *)); -bfd_vma bfd_getb32 PARAMS ((const unsigned char *)); -bfd_vma bfd_getl32 PARAMS ((const unsigned char *)); -bfd_signed_vma bfd_getb_signed_32 PARAMS ((const unsigned char *)); -bfd_signed_vma bfd_getl_signed_32 PARAMS ((const unsigned char *)); -bfd_vma bfd_getb16 PARAMS ((const unsigned char *)); -bfd_vma bfd_getl16 PARAMS ((const unsigned char *)); -bfd_signed_vma bfd_getb_signed_16 PARAMS ((const unsigned char *)); -bfd_signed_vma bfd_getl_signed_16 PARAMS ((const unsigned char *)); -void bfd_putb64 PARAMS ((bfd_vma, unsigned char *)); -void bfd_putl64 PARAMS ((bfd_vma, unsigned char *)); -void bfd_putb32 PARAMS ((bfd_vma, unsigned char *)); -void bfd_putl32 PARAMS ((bfd_vma, unsigned char *)); -void bfd_putb16 PARAMS ((bfd_vma, unsigned char *)); -void bfd_putl16 PARAMS ((bfd_vma, unsigned char *)); - -/* Externally visible ECOFF routines. */ - -#if defined(__STDC__) || defined(ALMOST_STDC) -struct ecoff_debug_info; -struct ecoff_debug_swap; -struct ecoff_extr; -struct symbol_cache_entry; -struct bfd_link_info; -#endif -extern bfd_vma bfd_ecoff_get_gp_value PARAMS ((bfd * abfd)); -extern boolean bfd_ecoff_set_gp_value PARAMS ((bfd *abfd, bfd_vma gp_value)); -extern boolean bfd_ecoff_set_regmasks - PARAMS ((bfd *abfd, unsigned long gprmask, unsigned long fprmask, - unsigned long *cprmask)); -extern PTR bfd_ecoff_debug_init - PARAMS ((bfd *output_bfd, struct ecoff_debug_info *output_debug, - const struct ecoff_debug_swap *output_swap, - struct bfd_link_info *)); -extern void bfd_ecoff_debug_free - PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug, - const struct ecoff_debug_swap *output_swap, - struct bfd_link_info *)); -extern boolean bfd_ecoff_debug_accumulate - PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug, - const struct ecoff_debug_swap *output_swap, - bfd *input_bfd, struct ecoff_debug_info *input_debug, - const struct ecoff_debug_swap *input_swap, - struct bfd_link_info *)); -extern boolean bfd_ecoff_debug_accumulate_other - PARAMS ((PTR handle, bfd *output_bfd, struct ecoff_debug_info *output_debug, - const struct ecoff_debug_swap *output_swap, bfd *input_bfd, - struct bfd_link_info *)); -extern boolean bfd_ecoff_debug_externals - PARAMS ((bfd *abfd, struct ecoff_debug_info *debug, - const struct ecoff_debug_swap *swap, - boolean relocateable, - boolean (*get_extr) (struct symbol_cache_entry *, - struct ecoff_extr *), - void (*set_index) (struct symbol_cache_entry *, - bfd_size_type))); -extern boolean bfd_ecoff_debug_one_external - PARAMS ((bfd *abfd, struct ecoff_debug_info *debug, - const struct ecoff_debug_swap *swap, - const char *name, struct ecoff_extr *esym)); -extern bfd_size_type bfd_ecoff_debug_size - PARAMS ((bfd *abfd, struct ecoff_debug_info *debug, - const struct ecoff_debug_swap *swap)); -extern boolean bfd_ecoff_write_debug - PARAMS ((bfd *abfd, struct ecoff_debug_info *debug, - const struct ecoff_debug_swap *swap, file_ptr where)); -extern boolean bfd_ecoff_write_accumulated_debug - PARAMS ((PTR handle, bfd *abfd, struct ecoff_debug_info *debug, - const struct ecoff_debug_swap *swap, - struct bfd_link_info *info, file_ptr where)); - -/* And more from the source. */ -void -bfd_init PARAMS ((void)); - -bfd * -bfd_openr PARAMS ((CONST char *filename, CONST char *target)); - -bfd * -bfd_fdopenr PARAMS ((CONST char *filename, CONST char *target, int fd)); - -bfd * -bfd_openw PARAMS ((CONST char *filename, CONST char *target)); - -boolean -bfd_close PARAMS ((bfd *abfd)); - -boolean -bfd_close_all_done PARAMS ((bfd *)); - -bfd_size_type -bfd_alloc_size PARAMS ((bfd *abfd)); - -bfd * -bfd_create PARAMS ((CONST char *filename, bfd *templ)); - - - /* Byte swapping macros for user section data. */ - -#define bfd_put_8(abfd, val, ptr) \ - (*((unsigned char *)(ptr)) = (unsigned char)(val)) -#define bfd_put_signed_8 \ - bfd_put_8 -#define bfd_get_8(abfd, ptr) \ - (*(unsigned char *)(ptr)) -#define bfd_get_signed_8(abfd, ptr) \ - ((*(unsigned char *)(ptr) ^ 0x80) - 0x80) - -#define bfd_put_16(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_putx16, ((val),(ptr))) -#define bfd_put_signed_16 \ - bfd_put_16 -#define bfd_get_16(abfd, ptr) \ - BFD_SEND(abfd, bfd_getx16, (ptr)) -#define bfd_get_signed_16(abfd, ptr) \ - BFD_SEND (abfd, bfd_getx_signed_16, (ptr)) - -#define bfd_put_32(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_putx32, ((val),(ptr))) -#define bfd_put_signed_32 \ - bfd_put_32 -#define bfd_get_32(abfd, ptr) \ - BFD_SEND(abfd, bfd_getx32, (ptr)) -#define bfd_get_signed_32(abfd, ptr) \ - BFD_SEND(abfd, bfd_getx_signed_32, (ptr)) - -#define bfd_put_64(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_putx64, ((val), (ptr))) -#define bfd_put_signed_64 \ - bfd_put_64 -#define bfd_get_64(abfd, ptr) \ - BFD_SEND(abfd, bfd_getx64, (ptr)) -#define bfd_get_signed_64(abfd, ptr) \ - BFD_SEND(abfd, bfd_getx_signed_64, (ptr)) - - - /* Byte swapping macros for file header data. */ - -#define bfd_h_put_8(abfd, val, ptr) \ - bfd_put_8 (abfd, val, ptr) -#define bfd_h_put_signed_8(abfd, val, ptr) \ - bfd_put_8 (abfd, val, ptr) -#define bfd_h_get_8(abfd, ptr) \ - bfd_get_8 (abfd, ptr) -#define bfd_h_get_signed_8(abfd, ptr) \ - bfd_get_signed_8 (abfd, ptr) - -#define bfd_h_put_16(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_h_putx16,(val,ptr)) -#define bfd_h_put_signed_16 \ - bfd_h_put_16 -#define bfd_h_get_16(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx16,(ptr)) -#define bfd_h_get_signed_16(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx_signed_16, (ptr)) - -#define bfd_h_put_32(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_h_putx32,(val,ptr)) -#define bfd_h_put_signed_32 \ - bfd_h_put_32 -#define bfd_h_get_32(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx32,(ptr)) -#define bfd_h_get_signed_32(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx_signed_32, (ptr)) - -#define bfd_h_put_64(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_h_putx64,(val, ptr)) -#define bfd_h_put_signed_64 \ - bfd_h_put_64 -#define bfd_h_get_64(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx64,(ptr)) -#define bfd_h_get_signed_64(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr)) - -typedef struct sec -{ - /* The name of the section; the name isn't a copy, the pointer is - the same as that passed to bfd_make_section. */ - - CONST char *name; - - /* Which section is it; 0..nth. */ - - int index; - - /* The next section in the list belonging to the BFD, or NULL. */ - - struct sec *next; - - /* The field flags contains attributes of the section. Some - flags are read in from the object file, and some are - synthesized from other information. */ - - flagword flags; - -#define SEC_NO_FLAGS 0x000 - - /* Tells the OS to allocate space for this section when loading. - This is clear for a section containing debug information - only. */ -#define SEC_ALLOC 0x001 - - /* Tells the OS to load the section from the file when loading. - This is clear for a .bss section. */ -#define SEC_LOAD 0x002 - - /* The section contains data still to be relocated, so there is - some relocation information too. */ -#define SEC_RELOC 0x004 - -#if 0 /* Obsolete ? */ -#define SEC_BALIGN 0x008 -#endif - - /* A signal to the OS that the section contains read only - data. */ -#define SEC_READONLY 0x010 - - /* The section contains code only. */ -#define SEC_CODE 0x020 - - /* The section contains data only. */ -#define SEC_DATA 0x040 - - /* The section will reside in ROM. */ -#define SEC_ROM 0x080 - - /* The section contains constructor information. This section - type is used by the linker to create lists of constructors and - destructors used by <>. When a back end sees a symbol - which should be used in a constructor list, it creates a new - section for the type of name (e.g., <<__CTOR_LIST__>>), attaches - the symbol to it, and builds a relocation. To build the lists - of constructors, all the linker has to do is catenate all the - sections called <<__CTOR_LIST__>> and relocate the data - contained within - exactly the operations it would peform on - standard data. */ -#define SEC_CONSTRUCTOR 0x100 - - /* The section is a constuctor, and should be placed at the - end of the text, data, or bss section(?). */ -#define SEC_CONSTRUCTOR_TEXT 0x1100 -#define SEC_CONSTRUCTOR_DATA 0x2100 -#define SEC_CONSTRUCTOR_BSS 0x3100 - - /* The section has contents - a data section could be - <> | <>; a debug section could be - <> */ -#define SEC_HAS_CONTENTS 0x200 - - /* An instruction to the linker to not output the section - even if it has information which would normally be written. */ -#define SEC_NEVER_LOAD 0x400 - - /* The section is a shared library section. The linker must leave - these completely alone, as the vma and size are used when - the executable is loaded. */ -#define SEC_SHARED_LIBRARY 0x800 - - /* The section is a common section (symbols may be defined - multiple times, the value of a symbol is the amount of - space it requires, and the largest symbol value is the one - used). Most targets have exactly one of these (which we - translate to bfd_com_section), but ECOFF has two. */ -#define SEC_IS_COMMON 0x8000 - - /* The section contains only debugging information. For - example, this is set for ELF .debug and .stab sections. - strip tests this flag to see if a section can be - discarded. */ -#define SEC_DEBUGGING 0x10000 - - /* The contents of this section are held in memory pointed to - by the contents field. This is checked by - bfd_get_section_contents, and the data is retrieved from - memory if appropriate. */ -#define SEC_IN_MEMORY 0x20000 - - /* End of section flags. */ - - /* The virtual memory address of the section - where it will be - at run time. The symbols are relocated against this. The - user_set_vma flag is maintained by bfd; if it's not set, the - backend can assign addresses (for example, in <>, where - the default address for <<.data>> is dependent on the specific - target and various flags). */ - - bfd_vma vma; - boolean user_set_vma; - - /* The load address of the section - where it would be in a - rom image; really only used for writing section header - information. */ - - bfd_vma lma; - - /* The size of the section in bytes, as it will be output. - contains a value even if the section has no contents (e.g., the - size of <<.bss>>). This will be filled in after relocation */ - - bfd_size_type _cooked_size; - - /* The original size on disk of the section, in bytes. Normally this - value is the same as the size, but if some relaxing has - been done, then this value will be bigger. */ - - bfd_size_type _raw_size; - - /* If this section is going to be output, then this value is the - offset into the output section of the first byte in the input - section. E.g., if this was going to start at the 100th byte in - the output section, this value would be 100. */ - - bfd_vma output_offset; - - /* The output section through which to map on output. */ - - struct sec *output_section; - - /* The alignment requirement of the section, as an exponent of 2 - - e.g., 3 aligns to 2^3 (or 8). */ - - unsigned int alignment_power; - - /* If an input section, a pointer to a vector of relocation - records for the data in this section. */ - - struct reloc_cache_entry *relocation; - - /* If an output section, a pointer to a vector of pointers to - relocation records for the data in this section. */ - - struct reloc_cache_entry **orelocation; - - /* The number of relocation records in one of the above */ - - unsigned reloc_count; - - /* Information below is back end specific - and not always used - or updated. */ - - /* File position of section data */ - - file_ptr filepos; - - /* File position of relocation info */ - - file_ptr rel_filepos; - - /* File position of line data */ - - file_ptr line_filepos; - - /* Pointer to data for applications */ - - PTR userdata; - - /* If the SEC_IN_MEMORY flag is set, this points to the actual - contents. */ - unsigned char *contents; - - /* Attached line number information */ - - alent *lineno; - - /* Number of line number records */ - - unsigned int lineno_count; - - /* When a section is being output, this value changes as more - linenumbers are written out */ - - file_ptr moving_line_filepos; - - /* What the section number is in the target world */ - - int target_index; - - PTR used_by_bfd; - - /* If this is a constructor section then here is a list of the - relocations created to relocate items within it. */ - - struct relent_chain *constructor_chain; - - /* The BFD which owns the section. */ - - bfd *owner; - - boolean reloc_done; - /* A symbol which points at this section only */ - struct symbol_cache_entry *symbol; - struct symbol_cache_entry **symbol_ptr_ptr; - - struct bfd_link_order *link_order_head; - struct bfd_link_order *link_order_tail; -} asection ; - - - /* These sections are global, and are managed by BFD. The application - and target back end are not permitted to change the values in - these sections. */ -#define BFD_ABS_SECTION_NAME "*ABS*" -#define BFD_UND_SECTION_NAME "*UND*" -#define BFD_COM_SECTION_NAME "*COM*" -#define BFD_IND_SECTION_NAME "*IND*" - - /* the absolute section */ -extern asection bfd_abs_section; - /* Pointer to the undefined section */ -extern asection bfd_und_section; - /* Pointer to the common section */ -extern asection bfd_com_section; - /* Pointer to the indirect section */ -extern asection bfd_ind_section; - -extern struct symbol_cache_entry *bfd_abs_symbol; -extern struct symbol_cache_entry *bfd_com_symbol; -extern struct symbol_cache_entry *bfd_und_symbol; -extern struct symbol_cache_entry *bfd_ind_symbol; -#define bfd_get_section_size_before_reloc(section) \ - (section->reloc_done ? (abort(),1): (section)->_raw_size) -#define bfd_get_section_size_after_reloc(section) \ - ((section->reloc_done) ? (section)->_cooked_size: (abort(),1)) -asection * -bfd_get_section_by_name PARAMS ((bfd *abfd, CONST char *name)); - -asection * -bfd_make_section_old_way PARAMS ((bfd *abfd, CONST char *name)); - -asection * -bfd_make_section_anyway PARAMS ((bfd *abfd, CONST char *name)); - -asection * -bfd_make_section PARAMS ((bfd *, CONST char *name)); - -boolean -bfd_set_section_flags PARAMS ((bfd *abfd, asection *sec, flagword flags)); - -void -bfd_map_over_sections PARAMS ((bfd *abfd, - void (*func)(bfd *abfd, - asection *sect, - PTR obj), - PTR obj)); - -boolean -bfd_set_section_size PARAMS ((bfd *abfd, asection *sec, bfd_size_type val)); - -boolean -bfd_set_section_contents - PARAMS ((bfd *abfd, - asection *section, - PTR data, - file_ptr offset, - bfd_size_type count)); - -boolean -bfd_get_section_contents - PARAMS ((bfd *abfd, asection *section, PTR location, - file_ptr offset, bfd_size_type count)); - -boolean -bfd_copy_private_section_data PARAMS ((bfd *ibfd, asection *isec, bfd *obfd, asection *osec)); - -#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \ - BFD_SEND (ibfd, _bfd_copy_private_section_data, \ - (ibfd, isection, obfd, osection)) -enum bfd_architecture -{ - bfd_arch_unknown, /* File arch not known */ - bfd_arch_obscure, /* Arch known, not one of these */ - bfd_arch_m68k, /* Motorola 68xxx */ - bfd_arch_vax, /* DEC Vax */ - bfd_arch_i960, /* Intel 960 */ - /* The order of the following is important. - lower number indicates a machine type that - only accepts a subset of the instructions - available to machines with higher numbers. - The exception is the "ca", which is - incompatible with all other machines except - "core". */ - -#define bfd_mach_i960_core 1 -#define bfd_mach_i960_ka_sa 2 -#define bfd_mach_i960_kb_sb 3 -#define bfd_mach_i960_mc 4 -#define bfd_mach_i960_xa 5 -#define bfd_mach_i960_ca 6 - - bfd_arch_a29k, /* AMD 29000 */ - bfd_arch_sparc, /* SPARC */ - bfd_arch_mips, /* MIPS Rxxxx */ - bfd_arch_i386, /* Intel 386 */ - bfd_arch_we32k, /* AT&T WE32xxx */ - bfd_arch_tahoe, /* CCI/Harris Tahoe */ - bfd_arch_i860, /* Intel 860 */ - bfd_arch_romp, /* IBM ROMP PC/RT */ - bfd_arch_alliant, /* Alliant */ - bfd_arch_convex, /* Convex */ - bfd_arch_m88k, /* Motorola 88xxx */ - bfd_arch_pyramid, /* Pyramid Technology */ - bfd_arch_h8300, /* Hitachi H8/300 */ -#define bfd_mach_h8300 1 -#define bfd_mach_h8300h 2 - bfd_arch_powerpc, /* PowerPC */ - bfd_arch_rs6000, /* IBM RS/6000 */ - bfd_arch_hppa, /* HP PA RISC */ - bfd_arch_z8k, /* Zilog Z8000 */ -#define bfd_mach_z8001 1 -#define bfd_mach_z8002 2 - bfd_arch_h8500, /* Hitachi H8/500 */ - bfd_arch_sh, /* Hitachi SH */ - bfd_arch_alpha, /* Dec Alpha */ - bfd_arch_last - }; - -typedef struct bfd_arch_info -{ - int bits_per_word; - int bits_per_address; - int bits_per_byte; - enum bfd_architecture arch; - long mach; - char *arch_name; - CONST char *printable_name; - unsigned int section_align_power; - /* true if this is the default machine for the architecture */ - boolean the_default; - CONST struct bfd_arch_info * (*compatible) - PARAMS ((CONST struct bfd_arch_info *a, - CONST struct bfd_arch_info *b)); - - boolean (*scan) PARAMS ((CONST struct bfd_arch_info *, CONST char *)); - /* How to disassemble an instruction, producing a printable - representation on a specified stdio stream. This isn't - defined for most processors at present, because of the size - of the additional tables it would drag in, and because gdb - wants to use a different interface. */ - unsigned int (*disassemble) PARAMS ((bfd_vma addr, CONST char *data, - PTR stream)); - - struct bfd_arch_info *next; -} bfd_arch_info_type; -CONST char * -bfd_printable_name PARAMS ((bfd *abfd)); - -bfd_arch_info_type * -bfd_scan_arch PARAMS ((CONST char *string)); - -CONST bfd_arch_info_type * -bfd_arch_get_compatible PARAMS (( - CONST bfd *abfd, - CONST bfd *bbfd)); - -void -bfd_set_arch_info PARAMS ((bfd *abfd, bfd_arch_info_type *arg)); - -enum bfd_architecture -bfd_get_arch PARAMS ((bfd *abfd)); - -unsigned long -bfd_get_mach PARAMS ((bfd *abfd)); - -unsigned int -bfd_arch_bits_per_byte PARAMS ((bfd *abfd)); - -unsigned int -bfd_arch_bits_per_address PARAMS ((bfd *abfd)); - -bfd_arch_info_type * -bfd_get_arch_info PARAMS ((bfd *abfd)); - -bfd_arch_info_type * -bfd_lookup_arch - PARAMS ((enum bfd_architecture - arch, - long machine)); - -CONST char * -bfd_printable_arch_mach - PARAMS ((enum bfd_architecture arch, unsigned long machine)); - -typedef enum bfd_reloc_status -{ - /* No errors detected */ - bfd_reloc_ok, - - /* The relocation was performed, but there was an overflow. */ - bfd_reloc_overflow, - - /* The address to relocate was not within the section supplied. */ - bfd_reloc_outofrange, - - /* Used by special functions */ - bfd_reloc_continue, - - /* Unsupported relocation size requested. */ - bfd_reloc_notsupported, - - /* Unused */ - bfd_reloc_other, - - /* The symbol to relocate against was undefined. */ - bfd_reloc_undefined, - - /* The relocation was performed, but may not be ok - presently - generated only when linking i960 coff files with i960 b.out - symbols. If this type is returned, the error_message argument - to bfd_perform_relocation will be set. */ - bfd_reloc_dangerous - } - bfd_reloc_status_type; - - -typedef struct reloc_cache_entry -{ - /* A pointer into the canonical table of pointers */ - struct symbol_cache_entry **sym_ptr_ptr; - - /* offset in section */ - bfd_size_type address; - - /* addend for relocation value */ - bfd_vma addend; - - /* Pointer to how to perform the required relocation */ - const struct reloc_howto_struct *howto; - -} arelent; -enum complain_overflow -{ - /* Do not complain on overflow. */ - complain_overflow_dont, - - /* Complain if the bitfield overflows, whether it is considered - as signed or unsigned. */ - complain_overflow_bitfield, - - /* Complain if the value overflows when considered as signed - number. */ - complain_overflow_signed, - - /* Complain if the value overflows when considered as an - unsigned number. */ - complain_overflow_unsigned -}; - -typedef struct reloc_howto_struct -{ - /* The type field has mainly a documetary use - the back end can - do what it wants with it, though normally the back end's - external idea of what a reloc number is stored - in this field. For example, a PC relative word relocation - in a coff environment has the type 023 - because that's - what the outside world calls a R_PCRWORD reloc. */ - unsigned int type; - - /* The value the final relocation is shifted right by. This drops - unwanted data from the relocation. */ - unsigned int rightshift; - - /* The size of the item to be relocated. This is *not* a - power-of-two measure. To get the number of bytes operated - on by a type of relocation, use bfd_get_reloc_size. */ - int size; - - /* The number of bits in the item to be relocated. This is used - when doing overflow checking. */ - unsigned int bitsize; - - /* Notes that the relocation is relative to the location in the - data section of the addend. The relocation function will - subtract from the relocation value the address of the location - being relocated. */ - boolean pc_relative; - - /* The bit position of the reloc value in the destination. - The relocated value is left shifted by this amount. */ - unsigned int bitpos; - - /* What type of overflow error should be checked for when - relocating. */ - enum complain_overflow complain_on_overflow; - - /* If this field is non null, then the supplied function is - called rather than the normal function. This allows really - strange relocation methods to be accomodated (e.g., i960 callj - instructions). */ - bfd_reloc_status_type (*special_function) - PARAMS ((bfd *abfd, - arelent *reloc_entry, - struct symbol_cache_entry *symbol, - PTR data, - asection *input_section, - bfd *output_bfd, - char **error_message)); - - /* The textual name of the relocation type. */ - char *name; - - /* When performing a partial link, some formats must modify the - relocations rather than the data - this flag signals this.*/ - boolean partial_inplace; - - /* The src_mask selects which parts of the read in data - are to be used in the relocation sum. E.g., if this was an 8 bit - bit of data which we read and relocated, this would be - 0x000000ff. When we have relocs which have an addend, such as - sun4 extended relocs, the value in the offset part of a - relocating field is garbage so we never use it. In this case - the mask would be 0x00000000. */ - bfd_vma src_mask; - - /* The dst_mask selects which parts of the instruction are replaced - into the instruction. In most cases src_mask == dst_mask, - except in the above special case, where dst_mask would be - 0x000000ff, and src_mask would be 0x00000000. */ - bfd_vma dst_mask; - - /* When some formats create PC relative instructions, they leave - the value of the pc of the place being relocated in the offset - slot of the instruction, so that a PC relative relocation can - be made just by adding in an ordinary offset (e.g., sun3 a.out). - Some formats leave the displacement part of an instruction - empty (e.g., m88k bcs); this flag signals the fact.*/ - boolean pcrel_offset; - -} reloc_howto_type; -#define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \ - {(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC} -#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN) - -#define HOWTO_PREPARE(relocation, symbol) \ - { \ - if (symbol != (asymbol *)NULL) { \ - if (bfd_is_com_section (symbol->section)) { \ - relocation = 0; \ - } \ - else { \ - relocation = symbol->value; \ - } \ - } \ -} -int -bfd_get_reloc_size PARAMS ((const reloc_howto_type *)); - -typedef unsigned char bfd_byte; - -typedef struct relent_chain { - arelent relent; - struct relent_chain *next; -} arelent_chain; -bfd_reloc_status_type - -bfd_perform_relocation - PARAMS ((bfd *abfd, - arelent *reloc_entry, - PTR data, - asection *input_section, - bfd *output_bfd, - char **error_message)); - -typedef enum bfd_reloc_code_real -{ - /* Basic absolute relocations */ - BFD_RELOC_64, - BFD_RELOC_32, - BFD_RELOC_26, - BFD_RELOC_16, - BFD_RELOC_14, - BFD_RELOC_8, - - /* PC-relative relocations */ - BFD_RELOC_64_PCREL, - BFD_RELOC_32_PCREL, - BFD_RELOC_24_PCREL, /* used by i960 */ - BFD_RELOC_16_PCREL, - BFD_RELOC_8_PCREL, - - /* Linkage-table relative */ - BFD_RELOC_32_BASEREL, - BFD_RELOC_16_BASEREL, - BFD_RELOC_8_BASEREL, - - /* The type of reloc used to build a contructor table - at the moment - probably a 32 bit wide abs address, but the cpu can choose. */ - BFD_RELOC_CTOR, - - /* 8 bits wide, but used to form an address like 0xffnn */ - BFD_RELOC_8_FFnn, - - /* 32-bit pc-relative, shifted right 2 bits (i.e., 30-bit - word displacement, e.g. for SPARC) */ - BFD_RELOC_32_PCREL_S2, - /* signed 16-bit pc-relative, shifted right 2 bits (e.g. for MIPS) */ - BFD_RELOC_16_PCREL_S2, - /* this is used on the Alpha */ - BFD_RELOC_23_PCREL_S2, - - /* High 22 bits of 32-bit value, placed into lower 22 bits of - target word; simple reloc. */ - BFD_RELOC_HI22, - /* Low 10 bits. */ - BFD_RELOC_LO10, - - /* For systems that allocate a Global Pointer register, these are - displacements off that register. These relocation types are - handled specially, because the value the register will have is - decided relatively late. */ - BFD_RELOC_GPREL16, - BFD_RELOC_GPREL32, - - /* Reloc types used for i960/b.out. */ - BFD_RELOC_I960_CALLJ, - - /* now for the sparc/elf codes */ - BFD_RELOC_NONE, /* actually used */ - BFD_RELOC_SPARC_WDISP22, - BFD_RELOC_SPARC22, - BFD_RELOC_SPARC13, - BFD_RELOC_SPARC_GOT10, - BFD_RELOC_SPARC_GOT13, - BFD_RELOC_SPARC_GOT22, - BFD_RELOC_SPARC_PC10, - BFD_RELOC_SPARC_PC22, - BFD_RELOC_SPARC_WPLT30, - BFD_RELOC_SPARC_COPY, - BFD_RELOC_SPARC_GLOB_DAT, - BFD_RELOC_SPARC_JMP_SLOT, - BFD_RELOC_SPARC_RELATIVE, - BFD_RELOC_SPARC_UA32, - - /* these are a.out specific? */ - BFD_RELOC_SPARC_BASE13, - BFD_RELOC_SPARC_BASE22, - - - /* Alpha ECOFF relocations. Some of these treat the symbol or "addend" - in some special way. */ - /* For GPDISP_HI16 ("gpdisp") relocations, the symbol is ignored when - writing; when reading, it will be the absolute section symbol. The - addend is the displacement in bytes of the "lda" instruction from - the "ldah" instruction (which is at the address of this reloc). */ - BFD_RELOC_ALPHA_GPDISP_HI16, - /* For GPDISP_LO16 ("ignore") relocations, the symbol is handled as - with GPDISP_HI16 relocs. The addend is ignored when writing the - relocations out, and is filled in with the file's GP value on - reading, for convenience. */ - BFD_RELOC_ALPHA_GPDISP_LO16, - - /* The Alpha LITERAL/LITUSE relocs are produced by a symbol reference; - the assembler turns it into a LDQ instruction to load the address of - the symbol, and then fills in a register in the real instruction. - - The LITERAL reloc, at the LDQ instruction, refers to the .lita - section symbol. The addend is ignored when writing, but is filled - in with the file's GP value on reading, for convenience, as with the - GPDISP_LO16 reloc. - - The LITUSE reloc, on the instruction using the loaded address, gives - information to the linker that it might be able to use to optimize - away some literal section references. The symbol is ignored (read - as the absolute section symbol), and the "addend" indicates the type - of instruction using the register: - 1 - "memory" fmt insn - 2 - byte-manipulation (byte offset reg) - 3 - jsr (target of branch) - - The GNU linker currently doesn't do any of this optimizing. */ - BFD_RELOC_ALPHA_LITERAL, - BFD_RELOC_ALPHA_LITUSE, - - /* The HINT relocation indicates a value that should be filled into the - "hint" field of a jmp/jsr/ret instruction, for possible branch- - prediction logic which may be provided on some processors. */ - BFD_RELOC_ALPHA_HINT, - - /* Bits 27..2 of the relocation address shifted right 2 bits; - simple reloc otherwise. */ - BFD_RELOC_MIPS_JMP, - - /* High 16 bits of 32-bit value; simple reloc. */ - BFD_RELOC_HI16, - /* High 16 bits of 32-bit value but the low 16 bits will be sign - extended and added to form the final result. If the low 16 - bits form a negative number, we need to add one to the high value - to compensate for the borrow when the low bits are added. */ - BFD_RELOC_HI16_S, - /* Low 16 bits. */ - BFD_RELOC_LO16, - /* Like BFD_RELOC_HI16_S, but PC relative. */ - BFD_RELOC_PCREL_HI16_S, - /* Like BFD_RELOC_LO16, but PC relative. */ - BFD_RELOC_PCREL_LO16, - - /* relocation relative to the global pointer. */ -#define BFD_RELOC_MIPS_GPREL BFD_RELOC_GPREL16 - - /* Relocation against a MIPS literal section. */ - BFD_RELOC_MIPS_LITERAL, - - /* MIPS ELF relocations. */ - BFD_RELOC_MIPS_GOT16, - BFD_RELOC_MIPS_CALL16, -#define BFD_RELOC_MIPS_GPREL32 BFD_RELOC_GPREL32 - - /* These are, so far, specific to HPPA processors. I'm not sure that some - don't duplicate other reloc types, such as BFD_RELOC_32 and _32_PCREL. - Also, many more were in the list I got that don't fit in well in the - model BFD uses, so I've omitted them for now. If we do make this reloc - type get used for code that really does implement the funky reloc types, - they'll have to be added to this list. */ - BFD_RELOC_HPPA_32, - BFD_RELOC_HPPA_11, - BFD_RELOC_HPPA_14, - BFD_RELOC_HPPA_17, - - BFD_RELOC_HPPA_L21, - BFD_RELOC_HPPA_R11, - BFD_RELOC_HPPA_R14, - BFD_RELOC_HPPA_R17, - BFD_RELOC_HPPA_LS21, - BFD_RELOC_HPPA_RS11, - BFD_RELOC_HPPA_RS14, - BFD_RELOC_HPPA_RS17, - BFD_RELOC_HPPA_LD21, - BFD_RELOC_HPPA_RD11, - BFD_RELOC_HPPA_RD14, - BFD_RELOC_HPPA_RD17, - BFD_RELOC_HPPA_LR21, - BFD_RELOC_HPPA_RR14, - BFD_RELOC_HPPA_RR17, - - BFD_RELOC_HPPA_GOTOFF_11, - BFD_RELOC_HPPA_GOTOFF_14, - BFD_RELOC_HPPA_GOTOFF_L21, - BFD_RELOC_HPPA_GOTOFF_R11, - BFD_RELOC_HPPA_GOTOFF_R14, - BFD_RELOC_HPPA_GOTOFF_LS21, - BFD_RELOC_HPPA_GOTOFF_RS11, - BFD_RELOC_HPPA_GOTOFF_RS14, - BFD_RELOC_HPPA_GOTOFF_LD21, - BFD_RELOC_HPPA_GOTOFF_RD11, - BFD_RELOC_HPPA_GOTOFF_RD14, - BFD_RELOC_HPPA_GOTOFF_LR21, - BFD_RELOC_HPPA_GOTOFF_RR14, - - BFD_RELOC_HPPA_DLT_32, - BFD_RELOC_HPPA_DLT_11, - BFD_RELOC_HPPA_DLT_14, - BFD_RELOC_HPPA_DLT_L21, - BFD_RELOC_HPPA_DLT_R11, - BFD_RELOC_HPPA_DLT_R14, - - BFD_RELOC_HPPA_ABS_CALL_11, - BFD_RELOC_HPPA_ABS_CALL_14, - BFD_RELOC_HPPA_ABS_CALL_17, - BFD_RELOC_HPPA_ABS_CALL_L21, - BFD_RELOC_HPPA_ABS_CALL_R11, - BFD_RELOC_HPPA_ABS_CALL_R14, - BFD_RELOC_HPPA_ABS_CALL_R17, - BFD_RELOC_HPPA_ABS_CALL_LS21, - BFD_RELOC_HPPA_ABS_CALL_RS11, - BFD_RELOC_HPPA_ABS_CALL_RS14, - BFD_RELOC_HPPA_ABS_CALL_RS17, - BFD_RELOC_HPPA_ABS_CALL_LD21, - BFD_RELOC_HPPA_ABS_CALL_RD11, - BFD_RELOC_HPPA_ABS_CALL_RD14, - BFD_RELOC_HPPA_ABS_CALL_RD17, - BFD_RELOC_HPPA_ABS_CALL_LR21, - BFD_RELOC_HPPA_ABS_CALL_RR14, - BFD_RELOC_HPPA_ABS_CALL_RR17, - - BFD_RELOC_HPPA_PCREL_CALL_11, - BFD_RELOC_HPPA_PCREL_CALL_12, - BFD_RELOC_HPPA_PCREL_CALL_14, - BFD_RELOC_HPPA_PCREL_CALL_17, - BFD_RELOC_HPPA_PCREL_CALL_L21, - BFD_RELOC_HPPA_PCREL_CALL_R11, - BFD_RELOC_HPPA_PCREL_CALL_R14, - BFD_RELOC_HPPA_PCREL_CALL_R17, - BFD_RELOC_HPPA_PCREL_CALL_LS21, - BFD_RELOC_HPPA_PCREL_CALL_RS11, - BFD_RELOC_HPPA_PCREL_CALL_RS14, - BFD_RELOC_HPPA_PCREL_CALL_RS17, - BFD_RELOC_HPPA_PCREL_CALL_LD21, - BFD_RELOC_HPPA_PCREL_CALL_RD11, - BFD_RELOC_HPPA_PCREL_CALL_RD14, - BFD_RELOC_HPPA_PCREL_CALL_RD17, - BFD_RELOC_HPPA_PCREL_CALL_LR21, - BFD_RELOC_HPPA_PCREL_CALL_RR14, - BFD_RELOC_HPPA_PCREL_CALL_RR17, - - BFD_RELOC_HPPA_PLABEL_32, - BFD_RELOC_HPPA_PLABEL_11, - BFD_RELOC_HPPA_PLABEL_14, - BFD_RELOC_HPPA_PLABEL_L21, - BFD_RELOC_HPPA_PLABEL_R11, - BFD_RELOC_HPPA_PLABEL_R14, - - BFD_RELOC_HPPA_UNWIND_ENTRY, - BFD_RELOC_HPPA_UNWIND_ENTRIES, - - /* i386/elf relocations */ - BFD_RELOC_386_GOT32, - BFD_RELOC_386_PLT32, - BFD_RELOC_386_COPY, - BFD_RELOC_386_GLOB_DAT, - BFD_RELOC_386_JUMP_SLOT, - BFD_RELOC_386_RELATIVE, - BFD_RELOC_386_GOTOFF, - BFD_RELOC_386_GOTPC, - - /* PowerPC/POWER (RS/6000) relocs. */ - /* 26 bit relative branch. Low two bits must be zero. High 24 - bits installed in bits 6 through 29 of instruction. */ - BFD_RELOC_PPC_B26, - /* 26 bit absolute branch, like BFD_RELOC_PPC_B26 but absolute. */ - BFD_RELOC_PPC_BA26, - /* 16 bit TOC relative reference. */ - BFD_RELOC_PPC_TOC16, - - /* this must be the highest numeric value */ - BFD_RELOC_UNUSED - } bfd_reloc_code_real_type; -const struct reloc_howto_struct * - -bfd_reloc_type_lookup PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); - - -typedef struct symbol_cache_entry -{ - /* A pointer to the BFD which owns the symbol. This information - is necessary so that a back end can work out what additional - information (invisible to the application writer) is carried - with the symbol. - - This field is *almost* redundant, since you can use section->owner - instead, except that some symbols point to the global sections - bfd_{abs,com,und}_section. This could be fixed by making - these globals be per-bfd (or per-target-flavor). FIXME. */ - - struct _bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. */ - - /* The text of the symbol. The name is left alone, and not copied; the - application may not alter it. */ - CONST char *name; - - /* The value of the symbol. This really should be a union of a - numeric value with a pointer, since some flags indicate that - a pointer to another symbol is stored here. */ - symvalue value; - - /* Attributes of a symbol: */ - -#define BSF_NO_FLAGS 0x00 - - /* The symbol has local scope; <> in <>. The value - is the offset into the section of the data. */ -#define BSF_LOCAL 0x01 - - /* The symbol has global scope; initialized data in <>. The - value is the offset into the section of the data. */ -#define BSF_GLOBAL 0x02 - - /* The symbol has global scope and is exported. The value is - the offset into the section of the data. */ -#define BSF_EXPORT BSF_GLOBAL /* no real difference */ - - /* A normal C symbol would be one of: - <>, <>, <> or - <> */ - - /* The symbol is a debugging record. The value has an arbitary - meaning. */ -#define BSF_DEBUGGING 0x08 - - /* The symbol denotes a function entry point. Used in ELF, - perhaps others someday. */ -#define BSF_FUNCTION 0x10 - - /* Used by the linker. */ -#define BSF_KEEP 0x20 -#define BSF_KEEP_G 0x40 - - /* A weak global symbol, overridable without warnings by - a regular global symbol of the same name. */ -#define BSF_WEAK 0x80 - - /* This symbol was created to point to a section, e.g. ELF's - STT_SECTION symbols. */ -#define BSF_SECTION_SYM 0x100 - - /* The symbol used to be a common symbol, but now it is - allocated. */ -#define BSF_OLD_COMMON 0x200 - - /* The default value for common data. */ -#define BFD_FORT_COMM_DEFAULT_VALUE 0 - - /* In some files the type of a symbol sometimes alters its - location in an output file - ie in coff a <> symbol - which is also <> symbol appears where it was - declared and not at the end of a section. This bit is set - by the target BFD part to convey this information. */ - -#define BSF_NOT_AT_END 0x400 - - /* Signal that the symbol is the label of constructor section. */ -#define BSF_CONSTRUCTOR 0x800 - - /* Signal that the symbol is a warning symbol. If the symbol - is a warning symbol, then the value field (I know this is - tacky) will point to the asymbol which when referenced will - cause the warning. */ -#define BSF_WARNING 0x1000 - - /* Signal that the symbol is indirect. The value of the symbol - is a pointer to an undefined asymbol which contains the - name to use instead. */ -#define BSF_INDIRECT 0x2000 - - /* BSF_FILE marks symbols that contain a file name. This is used - for ELF STT_FILE symbols. */ -#define BSF_FILE 0x4000 - - /* Symbol is from dynamic linking information. */ -#define BSF_DYNAMIC 0x8000 - - flagword flags; - - /* A pointer to the section to which this symbol is - relative. This will always be non NULL, there are special - sections for undefined and absolute symbols */ - struct sec *section; - - /* Back end special data. This is being phased out in favour - of making this a union. */ - PTR udata; - -} asymbol; -#define bfd_get_symtab_upper_bound(abfd) \ - BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd)) -boolean -bfd_is_local_label PARAMS ((bfd *abfd, asymbol *sym)); - -#define bfd_is_local_label(abfd, sym) \ - BFD_SEND (abfd, _bfd_is_local_label,(abfd, sym)) -#define bfd_canonicalize_symtab(abfd, location) \ - BFD_SEND (abfd, _bfd_canonicalize_symtab,\ - (abfd, location)) -boolean -bfd_set_symtab PARAMS ((bfd *abfd, asymbol **location, unsigned int count)); - -void -bfd_print_symbol_vandf PARAMS ((PTR file, asymbol *symbol)); - -#define bfd_make_empty_symbol(abfd) \ - BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd)) -#define bfd_make_debug_symbol(abfd,ptr,size) \ - BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size)) -int -bfd_decode_symclass PARAMS ((asymbol *symbol)); - -void -bfd_symbol_info PARAMS ((asymbol *symbol, symbol_info *ret)); - -struct _bfd -{ - /* The filename the application opened the BFD with. */ - CONST char *filename; - - /* A pointer to the target jump table. */ - struct bfd_target *xvec; - - /* To avoid dragging too many header files into every file that - includes `<>', IOSTREAM has been declared as a "char - *", and MTIME as a "long". Their correct types, to which they - are cast when used, are "FILE *" and "time_t". The iostream - is the result of an fopen on the filename. */ - char *iostream; - - /* Is the file descriptor being cached? That is, can it be closed as - needed, and re-opened when accessed later? */ - - boolean cacheable; - - /* Marks whether there was a default target specified when the - BFD was opened. This is used to select which matching algorithm - to use to choose the back end. */ - - boolean target_defaulted; - - /* The caching routines use these to maintain a - least-recently-used list of BFDs */ - - struct _bfd *lru_prev, *lru_next; - - /* When a file is closed by the caching routines, BFD retains - state information on the file here: */ - - file_ptr where; - - /* and here: (``once'' means at least once) */ - - boolean opened_once; - - /* Set if we have a locally maintained mtime value, rather than - getting it from the file each time: */ - - boolean mtime_set; - - /* File modified time, if mtime_set is true: */ - - long mtime; - - /* Reserved for an unimplemented file locking extension.*/ - - int ifd; - - /* The format which belongs to the BFD. (object, core, etc.) */ - - bfd_format format; - - /* The direction the BFD was opened with*/ - - enum bfd_direction {no_direction = 0, - read_direction = 1, - write_direction = 2, - both_direction = 3} direction; - - /* Format_specific flags*/ - - flagword flags; - - /* Currently my_archive is tested before adding origin to - anything. I believe that this can become always an add of - origin, with origin set to 0 for non archive files. */ - - file_ptr origin; - - /* Remember when output has begun, to stop strange things - from happening. */ - boolean output_has_begun; - - /* Pointer to linked list of sections*/ - struct sec *sections; - - /* The number of sections */ - unsigned int section_count; - - /* Stuff only useful for object files: - The start address. */ - bfd_vma start_address; - - /* Used for input and output*/ - unsigned int symcount; - - /* Symbol table for output BFD (with symcount entries) */ - struct symbol_cache_entry **outsymbols; - - /* Pointer to structure which contains architecture information*/ - struct bfd_arch_info *arch_info; - - /* Stuff only useful for archives:*/ - PTR arelt_data; - struct _bfd *my_archive; /* The containing archive BFD. */ - struct _bfd *next; /* The next BFD in the archive. */ - struct _bfd *archive_head; /* The first BFD in the archive. */ - boolean has_armap; - - /* A chain of BFD structures involved in a link. */ - struct _bfd *link_next; - - /* A field used by _bfd_generic_link_add_archive_symbols. This will - be used only for archive elements. */ - int archive_pass; - - /* Used by the back end to hold private data. */ - - union - { - struct aout_data_struct *aout_data; - struct artdata *aout_ar_data; - struct _oasys_data *oasys_obj_data; - struct _oasys_ar_data *oasys_ar_data; - struct coff_tdata *coff_obj_data; - struct ecoff_tdata *ecoff_obj_data; - struct ieee_data_struct *ieee_data; - struct ieee_ar_data_struct *ieee_ar_data; - struct srec_data_struct *srec_data; - struct tekhex_data_struct *tekhex_data; - struct elf_obj_tdata *elf_obj_data; - struct nlm_obj_tdata *nlm_obj_data; - struct bout_data_struct *bout_data; - struct sun_core_struct *sun_core_data; - struct trad_core_struct *trad_core_data; - struct som_data_struct *som_data; - struct hpux_core_struct *hpux_core_data; - struct hppabsd_core_struct *hppabsd_core_data; - struct sgi_core_struct *sgi_core_data; - struct lynx_core_struct *lynx_core_data; - struct osf_core_struct *osf_core_data; - struct cisco_core_struct *cisco_core_data; - PTR any; - } tdata; - - /* Used by the application to hold private data*/ - PTR usrdata; - - /* Where all the allocated stuff under this BFD goes */ - struct obstack memory; -}; - -typedef enum bfd_error -{ - bfd_error_no_error = 0, - bfd_error_system_call, - bfd_error_invalid_target, - bfd_error_wrong_format, - bfd_error_invalid_operation, - bfd_error_no_memory, - bfd_error_no_symbols, - bfd_error_no_more_archived_files, - bfd_error_malformed_archive, - bfd_error_file_not_recognized, - bfd_error_file_ambiguously_recognized, - bfd_error_no_contents, - bfd_error_nonrepresentable_section, - bfd_error_no_debug_section, - bfd_error_bad_value, - bfd_error_file_truncated, - bfd_error_invalid_error_code -} bfd_error_type; - -bfd_error_type -bfd_get_error PARAMS ((void)); - -void -bfd_set_error PARAMS ((bfd_error_type error_tag)); - -CONST char * -bfd_errmsg PARAMS ((bfd_error_type error_tag)); - -void -bfd_perror PARAMS ((CONST char *message)); - -long -bfd_get_reloc_upper_bound PARAMS ((bfd *abfd, asection *sect)); - -long -bfd_canonicalize_reloc - PARAMS ((bfd *abfd, - asection *sec, - arelent **loc, - asymbol **syms)); - -void -bfd_set_reloc - PARAMS ((bfd *abfd, asection *sec, arelent **rel, unsigned int count) - - ); - -boolean -bfd_set_file_flags PARAMS ((bfd *abfd, flagword flags)); - -boolean -bfd_set_start_address PARAMS ((bfd *abfd, bfd_vma vma)); - -long -bfd_get_mtime PARAMS ((bfd *abfd)); - -long -bfd_get_size PARAMS ((bfd *abfd)); - -int -bfd_get_gp_size PARAMS ((bfd *abfd)); - -void -bfd_set_gp_size PARAMS ((bfd *abfd, int i)); - -bfd_vma -bfd_scan_vma PARAMS ((CONST char *string, CONST char **end, int base)); - -boolean -bfd_copy_private_bfd_data PARAMS ((bfd *ibfd, bfd *obfd)); - -#define bfd_copy_private_bfd_data(ibfd, obfd) \ - BFD_SEND (ibfd, _bfd_copy_private_bfd_data, \ - (ibfd, obfd)) -#define bfd_sizeof_headers(abfd, reloc) \ - BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc)) - -#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \ - BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, sec, syms, off, file, func, line)) - - /* Do these three do anything useful at all, for any back end? */ -#define bfd_debug_info_start(abfd) \ - BFD_SEND (abfd, _bfd_debug_info_start, (abfd)) - -#define bfd_debug_info_end(abfd) \ - BFD_SEND (abfd, _bfd_debug_info_end, (abfd)) - -#define bfd_debug_info_accumulate(abfd, section) \ - BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section)) - - -#define bfd_stat_arch_elt(abfd, stat) \ - BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat)) - -#define bfd_set_arch_mach(abfd, arch, mach)\ - BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach)) - -#define bfd_get_relocated_section_contents(abfd, link_info, link_order, data, relocateable, symbols) \ - BFD_SEND (abfd, _bfd_get_relocated_section_contents, \ - (abfd, link_info, link_order, data, relocateable, symbols)) - -#define bfd_relax_section(abfd, section, link_info, again) \ - BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again)) - -#define bfd_link_hash_table_create(abfd) \ - BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd)) - -#define bfd_link_add_symbols(abfd, info) \ - BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info)) - -#define bfd_final_link(abfd, info) \ - BFD_SEND (abfd, _bfd_final_link, (abfd, info)) - -#define bfd_free_cached_info(abfd) \ - BFD_SEND (abfd, _bfd_free_cached_info, (abfd)) - -#define bfd_get_dynamic_symtab_upper_bound(abfd) \ - BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd)) - -#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \ - BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols)) - -#define bfd_get_dynamic_reloc_upper_bound(abfd) \ - BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd)) - -#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \ - BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms)) - -symindex -bfd_get_next_mapent PARAMS ((bfd *abfd, symindex previous, carsym **sym)); - -boolean -bfd_set_archive_head PARAMS ((bfd *output, bfd *new_head)); - -bfd * -bfd_get_elt_at_index PARAMS ((bfd *archive, int index)); - -bfd * -bfd_openr_next_archived_file PARAMS ((bfd *archive, bfd *previous)); - -CONST char * -bfd_core_file_failing_command PARAMS ((bfd *abfd)); - -int -bfd_core_file_failing_signal PARAMS ((bfd *abfd)); - -boolean -core_file_matches_executable_p - PARAMS ((bfd *core_bfd, bfd *exec_bfd)); - -#define BFD_SEND(bfd, message, arglist) \ - ((*((bfd)->xvec->message)) arglist) - -#ifdef DEBUG_BFD_SEND -#undef BFD_SEND -#define BFD_SEND(bfd, message, arglist) \ - (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ - ((*((bfd)->xvec->message)) arglist) : \ - (bfd_assert (__FILE__,__LINE__), NULL)) -#endif -#define BFD_SEND_FMT(bfd, message, arglist) \ - (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) - -#ifdef DEBUG_BFD_SEND -#undef BFD_SEND_FMT -#define BFD_SEND_FMT(bfd, message, arglist) \ - (((bfd) && (bfd)->xvec && (bfd)->xvec->message) ? \ - (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) : \ - (bfd_assert (__FILE__,__LINE__), NULL)) -#endif -enum bfd_flavour { - bfd_target_unknown_flavour, - bfd_target_aout_flavour, - bfd_target_coff_flavour, - bfd_target_ecoff_flavour, - bfd_target_elf_flavour, - bfd_target_ieee_flavour, - bfd_target_nlm_flavour, - bfd_target_oasys_flavour, - bfd_target_tekhex_flavour, - bfd_target_srec_flavour, - bfd_target_som_flavour, - bfd_target_os9k_flavour}; - - /* Forward declaration. */ -typedef struct bfd_link_info _bfd_link_info; - -typedef struct bfd_target -{ - char *name; - enum bfd_flavour flavour; - boolean byteorder_big_p; - boolean header_byteorder_big_p; - flagword object_flags; - flagword section_flags; - char symbol_leading_char; - char ar_pad_char; - unsigned short ar_max_namelen; - unsigned int align_power_min; - bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *)); - bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *)); - void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *)); - bfd_vma (*bfd_getx32) PARAMS ((const bfd_byte *)); - bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((const bfd_byte *)); - void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *)); - bfd_vma (*bfd_getx16) PARAMS ((const bfd_byte *)); - bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((const bfd_byte *)); - void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *)); - bfd_vma (*bfd_h_getx64) PARAMS ((const bfd_byte *)); - bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((const bfd_byte *)); - void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *)); - bfd_vma (*bfd_h_getx32) PARAMS ((const bfd_byte *)); - bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((const bfd_byte *)); - void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *)); - bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *)); - bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((const bfd_byte *)); - void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *)); - struct bfd_target * (*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *)); - boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *)); - boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *)); - - /* Generic entry points. */ -#define BFD_JUMP_TABLE_GENERIC(NAME)\ -CAT(NAME,_close_and_cleanup),\ -CAT(NAME,_bfd_free_cached_info),\ -CAT(NAME,_new_section_hook),\ -CAT(NAME,_get_section_contents) - /* Called when the BFD is being closed to do any necessary cleanup. */ - boolean (*_close_and_cleanup) PARAMS ((bfd *)); - /* Ask the BFD to free all cached information. */ - boolean (*_bfd_free_cached_info) PARAMS ((bfd *)); - /* Called when a new section is created. */ - boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr)); - /* Read the contents of a section. */ - boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR, - file_ptr, bfd_size_type)); - - /* Entry points to copy private data. */ -#define BFD_JUMP_TABLE_COPY(NAME)\ -CAT(NAME,_bfd_copy_private_bfd_data),\ -CAT(NAME,_bfd_copy_private_section_data) - /* Called to copy BFD general private data from one object file - to another. */ - boolean (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *)); - /* Called to copy BFD private section data from one object file - to another. */ - boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr, - bfd *, sec_ptr)); - - /* Core file entry points. */ -#define BFD_JUMP_TABLE_CORE(NAME)\ -CAT(NAME,_core_file_failing_command),\ -CAT(NAME,_core_file_failing_signal),\ -CAT(NAME,_core_file_matches_executable_p) - char * (*_core_file_failing_command) PARAMS ((bfd *)); - int (*_core_file_failing_signal) PARAMS ((bfd *)); - boolean (*_core_file_matches_executable_p) PARAMS ((bfd *, bfd *)); - - /* Archive entry points. */ -#define BFD_JUMP_TABLE_ARCHIVE(NAME)\ -CAT(NAME,_slurp_armap),\ -CAT(NAME,_slurp_extended_name_table),\ -CAT(NAME,_truncate_arname),\ -CAT(NAME,_write_armap),\ -CAT(NAME,_openr_next_archived_file),\ -CAT(NAME,_generic_stat_arch_elt) - boolean (*_bfd_slurp_armap) PARAMS ((bfd *)); - boolean (*_bfd_slurp_extended_name_table) PARAMS ((bfd *)); - void (*_bfd_truncate_arname) PARAMS ((bfd *, CONST char *, char *)); - boolean (*write_armap) PARAMS ((bfd *arch, - unsigned int elength, - struct orl *map, - unsigned int orl_count, - int stridx)); - bfd * (*openr_next_archived_file) PARAMS ((bfd *arch, bfd *prev)); - int (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *)); - - /* Entry points used for symbols. */ -#define BFD_JUMP_TABLE_SYMBOLS(NAME)\ -CAT(NAME,_get_symtab_upper_bound),\ -CAT(NAME,_get_symtab),\ -CAT(NAME,_make_empty_symbol),\ -CAT(NAME,_print_symbol),\ -CAT(NAME,_get_symbol_info),\ -CAT(NAME,_bfd_is_local_label),\ -CAT(NAME,_get_lineno),\ -CAT(NAME,_find_nearest_line),\ -CAT(NAME,_bfd_make_debug_symbol) - long (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *)); - long (*_bfd_canonicalize_symtab) PARAMS ((bfd *, - struct symbol_cache_entry **)); - struct symbol_cache_entry * - (*_bfd_make_empty_symbol) PARAMS ((bfd *)); - void (*_bfd_print_symbol) PARAMS ((bfd *, PTR, - struct symbol_cache_entry *, - bfd_print_symbol_type)); -#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e)) - void (*_bfd_get_symbol_info) PARAMS ((bfd *, - struct symbol_cache_entry *, - symbol_info *)); -#define bfd_get_symbol_info(b,p,e) BFD_SEND(b, _bfd_get_symbol_info, (b,p,e)) - boolean (*_bfd_is_local_label) PARAMS ((bfd *, asymbol *)); - - alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *)); - boolean (*_bfd_find_nearest_line) PARAMS ((bfd *abfd, - struct sec *section, struct symbol_cache_entry **symbols, - bfd_vma offset, CONST char **file, CONST char **func, - unsigned int *line)); - /* Back-door to allow format-aware applications to create debug symbols - while using BFD for everything else. Currently used by the assembler - when creating COFF files. */ - asymbol * (*_bfd_make_debug_symbol) PARAMS (( - bfd *abfd, - void *ptr, - unsigned long size)); - - /* Routines for relocs. */ -#define BFD_JUMP_TABLE_RELOCS(NAME)\ -CAT(NAME,_get_reloc_upper_bound),\ -CAT(NAME,_canonicalize_reloc),\ -CAT(NAME,_bfd_reloc_type_lookup) - long (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr)); - long (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **, - struct symbol_cache_entry **)); - /* See documentation on reloc types. */ - CONST struct reloc_howto_struct * - (*reloc_type_lookup) PARAMS ((bfd *abfd, - bfd_reloc_code_real_type code)); - - /* Routines used when writing an object file. */ -#define BFD_JUMP_TABLE_WRITE(NAME)\ -CAT(NAME,_set_arch_mach),\ -CAT(NAME,_set_section_contents) - boolean (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture, - unsigned long)); - boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR, - file_ptr, bfd_size_type)); - - /* Routines used by the linker. */ -#define BFD_JUMP_TABLE_LINK(NAME)\ -CAT(NAME,_sizeof_headers),\ -CAT(NAME,_bfd_get_relocated_section_contents),\ -CAT(NAME,_bfd_relax_section),\ -CAT(NAME,_bfd_link_hash_table_create),\ -CAT(NAME,_bfd_link_add_symbols),\ -CAT(NAME,_bfd_final_link) - int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean)); - bfd_byte * (*_bfd_get_relocated_section_contents) PARAMS ((bfd *, - struct bfd_link_info *, struct bfd_link_order *, - bfd_byte *data, boolean relocateable, - struct symbol_cache_entry **)); - - boolean (*_bfd_relax_section) PARAMS ((bfd *, struct sec *, - struct bfd_link_info *, boolean *again)); - - /* Create a hash table for the linker. Different backends store - different information in this table. */ - struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *)); - - /* Add symbols from this object file into the hash table. */ - boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *)); - - /* Do a link based on the link_order structures attached to each - section of the BFD. */ - boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *)); - - /* Routines to handle dynamic symbols and relocs. */ -#define BFD_JUMP_TABLE_DYNAMIC(NAME)\ -CAT(NAME,_get_dynamic_symtab_upper_bound),\ -CAT(NAME,_canonicalize_dynamic_symtab),\ -CAT(NAME,_get_dynamic_reloc_upper_bound),\ -CAT(NAME,_canonicalize_dynamic_reloc) - /* Get the amount of memory required to hold the dynamic symbols. */ - long (*_bfd_get_dynamic_symtab_upper_bound) PARAMS ((bfd *)); - /* Read in the dynamic symbols. */ - long (*_bfd_canonicalize_dynamic_symtab) - PARAMS ((bfd *, struct symbol_cache_entry **)); - /* Get the amount of memory required to hold the dynamic relocs. */ - long (*_bfd_get_dynamic_reloc_upper_bound) PARAMS ((bfd *)); - /* Read in the dynamic relocs. */ - long (*_bfd_canonicalize_dynamic_reloc) - PARAMS ((bfd *, arelent **, struct symbol_cache_entry **)); - - PTR backend_data; -} bfd_target; -bfd_target * -bfd_find_target PARAMS ((CONST char *target_name, bfd *abfd)); - -CONST char ** -bfd_target_list PARAMS ((void)); - -boolean -bfd_check_format PARAMS ((bfd *abfd, bfd_format format)); - -boolean -bfd_check_format_matches PARAMS ((bfd *abfd, bfd_format format, char ***matching)); - -boolean -bfd_set_format PARAMS ((bfd *abfd, bfd_format format)); - -CONST char * -bfd_format_string PARAMS ((bfd_format format)); - -#endif diff --git a/debugger/opcodes/dis-asm.h b/debugger/opcodes/dis-asm.h deleted file mode 100644 index e38f5fdfc1c..00000000000 --- a/debugger/opcodes/dis-asm.h +++ /dev/null @@ -1,179 +0,0 @@ -/* Interface between the opcode library and its callers. - Written by Cygnus Support, 1993. - - The opcode library (libopcodes.a) provides instruction decoders for - a large variety of instruction sets, callable with an identical - interface, for making instruction-processing programs more independent - of the instruction set being processed. */ - -#include -#include "bfd.h" - -typedef int (*fprintf_ftype) PARAMS((FILE*, const char*, ...)); - -enum dis_insn_type { - dis_noninsn, /* Not a valid instruction */ - dis_nonbranch, /* Not a branch instruction */ - dis_branch, /* Unconditional branch */ - dis_condbranch, /* Conditional branch */ - dis_jsr, /* Jump to subroutine */ - dis_condjsr, /* Conditional jump to subroutine */ - dis_dref, /* Data reference instruction */ - dis_dref2 /* Two data references in instruction */ -}; - -/* This struct is passed into the instruction decoding routine, - and is passed back out into each callback. The various fields are used - for conveying information from your main routine into your callbacks, - for passing information into the instruction decoders (such as the - addresses of the callback functions), or for passing information - back from the instruction decoders to their callers. - - It must be initialized before it is first passed; this can be done - by hand, or using one of the initialization macros below. */ - -typedef struct disassemble_info { - fprintf_ftype fprintf_func; - FILE *stream; - PTR application_data; - - /* For use by the disassembler. */ - int flags; - PTR private_data; - - /* Function used to get bytes to disassemble. MEMADDR is the - address of the stuff to be disassembled, MYADDR is the address to - put the bytes in, and LENGTH is the number of bytes to read. - INFO is a pointer to this struct. - Returns an errno value or 0 for success. */ - int (*read_memory_func) - PARAMS ((bfd_vma memaddr, bfd_byte *myaddr, int length, - struct disassemble_info *info)); - - /* Function which should be called if we get an error that we can't - recover from. STATUS is the errno value from read_memory_func and - MEMADDR is the address that we were trying to read. INFO is a - pointer to this struct. */ - void (*memory_error_func) - PARAMS ((int status, bfd_vma memaddr, struct disassemble_info *info)); - - /* Function called to print ADDR. */ - void (*print_address_func) - PARAMS ((bfd_vma addr, struct disassemble_info *info)); - - /* These are for buffer_read_memory. */ - bfd_byte *buffer; - bfd_vma buffer_vma; - int buffer_length; - - /* Results from instruction decoders. Not all decoders yet support - this information. This info is set each time an instruction is - decoded, and is only valid for the last such instruction. - - To determine whether this decoder supports this information, set - insn_info_valid to 0, decode an instruction, then check it. */ - - char insn_info_valid; /* Branch info has been set. */ - char branch_delay_insns; /* How many sequential insn's will run before - a branch takes effect. (0 = normal) */ - char data_size; /* Size of data reference in insn, in bytes */ - enum dis_insn_type insn_type; /* Type of instruction */ - bfd_vma target; /* Target address of branch or dref, if known; - zero if unknown. */ - bfd_vma target2; /* Second target address for dref2 */ - -} disassemble_info; - - - - - - -/* Standard disassemblers. Disassemble one instruction at the given - target address. Return number of bytes processed. */ -typedef int (*disassembler_ftype) - PARAMS((bfd_vma, disassemble_info *)); - -extern int print_insn_big_mips PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_little_mips PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_i286 PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_i386 PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_m68k PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_z8001 PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_z8002 PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_h8300 PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_h8300h PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_h8500 PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_alpha PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_sparc PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_big_a29k PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_little_a29k PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_i960 PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_sh PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_hppa PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_m88k PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_big_powerpc PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_little_powerpc PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_rs6000 PARAMS ((bfd_vma, disassemble_info*)); - -/* Fetch the disassembler for a given BFD, if that support is available. */ -extern disassembler_ftype disassembler PARAMS ((bfd *)); - - -/* This block of definitions is for particular callers who read instructions - into a buffer before calling the instruction decoder. */ - -/* Here is a function which callers may wish to use for read_memory_func. - It gets bytes from a buffer. */ -extern int buffer_read_memory - PARAMS ((bfd_vma, bfd_byte *, int, struct disassemble_info *)); - -/* This function goes with buffer_read_memory. - It prints a message using info->fprintf_func and info->stream. */ -extern void perror_memory PARAMS ((int, bfd_vma, struct disassemble_info *)); - - -/* Just print the address is hex. This is included for completeness even - though both GDB and objdump provide their own (to print symbolic - addresses). */ -extern void generic_print_address - PARAMS ((bfd_vma, struct disassemble_info *)); - -#define INIT_DISASSEMBLE_INFO(INFO, STREAM) \ - (INFO).fprintf_func = (fprintf_ftype)fprintf, \ - (INFO).stream = (STREAM), \ - (INFO).buffer = NULL, \ - (INFO).buffer_vma = 0, \ - (INFO).buffer_length = 0, \ - (INFO).read_memory_func = buffer_read_memory, \ - (INFO).memory_error_func = perror_memory, \ - (INFO).print_address_func = generic_print_address, \ - (INFO).insn_info_valid = 0 - - - - -/* This block of definitions is for calling the instruction decoders - from GDB. */ - -/* GDB--Like target_read_memory, but slightly different parameters. */ -extern int -dis_asm_read_memory PARAMS ((bfd_vma memaddr, bfd_byte *myaddr, int len, - disassemble_info *info)); - -/* GDB--Like memory_error with slightly different parameters. */ -extern void -dis_asm_memory_error - PARAMS ((int status, bfd_vma memaddr, disassemble_info *info)); - -/* GDB--Like print_address with slightly different parameters. */ -extern void -dis_asm_print_address PARAMS ((bfd_vma addr, disassemble_info *info)); - -#define GDB_INIT_DISASSEMBLE_INFO(INFO, STREAM) \ - (INFO).fprintf_func = (fprintf_ftype)fprintf_filtered, \ - (INFO).stream = (STREAM), \ - (INFO).read_memory_func = dis_asm_read_memory, \ - (INFO).memory_error_func = dis_asm_memory_error, \ - (INFO).print_address_func = dis_asm_print_address, \ - (INFO).insn_info_valid = 0 diff --git a/debugger/opcodes/dis-asm.h-fsf b/debugger/opcodes/dis-asm.h-fsf deleted file mode 100644 index 0e02a7e2f36..00000000000 --- a/debugger/opcodes/dis-asm.h-fsf +++ /dev/null @@ -1,178 +0,0 @@ -/* Interface between the opcode library and its callers. - Written by Cygnus Support, 1993. - - The opcode library (libopcodes.a) provides instruction decoders for - a large variety of instruction sets, callable with an identical - interface, for making instruction-processing programs more independent - of the instruction set being processed. */ - -#include -#include "bfd.h" - -typedef int (*fprintf_ftype) PARAMS((FILE*, const char*, ...)); - -enum dis_insn_type { - dis_noninsn, /* Not a valid instruction */ - dis_nonbranch, /* Not a branch instruction */ - dis_branch, /* Unconditional branch */ - dis_condbranch, /* Conditional branch */ - dis_jsr, /* Jump to subroutine */ - dis_condjsr, /* Conditional jump to subroutine */ - dis_dref, /* Data reference instruction */ - dis_dref2 /* Two data references in instruction */ -}; - -/* This struct is passed into the instruction decoding routine, - and is passed back out into each callback. The various fields are used - for conveying information from your main routine into your callbacks, - for passing information into the instruction decoders (such as the - addresses of the callback functions), or for passing information - back from the instruction decoders to their callers. - - It must be initialized before it is first passed; this can be done - by hand, or using one of the initialization macros below. */ - -typedef struct disassemble_info { - fprintf_ftype fprintf_func; - FILE *stream; - PTR application_data; - - /* For use by the disassembler. */ - int flags; - PTR private_data; - - /* Function used to get bytes to disassemble. MEMADDR is the - address of the stuff to be disassembled, MYADDR is the address to - put the bytes in, and LENGTH is the number of bytes to read. - INFO is a pointer to this struct. - Returns an errno value or 0 for success. */ - int (*read_memory_func) - PARAMS ((bfd_vma memaddr, bfd_byte *myaddr, int length, - struct disassemble_info *info)); - - /* Function which should be called if we get an error that we can't - recover from. STATUS is the errno value from read_memory_func and - MEMADDR is the address that we were trying to read. INFO is a - pointer to this struct. */ - void (*memory_error_func) - PARAMS ((int status, bfd_vma memaddr, struct disassemble_info *info)); - - /* Function called to print ADDR. */ - void (*print_address_func) - PARAMS ((bfd_vma addr, struct disassemble_info *info)); - - /* These are for buffer_read_memory. */ - bfd_byte *buffer; - bfd_vma buffer_vma; - int buffer_length; - - /* Results from instruction decoders. Not all decoders yet support - this information. This info is set each time an instruction is - decoded, and is only valid for the last such instruction. - - To determine whether this decoder supports this information, set - insn_info_valid to 0, decode an instruction, then check it. */ - - char insn_info_valid; /* Branch info has been set. */ - char branch_delay_insns; /* How many sequential insn's will run before - a branch takes effect. (0 = normal) */ - char data_size; /* Size of data reference in insn, in bytes */ - enum dis_insn_type insn_type; /* Type of instruction */ - bfd_vma target; /* Target address of branch or dref, if known; - zero if unknown. */ - bfd_vma target2; /* Second target address for dref2 */ - -} disassemble_info; - - - - - - -/* Standard disassemblers. Disassemble one instruction at the given - target address. Return number of bytes processed. */ -typedef int (*disassembler_ftype) - PARAMS((bfd_vma, disassemble_info *)); - -extern int print_insn_big_mips PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_little_mips PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_i386 PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_m68k PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_z8001 PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_z8002 PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_h8300 PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_h8300h PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_h8500 PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_alpha PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_sparc PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_big_a29k PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_little_a29k PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_i960 PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_sh PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_hppa PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_m88k PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_big_powerpc PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_little_powerpc PARAMS ((bfd_vma, disassemble_info*)); -extern int print_insn_rs6000 PARAMS ((bfd_vma, disassemble_info*)); - -/* Fetch the disassembler for a given BFD, if that support is available. */ -extern disassembler_ftype disassembler PARAMS ((bfd *)); - - -/* This block of definitions is for particular callers who read instructions - into a buffer before calling the instruction decoder. */ - -/* Here is a function which callers may wish to use for read_memory_func. - It gets bytes from a buffer. */ -extern int buffer_read_memory - PARAMS ((bfd_vma, bfd_byte *, int, struct disassemble_info *)); - -/* This function goes with buffer_read_memory. - It prints a message using info->fprintf_func and info->stream. */ -extern void perror_memory PARAMS ((int, bfd_vma, struct disassemble_info *)); - - -/* Just print the address is hex. This is included for completeness even - though both GDB and objdump provide their own (to print symbolic - addresses). */ -extern void generic_print_address - PARAMS ((bfd_vma, struct disassemble_info *)); - -#define INIT_DISASSEMBLE_INFO(INFO, STREAM) \ - (INFO).fprintf_func = (fprintf_ftype)fprintf, \ - (INFO).stream = (STREAM), \ - (INFO).buffer = NULL, \ - (INFO).buffer_vma = 0, \ - (INFO).buffer_length = 0, \ - (INFO).read_memory_func = buffer_read_memory, \ - (INFO).memory_error_func = perror_memory, \ - (INFO).print_address_func = generic_print_address, \ - (INFO).insn_info_valid = 0 - - - - -/* This block of definitions is for calling the instruction decoders - from GDB. */ - -/* GDB--Like target_read_memory, but slightly different parameters. */ -extern int -dis_asm_read_memory PARAMS ((bfd_vma memaddr, bfd_byte *myaddr, int len, - disassemble_info *info)); - -/* GDB--Like memory_error with slightly different parameters. */ -extern void -dis_asm_memory_error - PARAMS ((int status, bfd_vma memaddr, disassemble_info *info)); - -/* GDB--Like print_address with slightly different parameters. */ -extern void -dis_asm_print_address PARAMS ((bfd_vma addr, disassemble_info *info)); - -#define GDB_INIT_DISASSEMBLE_INFO(INFO, STREAM) \ - (INFO).fprintf_func = (fprintf_ftype)fprintf_filtered, \ - (INFO).stream = (STREAM), \ - (INFO).read_memory_func = dis_asm_read_memory, \ - (INFO).memory_error_func = dis_asm_memory_error, \ - (INFO).print_address_func = dis_asm_print_address, \ - (INFO).insn_info_valid = 0 diff --git a/debugger/opcodes/dis-buf.c b/debugger/opcodes/dis-buf.c deleted file mode 100644 index d184b28405a..00000000000 --- a/debugger/opcodes/dis-buf.c +++ /dev/null @@ -1,70 +0,0 @@ -/* Disassemble from a buffer, for GNU. - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - -This program 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; either version 2 of the License, or -(at your option) any later version. - -This program 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 this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "dis-asm.h" -#include "sysdep.h" -#include - -/* Get LENGTH bytes from info's buffer, at target address memaddr. - Transfer them to myaddr. */ -int -buffer_read_memory (memaddr, myaddr, length, info) - bfd_vma memaddr; - bfd_byte *myaddr; - int length; - struct disassemble_info *info; -{ - if (memaddr < info->buffer_vma - || memaddr + length > info->buffer_vma + info->buffer_length) - /* Out of bounds. Use EIO because GDB uses it. */ - return EIO; - memcpy (myaddr, info->buffer + (memaddr - info->buffer_vma), length); - return 0; -} - -/* Print an error message. We can assume that this is in response to - an error return from buffer_read_memory. */ -void -perror_memory (status, memaddr, info) - int status; - bfd_vma memaddr; - struct disassemble_info *info; -{ - if (status != EIO) - /* Can't happen. */ - (*info->fprintf_func) (info->stream, "Unknown error %d\n", status); - else - /* Actually, address between memaddr and memaddr + len was - out of bounds. */ - (*info->fprintf_func) (info->stream, - "Address 0x%x is out of bounds.\n", memaddr); -} - -/* This could be in a separate file, to save miniscule amounts of space - in statically linked executables. */ - -/* Just print the address is hex. This is included for completeness even - though both GDB and objdump provide their own (to print symbolic - addresses). */ - -void -generic_print_address (addr, info) - bfd_vma addr; - struct disassemble_info *info; -{ - (*info->fprintf_func) (info->stream, "0x%x", addr); -} diff --git a/debugger/opcodes/i386-dis.c b/debugger/opcodes/i386-dis.c deleted file mode 100644 index 0d18311e6ae..00000000000 --- a/debugger/opcodes/i386-dis.c +++ /dev/null @@ -1,2010 +0,0 @@ -/* Print i386 instructions for GDB, the GNU debugger. - Copyright (C) 1988, 1989, 1991, 1993, 1994 Free Software Foundation, Inc. - -This file is part of GDB. - -This program 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; either version 2 of the License, or -(at your option) any later version. - -This program 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 this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * 80386 instruction printer by Pace Willisson (pace@prep.ai.mit.edu) - * July 1988 - * modified by John Hassey (hassey@dg-rtp.dg.com) - */ - -/* - * The main tables describing the instructions is essentially a copy - * of the "Opcode Map" chapter (Appendix A) of the Intel 80386 - * Programmers Manual. Usually, there is a capital letter, followed - * by a small letter. The capital letter tell the addressing mode, - * and the small letter tells about the operand size. Refer to - * the Intel manual for details. - */ - -#include "dis-asm.h" -#include "sysdep.h" - -#define MAXLEN 20 - -#include - -struct dis_private -{ - /* Points to first byte not fetched. */ - bfd_byte *max_fetched; - bfd_byte the_buffer[MAXLEN]; - bfd_vma insn_start; - jmp_buf bailout; -}; - -/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive) - to ADDR (exclusive) are valid. Returns 1 for success, longjmps - on error. */ -#define FETCH_DATA(info, addr) \ - ((addr) <= ((struct dis_private *)(info->private_data))->max_fetched \ - ? 1 : fetch_data ((info), (addr))) - -static int -fetch_data (info, addr) - struct disassemble_info *info; - bfd_byte *addr; -{ - int status; - struct dis_private *priv = (struct dis_private *)info->private_data; - bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer); - - status = (*info->read_memory_func) (start, - priv->max_fetched, - addr - priv->max_fetched, - info); - if (status != 0) - { - (*info->memory_error_func) (status, start, info); - longjmp (priv->bailout, 1); - } - else - priv->max_fetched = addr; - return 1; -} - -#define Eb OP_E, b_mode -#define indirEb OP_indirE, b_mode -#define Gb OP_G, b_mode -#define Ev OP_E, v_mode -#define indirEv OP_indirE, v_mode -#define Ew OP_E, w_mode -#define Ma OP_E, v_mode -#define M OP_E, 0 -#define Mp OP_E, 0 /* ? */ -#define Gv OP_G, v_mode -#define Gw OP_G, w_mode -#define Rw OP_rm, w_mode -#define Rd OP_rm, d_mode -#define Ib OP_I, b_mode -#define sIb OP_sI, b_mode /* sign extened byte */ -#define Iv OP_I, v_mode -#define Iw OP_I, w_mode -#define Jb OP_J, b_mode -#define Jv OP_J, v_mode -#define ONE OP_ONE, 0 -#define Cd OP_C, d_mode -#define Dd OP_D, d_mode -#define Td OP_T, d_mode - -#define eAX OP_REG, eAX_reg -#define eBX OP_REG, eBX_reg -#define eCX OP_REG, eCX_reg -#define eDX OP_REG, eDX_reg -#define eSP OP_REG, eSP_reg -#define eBP OP_REG, eBP_reg -#define eSI OP_REG, eSI_reg -#define eDI OP_REG, eDI_reg -#define AL OP_REG, al_reg -#define CL OP_REG, cl_reg -#define DL OP_REG, dl_reg -#define BL OP_REG, bl_reg -#define AH OP_REG, ah_reg -#define CH OP_REG, ch_reg -#define DH OP_REG, dh_reg -#define BH OP_REG, bh_reg -#define AX OP_REG, ax_reg -#define DX OP_REG, dx_reg -#define indirDX OP_REG, indir_dx_reg - -#define Sw OP_SEG, w_mode -#define Ap OP_DIR, lptr -#define Av OP_DIR, v_mode -#define Ob OP_OFF, b_mode -#define Ov OP_OFF, v_mode -#define Xb OP_DSSI, b_mode -#define Xv OP_DSSI, v_mode -#define Yb OP_ESDI, b_mode -#define Yv OP_ESDI, v_mode - -#define es OP_REG, es_reg -#define ss OP_REG, ss_reg -#define cs OP_REG, cs_reg -#define ds OP_REG, ds_reg -#define fs OP_REG, fs_reg -#define gs OP_REG, gs_reg - -int OP_E(), OP_indirE(), OP_G(), OP_I(), OP_sI(), OP_REG(); -int OP_J(), OP_SEG(); -int OP_DIR(), OP_OFF(), OP_DSSI(), OP_ESDI(), OP_ONE(), OP_C(); -int OP_D(), OP_T(), OP_rm(); - -static void dofloat (), putop (), append_prefix (), set_op (); -static int get16 (), get32 (); - -#define b_mode 1 -#define v_mode 2 -#define w_mode 3 -#define d_mode 4 - -#define es_reg 100 -#define cs_reg 101 -#define ss_reg 102 -#define ds_reg 103 -#define fs_reg 104 -#define gs_reg 105 -#define eAX_reg 107 -#define eCX_reg 108 -#define eDX_reg 109 -#define eBX_reg 110 -#define eSP_reg 111 -#define eBP_reg 112 -#define eSI_reg 113 -#define eDI_reg 114 - -#define lptr 115 - -#define al_reg 116 -#define cl_reg 117 -#define dl_reg 118 -#define bl_reg 119 -#define ah_reg 120 -#define ch_reg 121 -#define dh_reg 122 -#define bh_reg 123 - -#define ax_reg 124 -#define cx_reg 125 -#define dx_reg 126 -#define bx_reg 127 -#define sp_reg 128 -#define bp_reg 129 -#define si_reg 130 -#define di_reg 131 - -#define indir_dx_reg 150 - -#define GRP1b NULL, NULL, 0 -#define GRP1S NULL, NULL, 1 -#define GRP1Ss NULL, NULL, 2 -#define GRP2b NULL, NULL, 3 -#define GRP2S NULL, NULL, 4 -#define GRP2b_one NULL, NULL, 5 -#define GRP2S_one NULL, NULL, 6 -#define GRP2b_cl NULL, NULL, 7 -#define GRP2S_cl NULL, NULL, 8 -#define GRP3b NULL, NULL, 9 -#define GRP3S NULL, NULL, 10 -#define GRP4 NULL, NULL, 11 -#define GRP5 NULL, NULL, 12 -#define GRP6 NULL, NULL, 13 -#define GRP7 NULL, NULL, 14 -#define GRP8 NULL, NULL, 15 - -#define FLOATCODE 50 -#define FLOAT NULL, NULL, FLOATCODE - -struct dis386 { - char *name; - int (*op1)(); - int bytemode1; - int (*op2)(); - int bytemode2; - int (*op3)(); - int bytemode3; -}; - -struct dis386 dis386[] = { - /* 00 */ - { "addb", Eb, Gb }, - { "addS", Ev, Gv }, - { "addb", Gb, Eb }, - { "addS", Gv, Ev }, - { "addb", AL, Ib }, - { "addS", eAX, Iv }, - { "pushl", es }, - { "popl", es }, - /* 08 */ - { "orb", Eb, Gb }, - { "orS", Ev, Gv }, - { "orb", Gb, Eb }, - { "orS", Gv, Ev }, - { "orb", AL, Ib }, - { "orS", eAX, Iv }, - { "pushl", cs }, - { "(bad)" }, /* 0x0f extended opcode escape */ - /* 10 */ - { "adcb", Eb, Gb }, - { "adcS", Ev, Gv }, - { "adcb", Gb, Eb }, - { "adcS", Gv, Ev }, - { "adcb", AL, Ib }, - { "adcS", eAX, Iv }, - { "pushl", ss }, - { "popl", ss }, - /* 18 */ - { "sbbb", Eb, Gb }, - { "sbbS", Ev, Gv }, - { "sbbb", Gb, Eb }, - { "sbbS", Gv, Ev }, - { "sbbb", AL, Ib }, - { "sbbS", eAX, Iv }, - { "pushl", ds }, - { "popl", ds }, - /* 20 */ - { "andb", Eb, Gb }, - { "andS", Ev, Gv }, - { "andb", Gb, Eb }, - { "andS", Gv, Ev }, - { "andb", AL, Ib }, - { "andS", eAX, Iv }, - { "(bad)" }, /* SEG ES prefix */ - { "daa" }, - /* 28 */ - { "subb", Eb, Gb }, - { "subS", Ev, Gv }, - { "subb", Gb, Eb }, - { "subS", Gv, Ev }, - { "subb", AL, Ib }, - { "subS", eAX, Iv }, - { "(bad)" }, /* SEG CS prefix */ - { "das" }, - /* 30 */ - { "xorb", Eb, Gb }, - { "xorS", Ev, Gv }, - { "xorb", Gb, Eb }, - { "xorS", Gv, Ev }, - { "xorb", AL, Ib }, - { "xorS", eAX, Iv }, - { "(bad)" }, /* SEG SS prefix */ - { "aaa" }, - /* 38 */ - { "cmpb", Eb, Gb }, - { "cmpS", Ev, Gv }, - { "cmpb", Gb, Eb }, - { "cmpS", Gv, Ev }, - { "cmpb", AL, Ib }, - { "cmpS", eAX, Iv }, - { "(bad)" }, /* SEG DS prefix */ - { "aas" }, - /* 40 */ - { "incS", eAX }, - { "incS", eCX }, - { "incS", eDX }, - { "incS", eBX }, - { "incS", eSP }, - { "incS", eBP }, - { "incS", eSI }, - { "incS", eDI }, - /* 48 */ - { "decS", eAX }, - { "decS", eCX }, - { "decS", eDX }, - { "decS", eBX }, - { "decS", eSP }, - { "decS", eBP }, - { "decS", eSI }, - { "decS", eDI }, - /* 50 */ - { "pushS", eAX }, - { "pushS", eCX }, - { "pushS", eDX }, - { "pushS", eBX }, - { "pushS", eSP }, - { "pushS", eBP }, - { "pushS", eSI }, - { "pushS", eDI }, - /* 58 */ - { "popS", eAX }, - { "popS", eCX }, - { "popS", eDX }, - { "popS", eBX }, - { "popS", eSP }, - { "popS", eBP }, - { "popS", eSI }, - { "popS", eDI }, - /* 60 */ - { "pusha" }, - { "popa" }, - { "boundS", Gv, Ma }, - { "arpl", Ew, Gw }, - { "(bad)" }, /* seg fs */ - { "(bad)" }, /* seg gs */ - { "(bad)" }, /* op size prefix */ - { "(bad)" }, /* adr size prefix */ - /* 68 */ - { "pushS", Iv }, /* 386 book wrong */ - { "imulS", Gv, Ev, Iv }, - { "pushl", sIb }, /* push of byte really pushes 4 bytes */ - { "imulS", Gv, Ev, Ib }, - { "insb", Yb, indirDX }, - { "insS", Yv, indirDX }, - { "outsb", indirDX, Xb }, - { "outsS", indirDX, Xv }, - /* 70 */ - { "jo", Jb }, - { "jno", Jb }, - { "jb", Jb }, - { "jae", Jb }, - { "je", Jb }, - { "jne", Jb }, - { "jbe", Jb }, - { "ja", Jb }, - /* 78 */ - { "js", Jb }, - { "jns", Jb }, - { "jp", Jb }, - { "jnp", Jb }, - { "jl", Jb }, - { "jnl", Jb }, - { "jle", Jb }, - { "jg", Jb }, - /* 80 */ - { GRP1b }, - { GRP1S }, - { "(bad)" }, - { GRP1Ss }, - { "testb", Eb, Gb }, - { "testS", Ev, Gv }, - { "xchgb", Eb, Gb }, - { "xchgS", Ev, Gv }, - /* 88 */ - { "movb", Eb, Gb }, - { "movS", Ev, Gv }, - { "movb", Gb, Eb }, - { "movS", Gv, Ev }, - { "movw", Ew, Sw }, - { "leaS", Gv, M }, - { "movw", Sw, Ew }, - { "popS", Ev }, - /* 90 */ - { "nop" }, - { "xchgS", eCX, eAX }, - { "xchgS", eDX, eAX }, - { "xchgS", eBX, eAX }, - { "xchgS", eSP, eAX }, - { "xchgS", eBP, eAX }, - { "xchgS", eSI, eAX }, - { "xchgS", eDI, eAX }, - /* 98 */ - { "cwtl" }, - { "cltd" }, - { "lcall", Ap }, - { "(bad)" }, /* fwait */ - { "pushf" }, - { "popf" }, - { "sahf" }, - { "lahf" }, - /* a0 */ - { "movb", AL, Ob }, - { "movS", eAX, Ov }, - { "movb", Ob, AL }, - { "movS", Ov, eAX }, - { "movsb", Yb, Xb }, - { "movsS", Yv, Xv }, - { "cmpsb", Yb, Xb }, - { "cmpsS", Yv, Xv }, - /* a8 */ - { "testb", AL, Ib }, - { "testS", eAX, Iv }, - { "stosb", Yb, AL }, - { "stosS", Yv, eAX }, - { "lodsb", AL, Xb }, - { "lodsS", eAX, Xv }, - { "scasb", AL, Yb }, - { "scasS", eAX, Yv }, - /* b0 */ - { "movb", AL, Ib }, - { "movb", CL, Ib }, - { "movb", DL, Ib }, - { "movb", BL, Ib }, - { "movb", AH, Ib }, - { "movb", CH, Ib }, - { "movb", DH, Ib }, - { "movb", BH, Ib }, - /* b8 */ - { "movS", eAX, Iv }, - { "movS", eCX, Iv }, - { "movS", eDX, Iv }, - { "movS", eBX, Iv }, - { "movS", eSP, Iv }, - { "movS", eBP, Iv }, - { "movS", eSI, Iv }, - { "movS", eDI, Iv }, - /* c0 */ - { GRP2b }, - { GRP2S }, - { "ret", Iw }, - { "ret" }, - { "lesS", Gv, Mp }, - { "ldsS", Gv, Mp }, - { "movb", Eb, Ib }, - { "movS", Ev, Iv }, - /* c8 */ - { "enter", Iw, Ib }, - { "leave" }, - { "lret", Iw }, - { "lret" }, - { "int3" }, - { "int", Ib }, - { "into" }, - { "iret" }, - /* d0 */ - { GRP2b_one }, - { GRP2S_one }, - { GRP2b_cl }, - { GRP2S_cl }, - { "aam", Ib }, - { "aad", Ib }, - { "(bad)" }, - { "xlat" }, - /* d8 */ - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - /* e0 */ - { "loopne", Jb }, - { "loope", Jb }, - { "loop", Jb }, - { "jCcxz", Jb }, - { "inb", AL, Ib }, - { "inS", eAX, Ib }, - { "outb", Ib, AL }, - { "outS", Ib, eAX }, - /* e8 */ - { "call", Av }, - { "jmp", Jv }, - { "ljmp", Ap }, - { "jmp", Jb }, - { "inb", AL, indirDX }, - { "inS", eAX, indirDX }, - { "outb", indirDX, AL }, - { "outS", indirDX, eAX }, - /* f0 */ - { "(bad)" }, /* lock prefix */ - { "(bad)" }, - { "(bad)" }, /* repne */ - { "(bad)" }, /* repz */ - { "hlt" }, - { "cmc" }, - { GRP3b }, - { GRP3S }, - /* f8 */ - { "clc" }, - { "stc" }, - { "cli" }, - { "sti" }, - { "cld" }, - { "std" }, - { GRP4 }, - { GRP5 }, -}; - -struct dis386 dis386_twobyte[] = { - /* 00 */ - { GRP6 }, - { GRP7 }, - { "larS", Gv, Ew }, - { "lslS", Gv, Ew }, - { "(bad)" }, - { "(bad)" }, - { "clts" }, - { "(bad)" }, - /* 08 */ - { "invd" }, - { "wbinvd" }, - { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 10 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 18 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 20 */ - /* these are all backward in appendix A of the intel book */ - { "movl", Rd, Cd }, - { "movl", Rd, Dd }, - { "movl", Cd, Rd }, - { "movl", Dd, Rd }, - { "movl", Rd, Td }, - { "(bad)" }, - { "movl", Td, Rd }, - { "(bad)" }, - /* 28 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 30 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 38 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 40 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 48 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 50 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 58 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 60 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 68 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 70 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 78 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 80 */ - { "jo", Jv }, - { "jno", Jv }, - { "jb", Jv }, - { "jae", Jv }, - { "je", Jv }, - { "jne", Jv }, - { "jbe", Jv }, - { "ja", Jv }, - /* 88 */ - { "js", Jv }, - { "jns", Jv }, - { "jp", Jv }, - { "jnp", Jv }, - { "jl", Jv }, - { "jge", Jv }, - { "jle", Jv }, - { "jg", Jv }, - /* 90 */ - { "seto", Eb }, - { "setno", Eb }, - { "setb", Eb }, - { "setae", Eb }, - { "sete", Eb }, - { "setne", Eb }, - { "setbe", Eb }, - { "seta", Eb }, - /* 98 */ - { "sets", Eb }, - { "setns", Eb }, - { "setp", Eb }, - { "setnp", Eb }, - { "setl", Eb }, - { "setge", Eb }, - { "setle", Eb }, - { "setg", Eb }, - /* a0 */ - { "pushl", fs }, - { "popl", fs }, - { "(bad)" }, - { "btS", Ev, Gv }, - { "shldS", Ev, Gv, Ib }, - { "shldS", Ev, Gv, CL }, - { "(bad)" }, - { "(bad)" }, - /* a8 */ - { "pushl", gs }, - { "popl", gs }, - { "(bad)" }, - { "btsS", Ev, Gv }, - { "shrdS", Ev, Gv, Ib }, - { "shrdS", Ev, Gv, CL }, - { "(bad)" }, - { "imulS", Gv, Ev }, - /* b0 */ - { "cmpxchgb", Eb, Gb }, - { "cmpxchgS", Ev, Gv }, - { "lssS", Gv, Mp }, /* 386 lists only Mp */ - { "btrS", Ev, Gv }, - { "lfsS", Gv, Mp }, /* 386 lists only Mp */ - { "lgsS", Gv, Mp }, /* 386 lists only Mp */ - { "movzbS", Gv, Eb }, - { "movzwS", Gv, Ew }, - /* b8 */ - { "(bad)" }, - { "(bad)" }, - { GRP8 }, - { "btcS", Ev, Gv }, - { "bsfS", Gv, Ev }, - { "bsrS", Gv, Ev }, - { "movsbS", Gv, Eb }, - { "movswS", Gv, Ew }, - /* c0 */ - { "xaddb", Eb, Gb }, - { "xaddS", Ev, Gv }, - { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* c8 */ - { "bswap", eAX }, - { "bswap", eCX }, - { "bswap", eDX }, - { "bswap", eBX }, - { "bswap", eSP }, - { "bswap", eBP }, - { "bswap", eSI }, - { "bswap", eDI }, - /* d0 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* d8 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* e0 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* e8 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* f0 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* f8 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, -}; - -static char obuf[100]; -static char *obufp; -static char scratchbuf[100]; -static unsigned char *start_codep; -static unsigned char *codep; -static disassemble_info *the_info; -static int mod; -static int rm; -static int reg; -static void oappend (); - -static char *names32[]={ - "%eax","%ecx","%edx","%ebx", "%esp","%ebp","%esi","%edi", -}; -static char *names16[] = { - "%ax","%cx","%dx","%bx","%sp","%bp","%si","%di", -}; -static char *names8[] = { - "%al","%cl","%dl","%bl","%ah","%ch","%dh","%bh", -}; -static char *names_seg[] = { - "%es","%cs","%ss","%ds","%fs","%gs","%?","%?", -}; -static char *names_rmw[] = { - "%bx,%si","%bx,%di","%bp,%si","%bp,%di","%si","%di","%bp","%bx", -}; - -struct dis386 grps[][8] = { - /* GRP1b */ - { - { "addb", Eb, Ib }, - { "orb", Eb, Ib }, - { "adcb", Eb, Ib }, - { "sbbb", Eb, Ib }, - { "andb", Eb, Ib }, - { "subb", Eb, Ib }, - { "xorb", Eb, Ib }, - { "cmpb", Eb, Ib } - }, - /* GRP1S */ - { - { "addS", Ev, Iv }, - { "orS", Ev, Iv }, - { "adcS", Ev, Iv }, - { "sbbS", Ev, Iv }, - { "andS", Ev, Iv }, - { "subS", Ev, Iv }, - { "xorS", Ev, Iv }, - { "cmpS", Ev, Iv } - }, - /* GRP1Ss */ - { - { "addS", Ev, sIb }, - { "orS", Ev, sIb }, - { "adcS", Ev, sIb }, - { "sbbS", Ev, sIb }, - { "andS", Ev, sIb }, - { "subS", Ev, sIb }, - { "xorS", Ev, sIb }, - { "cmpS", Ev, sIb } - }, - /* GRP2b */ - { - { "rolb", Eb, Ib }, - { "rorb", Eb, Ib }, - { "rclb", Eb, Ib }, - { "rcrb", Eb, Ib }, - { "shlb", Eb, Ib }, - { "shrb", Eb, Ib }, - { "(bad)" }, - { "sarb", Eb, Ib }, - }, - /* GRP2S */ - { - { "rolS", Ev, Ib }, - { "rorS", Ev, Ib }, - { "rclS", Ev, Ib }, - { "rcrS", Ev, Ib }, - { "shlS", Ev, Ib }, - { "shrS", Ev, Ib }, - { "(bad)" }, - { "sarS", Ev, Ib }, - }, - /* GRP2b_one */ - { - { "rolb", Eb }, - { "rorb", Eb }, - { "rclb", Eb }, - { "rcrb", Eb }, - { "shlb", Eb }, - { "shrb", Eb }, - { "(bad)" }, - { "sarb", Eb }, - }, - /* GRP2S_one */ - { - { "rolS", Ev }, - { "rorS", Ev }, - { "rclS", Ev }, - { "rcrS", Ev }, - { "shlS", Ev }, - { "shrS", Ev }, - { "(bad)" }, - { "sarS", Ev }, - }, - /* GRP2b_cl */ - { - { "rolb", Eb, CL }, - { "rorb", Eb, CL }, - { "rclb", Eb, CL }, - { "rcrb", Eb, CL }, - { "shlb", Eb, CL }, - { "shrb", Eb, CL }, - { "(bad)" }, - { "sarb", Eb, CL }, - }, - /* GRP2S_cl */ - { - { "rolS", Ev, CL }, - { "rorS", Ev, CL }, - { "rclS", Ev, CL }, - { "rcrS", Ev, CL }, - { "shlS", Ev, CL }, - { "shrS", Ev, CL }, - { "(bad)" }, - { "sarS", Ev, CL } - }, - /* GRP3b */ - { - { "testb", Eb, Ib }, - { "(bad)", Eb }, - { "notb", Eb }, - { "negb", Eb }, - { "mulb", AL, Eb }, - { "imulb", AL, Eb }, - { "divb", AL, Eb }, - { "idivb", AL, Eb } - }, - /* GRP3S */ - { - { "testS", Ev, Iv }, - { "(bad)" }, - { "notS", Ev }, - { "negS", Ev }, - { "mulS", eAX, Ev }, - { "imulS", eAX, Ev }, - { "divS", eAX, Ev }, - { "idivS", eAX, Ev }, - }, - /* GRP4 */ - { - { "incb", Eb }, - { "decb", Eb }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - }, - /* GRP5 */ - { - { "incS", Ev }, - { "decS", Ev }, - { "call", indirEv }, - { "lcall", indirEv }, - { "jmp", indirEv }, - { "ljmp", indirEv }, - { "pushS", Ev }, - { "(bad)" }, - }, - /* GRP6 */ - { - { "sldt", Ew }, - { "str", Ew }, - { "lldt", Ew }, - { "ltr", Ew }, - { "verr", Ew }, - { "verw", Ew }, - { "(bad)" }, - { "(bad)" } - }, - /* GRP7 */ - { - { "sgdt", Ew }, - { "sidt", Ew }, - { "lgdt", Ew }, - { "lidt", Ew }, - { "smsw", Ew }, - { "(bad)" }, - { "lmsw", Ew }, - { "invlpg", Ew }, - }, - /* GRP8 */ - { - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "btS", Ev, Ib }, - { "btsS", Ev, Ib }, - { "btrS", Ev, Ib }, - { "btcS", Ev, Ib }, - } -}; - -#define PREFIX_REPZ 1 -#define PREFIX_REPNZ 2 -#define PREFIX_LOCK 4 -#define PREFIX_CS 8 -#define PREFIX_SS 0x10 -#define PREFIX_DS 0x20 -#define PREFIX_ES 0x40 -#define PREFIX_FS 0x80 -#define PREFIX_GS 0x100 -#define PREFIX_DATA 0x200 -#define PREFIX_ADR 0x400 -#define PREFIX_FWAIT 0x800 - -static int prefixes; - -static void -ckprefix () -{ - prefixes = 0; - while (1) - { - FETCH_DATA (the_info, codep + 1); - switch (*codep) - { - case 0xf3: - prefixes |= PREFIX_REPZ; - break; - case 0xf2: - prefixes |= PREFIX_REPNZ; - break; - case 0xf0: - prefixes |= PREFIX_LOCK; - break; - case 0x2e: - prefixes |= PREFIX_CS; - break; - case 0x36: - prefixes |= PREFIX_SS; - break; - case 0x3e: - prefixes |= PREFIX_DS; - break; - case 0x26: - prefixes |= PREFIX_ES; - break; - case 0x64: - prefixes |= PREFIX_FS; - break; - case 0x65: - prefixes |= PREFIX_GS; - break; - case 0x66: - prefixes |= PREFIX_DATA; - break; - case 0x67: - prefixes |= PREFIX_ADR; - break; - case 0x9b: - prefixes |= PREFIX_FWAIT; - break; - default: - return; - } - codep++; - } -} - -static int machine; -static int dflag; -static int aflag; - -static char op1out[100], op2out[100], op3out[100]; -static int op_address[3], op_ad, op_index[3]; -static int start_pc; - - -/* - * On the 386's of 1988, the maximum length of an instruction is 15 bytes. - * (see topic "Redundant prefixes" in the "Differences from 8086" - * section of the "Virtual 8086 Mode" chapter.) - * 'pc' should be the address of this instruction, it will - * be used to print the target address if this is a relative jump or call - * The function returns the length of this instruction in bytes. - */ -static int -print_insn_i286_or_i386 (pc, info) - bfd_vma pc; - disassemble_info *info; -{ - struct dis386 *dp; - int i; - int enter_instruction; - char *first, *second, *third; - int needcomma; - - struct dis_private priv; - bfd_byte *inbuf = priv.the_buffer; - - info->private_data = (PTR) &priv; - priv.max_fetched = priv.the_buffer; - priv.insn_start = pc; - if (setjmp (priv.bailout) != 0) - /* Error return. */ - return -1; - - obuf[0] = 0; - op1out[0] = 0; - op2out[0] = 0; - op3out[0] = 0; - - op_index[0] = op_index[1] = op_index[2] = -1; - - the_info = info; - start_pc = pc; - start_codep = inbuf; - codep = inbuf; - - ckprefix (); - - FETCH_DATA (info, codep + 1); - if (*codep == 0xc8) - enter_instruction = 1; - else - enter_instruction = 0; - - obufp = obuf; - - if (prefixes & PREFIX_REPZ) - oappend ("repz "); - if (prefixes & PREFIX_REPNZ) - oappend ("repnz "); - if (prefixes & PREFIX_LOCK) - oappend ("lock "); - - if ((prefixes & PREFIX_FWAIT) - && ((*codep < 0xd8) || (*codep > 0xdf))) - { - /* fwait not followed by floating point instruction */ - (*info->fprintf_func) (info->stream, "fwait"); - return (1); - } - - if (prefixes & PREFIX_DATA) - dflag ^= 1; - - if (prefixes & PREFIX_ADR) - { - aflag ^= 1; - oappend ("addr16 "); - } - - if (*codep == 0x0f) - { - FETCH_DATA (info, codep + 2); - dp = &dis386_twobyte[*++codep]; - } - else - dp = &dis386[*codep]; - codep++; - - /* Fetch the mod/reg/rm byte. FIXME: We should be only fetching - this if we need it. As it is, this code loses if there is a - one-byte instruction (without a mod/reg/rm byte) at the end of - the address space. */ - - FETCH_DATA (info, codep + 1); - mod = (*codep >> 6) & 3; - reg = (*codep >> 3) & 7; - rm = *codep & 7; - - if (dp->name == NULL && dp->bytemode1 == FLOATCODE) - { - dofloat (); - } - else - { - if (dp->name == NULL) - dp = &grps[dp->bytemode1][reg]; - - putop (dp->name); - - obufp = op1out; - op_ad = 2; - if (dp->op1) - (*dp->op1)(dp->bytemode1); - - obufp = op2out; - op_ad = 1; - if (dp->op2) - (*dp->op2)(dp->bytemode2); - - obufp = op3out; - op_ad = 0; - if (dp->op3) - (*dp->op3)(dp->bytemode3); - } - - obufp = obuf + strlen (obuf); - for (i = strlen (obuf); i < 6; i++) - oappend (" "); - oappend (" "); - (*info->fprintf_func) (info->stream, "%s", obuf); - - /* enter instruction is printed with operands in the - * same order as the intel book; everything else - * is printed in reverse order - */ - if (enter_instruction) - { - first = op1out; - second = op2out; - third = op3out; - op_ad = op_index[0]; - op_index[0] = op_index[2]; - op_index[2] = op_ad; - } - else - { - first = op3out; - second = op2out; - third = op1out; - } - needcomma = 0; - if (*first) - { - if (op_index[0] != -1) - (*info->print_address_func) (op_address[op_index[0]], info); - else - (*info->fprintf_func) (info->stream, "%s", first); - needcomma = 1; - } - if (*second) - { - if (needcomma) - (*info->fprintf_func) (info->stream, ","); - if (op_index[1] != -1) - (*info->print_address_func) (op_address[op_index[1]], info); - else - (*info->fprintf_func) (info->stream, "%s", second); - needcomma = 1; - } - if (*third) - { - if (needcomma) - (*info->fprintf_func) (info->stream, ","); - if (op_index[2] != -1) - (*info->print_address_func) (op_address[op_index[2]], info); - else - (*info->fprintf_func) (info->stream, "%s", third); - } - return (codep - inbuf); -} - -int -print_insn_i286 (pc, info) - bfd_vma pc; - disassemble_info *info; -{ - machine = 286; - dflag = 0; - aflag = 0; - return print_insn_i286_or_i386 (pc, info); -} - -int -print_insn_i386 (pc, info) - bfd_vma pc; - disassemble_info *info; -{ - machine = 386; - dflag = 1; - aflag = 1; - return print_insn_i286_or_i386 (pc, info, 36); -} - -char *float_mem[] = { - /* d8 */ - "fadds", - "fmuls", - "fcoms", - "fcomps", - "fsubs", - "fsubrs", - "fdivs", - "fdivrs", - /* d9 */ - "flds", - "(bad)", - "fsts", - "fstps", - "fldenv", - "fldcw", - "fNstenv", - "fNstcw", - /* da */ - "fiaddl", - "fimull", - "ficoml", - "ficompl", - "fisubl", - "fisubrl", - "fidivl", - "fidivrl", - /* db */ - "fildl", - "(bad)", - "fistl", - "fistpl", - "(bad)", - "fldt", - "(bad)", - "fstpt", - /* dc */ - "faddl", - "fmull", - "fcoml", - "fcompl", - "fsubl", - "fsubrl", - "fdivl", - "fdivrl", - /* dd */ - "fldl", - "(bad)", - "fstl", - "fstpl", - "frstor", - "(bad)", - "fNsave", - "fNstsw", - /* de */ - "fiadd", - "fimul", - "ficom", - "ficomp", - "fisub", - "fisubr", - "fidiv", - "fidivr", - /* df */ - "fild", - "(bad)", - "fist", - "fistp", - "fbld", - "fildll", - "fbstp", - "fistpll", -}; - -#define ST OP_ST, 0 -#define STi OP_STi, 0 -int OP_ST(), OP_STi(); - -#define FGRPd9_2 NULL, NULL, 0 -#define FGRPd9_4 NULL, NULL, 1 -#define FGRPd9_5 NULL, NULL, 2 -#define FGRPd9_6 NULL, NULL, 3 -#define FGRPd9_7 NULL, NULL, 4 -#define FGRPda_5 NULL, NULL, 5 -#define FGRPdb_4 NULL, NULL, 6 -#define FGRPde_3 NULL, NULL, 7 -#define FGRPdf_4 NULL, NULL, 8 - -struct dis386 float_reg[][8] = { - /* d8 */ - { - { "fadd", ST, STi }, - { "fmul", ST, STi }, - { "fcom", STi }, - { "fcomp", STi }, - { "fsub", ST, STi }, - { "fsubr", ST, STi }, - { "fdiv", ST, STi }, - { "fdivr", ST, STi }, - }, - /* d9 */ - { - { "fld", STi }, - { "fxch", STi }, - { FGRPd9_2 }, - { "(bad)" }, - { FGRPd9_4 }, - { FGRPd9_5 }, - { FGRPd9_6 }, - { FGRPd9_7 }, - }, - /* da */ - { - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { FGRPda_5 }, - { "(bad)" }, - { "(bad)" }, - }, - /* db */ - { - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { FGRPdb_4 }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - }, - /* dc */ - { - { "fadd", STi, ST }, - { "fmul", STi, ST }, - { "(bad)" }, - { "(bad)" }, - { "fsub", STi, ST }, - { "fsubr", STi, ST }, - { "fdiv", STi, ST }, - { "fdivr", STi, ST }, - }, - /* dd */ - { - { "ffree", STi }, - { "(bad)" }, - { "fst", STi }, - { "fstp", STi }, - { "fucom", STi }, - { "fucomp", STi }, - { "(bad)" }, - { "(bad)" }, - }, - /* de */ - { - { "faddp", STi, ST }, - { "fmulp", STi, ST }, - { "(bad)" }, - { FGRPde_3 }, - { "fsubp", STi, ST }, - { "fsubrp", STi, ST }, - { "fdivp", STi, ST }, - { "fdivrp", STi, ST }, - }, - /* df */ - { - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { FGRPdf_4 }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - }, -}; - - -char *fgrps[][8] = { - /* d9_2 0 */ - { - "fnop","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", - }, - - /* d9_4 1 */ - { - "fchs","fabs","(bad)","(bad)","ftst","fxam","(bad)","(bad)", - }, - - /* d9_5 2 */ - { - "fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","(bad)", - }, - - /* d9_6 3 */ - { - "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp", - }, - - /* d9_7 4 */ - { - "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos", - }, - - /* da_5 5 */ - { - "(bad)","fucompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", - }, - - /* db_4 6 */ - { - "feni(287 only)","fdisi(287 only)","fNclex","fNinit", - "fNsetpm(287 only)","(bad)","(bad)","(bad)", - }, - - /* de_3 7 */ - { - "(bad)","fcompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", - }, - - /* df_4 8 */ - { - "fNstsw","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", - }, -}; - -static void -dofloat () -{ - struct dis386 *dp; - unsigned char floatop; - - floatop = codep[-1]; - - if (mod != 3) - { - putop (float_mem[(floatop - 0xd8) * 8 + reg]); - obufp = op1out; - OP_E (v_mode); - return; - } - codep++; - - dp = &float_reg[floatop - 0xd8][reg]; - if (dp->name == NULL) - { - putop (fgrps[dp->bytemode1][rm]); - /* instruction fnstsw is only one with strange arg */ - if (floatop == 0xdf - && FETCH_DATA (the_info, codep + 1) - && *codep == 0xe0) - strcpy (op1out, "%eax"); - } - else - { - putop (dp->name); - obufp = op1out; - if (dp->op1) - (*dp->op1)(dp->bytemode1); - obufp = op2out; - if (dp->op2) - (*dp->op2)(dp->bytemode2); - } -} - -/* ARGSUSED */ -int -OP_ST (ignore) - int ignore; -{ - oappend ("%st"); - return (0); -} - -/* ARGSUSED */ -int -OP_STi (ignore) - int ignore; -{ - sprintf (scratchbuf, "%%st(%d)", rm); - oappend (scratchbuf); - return (0); -} - - -/* capital letters in template are macros */ -static void -putop (template) - char *template; -{ - char *p; - - for (p = template; *p; p++) - { - switch (*p) - { - default: - *obufp++ = *p; - break; - case 'C': /* For jcxz/jecxz */ - if (aflag == 0) - *obufp++ = 'e'; - break; - case 'N': - if ((prefixes & PREFIX_FWAIT) == 0) - *obufp++ = 'n'; - break; - case 'S': - /* operand size flag */ - if (dflag) - *obufp++ = 'l'; - else - *obufp++ = 'w'; - break; - } - } - *obufp = 0; -} - -static void -oappend (s) - char *s; -{ - strcpy (obufp, s); - obufp += strlen (s); - *obufp = 0; -} - -static void -append_prefix () -{ - if (prefixes & PREFIX_CS) - oappend ("%cs:"); - if (prefixes & PREFIX_DS) - oappend ("%ds:"); - if (prefixes & PREFIX_SS) - oappend ("%ss:"); - if (prefixes & PREFIX_ES) - oappend ("%es:"); - if (prefixes & PREFIX_FS) - oappend ("%fs:"); - if (prefixes & PREFIX_GS) - oappend ("%gs:"); -} - -int -OP_indirE (bytemode) - int bytemode; -{ - oappend ("*"); - OP_E (bytemode); - return (0); -} - -int -OP_E (bytemode) - int bytemode; -{ - int disp; - int havesib; - int base; - int index; - int scale; - int havebase; - - /* skip mod/rm byte */ - codep++; - - havesib = 0; - havebase = 0; - disp = 0; - - if (mod == 3) - { - switch (bytemode) - { - case b_mode: - oappend (names8[rm]); - break; - case w_mode: - oappend (names16[rm]); - break; - case v_mode: - if (dflag) - oappend (names32[rm]); - else - oappend (names16[rm]); - break; - default: - oappend (""); - break; - } - return (0); - } - - append_prefix (); - - if (machine == 286) - { - if (mod == 0 && rm == 6) - { - sprintf (scratchbuf, "0x%04x", get16 ()); - oappend (scratchbuf); - return 0; - } - - if (mod == 1) - { - FETCH_DATA (the_info, codep + 1); - disp = *(char *)codep++; - } - else if (mod == 2) - disp = get16 (); - else - disp = 0; - if (disp != 0) - { - sprintf (scratchbuf, "0x%x", disp & 0xffff); - oappend (scratchbuf); - } - - sprintf (scratchbuf, "(%s)", names_rmw[rm]); - oappend (scratchbuf); - return 0; - } - - if (rm == 4) - { - havesib = 1; - havebase = 1; - FETCH_DATA (the_info, codep + 1); - scale = (*codep >> 6) & 3; - index = (*codep >> 3) & 7; - base = *codep & 7; - codep++; - } - - switch (mod) - { - case 0: - switch (rm) - { - case 4: - /* implies havesib and havebase */ - if (base == 5) { - havebase = 0; - disp = get32 (); - } - break; - case 5: - disp = get32 (); - break; - default: - havebase = 1; - base = rm; - break; - } - break; - case 1: - FETCH_DATA (the_info, codep + 1); - disp = *(char *)codep++; - if (rm != 4) - { - havebase = 1; - base = rm; - } - break; - case 2: - disp = get32 (); - if (rm != 4) - { - havebase = 1; - base = rm; - } - break; - } - - if (mod != 0 || rm == 5 || (havesib && base == 5)) - { - sprintf (scratchbuf, "0x%x", disp); - oappend (scratchbuf); - } - - if (havebase || havesib) - { - oappend ("("); - if (havebase) - oappend (names32[base]); - if (havesib) - { - if (index != 4) - { - sprintf (scratchbuf, ",%s", names32[index]); - oappend (scratchbuf); - } - sprintf (scratchbuf, ",%d", 1 << scale); - oappend (scratchbuf); - } - oappend (")"); - } - return (0); -} - -int -OP_G (bytemode) - int bytemode; -{ - switch (bytemode) - { - case b_mode: - oappend (names8[reg]); - break; - case w_mode: - oappend (names16[reg]); - break; - case d_mode: - oappend (names32[reg]); - break; - case v_mode: - if (dflag) - oappend (names32[reg]); - else - oappend (names16[reg]); - break; - default: - oappend (""); - break; - } - return (0); -} - -static int -get32 () -{ - int x = 0; - - FETCH_DATA (the_info, codep + 4); - x = *codep++ & 0xff; - x |= (*codep++ & 0xff) << 8; - x |= (*codep++ & 0xff) << 16; - x |= (*codep++ & 0xff) << 24; - return (x); -} - -static int -get16 () -{ - int x = 0; - - FETCH_DATA (the_info, codep + 2); - x = *codep++ & 0xff; - x |= (*codep++ & 0xff) << 8; - return (x); -} - -static void -set_op (op) - int op; -{ - op_index[op_ad] = op_ad; - op_address[op_ad] = op; -} - -int -OP_REG (code) - int code; -{ - char *s; - - switch (code) - { - case indir_dx_reg: s = "(%dx)"; break; - case ax_reg: case cx_reg: case dx_reg: case bx_reg: - case sp_reg: case bp_reg: case si_reg: case di_reg: - s = names16[code - ax_reg]; - break; - case es_reg: case ss_reg: case cs_reg: - case ds_reg: case fs_reg: case gs_reg: - s = names_seg[code - es_reg]; - break; - case al_reg: case ah_reg: case cl_reg: case ch_reg: - case dl_reg: case dh_reg: case bl_reg: case bh_reg: - s = names8[code - al_reg]; - break; - case eAX_reg: case eCX_reg: case eDX_reg: case eBX_reg: - case eSP_reg: case eBP_reg: case eSI_reg: case eDI_reg: - if (dflag) - s = names32[code - eAX_reg]; - else - s = names16[code - eAX_reg]; - break; - default: - s = ""; - break; - } - oappend (s); - return (0); -} - -int -OP_I (bytemode) - int bytemode; -{ - int op; - - switch (bytemode) - { - case b_mode: - FETCH_DATA (the_info, codep + 1); - op = *codep++ & 0xff; - break; - case v_mode: - if (dflag) - op = get32 (); - else - op = get16 (); - break; - case w_mode: - op = get16 (); - break; - default: - oappend (""); - return (0); - } - sprintf (scratchbuf, "$0x%x", op); - oappend (scratchbuf); - return (0); -} - -int -OP_sI (bytemode) - int bytemode; -{ - int op; - - switch (bytemode) - { - case b_mode: - FETCH_DATA (the_info, codep + 1); - op = *(char *)codep++; - break; - case v_mode: - if (dflag) - op = get32 (); - else - op = (short)get16(); - break; - case w_mode: - op = (short)get16 (); - break; - default: - oappend (""); - return (0); - } - sprintf (scratchbuf, "$0x%x", op); - oappend (scratchbuf); - return (0); -} - -int -OP_J (bytemode) - int bytemode; -{ - int disp; - int mask = -1; - - switch (bytemode) - { - case b_mode: - FETCH_DATA (the_info, codep + 1); - disp = *(char *)codep++; - break; - case v_mode: - if (dflag) - disp = get32 (); - else - { - disp = (short)get16 (); - /* for some reason, a data16 prefix on a jump instruction - means that the pc is masked to 16 bits after the - displacement is added! */ - mask = 0xffff; - } - break; - default: - oappend (""); - return (0); - } - disp = (start_pc + codep - start_codep + disp) & mask; - set_op (disp); - sprintf (scratchbuf, "0x%x", disp); - oappend (scratchbuf); - return (0); -} - -/* ARGSUSED */ -int -OP_SEG (dummy) - int dummy; -{ - static char *sreg[] = { - "%es","%cs","%ss","%ds","%fs","%gs","%?","%?", - }; - - oappend (sreg[reg]); - return (0); -} - -int -OP_DIR (size) - int size; -{ - int seg, offset; - - switch (size) - { - case lptr: - if (aflag) - { - offset = get32 (); - seg = get16 (); - } - else - { - offset = get16 (); - seg = get16 (); - } - sprintf (scratchbuf, "0x%x,0x%x", seg, offset); - oappend (scratchbuf); - break; - case v_mode: - if (aflag) - offset = get32 (); - else - offset = (short)get16 (); - - offset = start_pc + codep - start_codep + offset; - set_op (offset); - sprintf (scratchbuf, "0x%x", offset); - oappend (scratchbuf); - break; - default: - oappend (""); - break; - } - return (0); -} - -/* ARGSUSED */ -int -OP_OFF (bytemode) - int bytemode; -{ - int off; - - if (aflag) - off = get32 (); - else - off = get16 (); - - sprintf (scratchbuf, "0x%x", off); - oappend (scratchbuf); - return (0); -} - -/* ARGSUSED */ -int -OP_ESDI (dummy) - int dummy; -{ - oappend ("%es:("); - oappend (aflag ? "%edi" : "%di"); - oappend (")"); - return (0); -} - -/* ARGSUSED */ -int -OP_DSSI (dummy) - int dummy; -{ - oappend ("%ds:("); - oappend (aflag ? "%esi" : "%si"); - oappend (")"); - return (0); -} - -/* ARGSUSED */ -int -OP_ONE (dummy) - int dummy; -{ - oappend ("1"); - return (0); -} - -/* ARGSUSED */ -int -OP_C (dummy) - int dummy; -{ - codep++; /* skip mod/rm */ - sprintf (scratchbuf, "%%cr%d", reg); - oappend (scratchbuf); - return (0); -} - -/* ARGSUSED */ -int -OP_D (dummy) - int dummy; -{ - codep++; /* skip mod/rm */ - sprintf (scratchbuf, "%%db%d", reg); - oappend (scratchbuf); - return (0); -} - -/* ARGSUSED */ -int -OP_T (dummy) - int dummy; -{ - codep++; /* skip mod/rm */ - sprintf (scratchbuf, "%%tr%d", reg); - oappend (scratchbuf); - return (0); -} - -int -OP_rm (bytemode) - int bytemode; -{ - switch (bytemode) - { - case d_mode: - oappend (names32[rm]); - break; - case w_mode: - oappend (names16[rm]); - break; - } - return (0); -} diff --git a/debugger/opcodes/i386-dis.c-fsf b/debugger/opcodes/i386-dis.c-fsf deleted file mode 100644 index 7f9641dc156..00000000000 --- a/debugger/opcodes/i386-dis.c-fsf +++ /dev/null @@ -1,1959 +0,0 @@ -/* Print i386 instructions for GDB, the GNU debugger. - Copyright (C) 1988, 1989, 1991, 1993, 1994 Free Software Foundation, Inc. - -This file is part of GDB. - -This program 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; either version 2 of the License, or -(at your option) any later version. - -This program 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 this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * 80386 instruction printer by Pace Willisson (pace@prep.ai.mit.edu) - * July 1988 - * modified by John Hassey (hassey@dg-rtp.dg.com) - */ - -/* - * The main tables describing the instructions is essentially a copy - * of the "Opcode Map" chapter (Appendix A) of the Intel 80386 - * Programmers Manual. Usually, there is a capital letter, followed - * by a small letter. The capital letter tell the addressing mode, - * and the small letter tells about the operand size. Refer to - * the Intel manual for details. - */ - -#include "dis-asm.h" -#include "sysdep.h" - -#define MAXLEN 20 - -#include - -struct dis_private -{ - /* Points to first byte not fetched. */ - bfd_byte *max_fetched; - bfd_byte the_buffer[MAXLEN]; - bfd_vma insn_start; - jmp_buf bailout; -}; - -/* Make sure that bytes from INFO->PRIVATE_DATA->BUFFER (inclusive) - to ADDR (exclusive) are valid. Returns 1 for success, longjmps - on error. */ -#define FETCH_DATA(info, addr) \ - ((addr) <= ((struct dis_private *)(info->private_data))->max_fetched \ - ? 1 : fetch_data ((info), (addr))) - -static int -fetch_data (info, addr) - struct disassemble_info *info; - bfd_byte *addr; -{ - int status; - struct dis_private *priv = (struct dis_private *)info->private_data; - bfd_vma start = priv->insn_start + (priv->max_fetched - priv->the_buffer); - - status = (*info->read_memory_func) (start, - priv->max_fetched, - addr - priv->max_fetched, - info); - if (status != 0) - { - (*info->memory_error_func) (status, start, info); - longjmp (priv->bailout, 1); - } - else - priv->max_fetched = addr; - return 1; -} - -#define Eb OP_E, b_mode -#define indirEb OP_indirE, b_mode -#define Gb OP_G, b_mode -#define Ev OP_E, v_mode -#define indirEv OP_indirE, v_mode -#define Ew OP_E, w_mode -#define Ma OP_E, v_mode -#define M OP_E, 0 -#define Mp OP_E, 0 /* ? */ -#define Gv OP_G, v_mode -#define Gw OP_G, w_mode -#define Rw OP_rm, w_mode -#define Rd OP_rm, d_mode -#define Ib OP_I, b_mode -#define sIb OP_sI, b_mode /* sign extened byte */ -#define Iv OP_I, v_mode -#define Iw OP_I, w_mode -#define Jb OP_J, b_mode -#define Jv OP_J, v_mode -#define ONE OP_ONE, 0 -#define Cd OP_C, d_mode -#define Dd OP_D, d_mode -#define Td OP_T, d_mode - -#define eAX OP_REG, eAX_reg -#define eBX OP_REG, eBX_reg -#define eCX OP_REG, eCX_reg -#define eDX OP_REG, eDX_reg -#define eSP OP_REG, eSP_reg -#define eBP OP_REG, eBP_reg -#define eSI OP_REG, eSI_reg -#define eDI OP_REG, eDI_reg -#define AL OP_REG, al_reg -#define CL OP_REG, cl_reg -#define DL OP_REG, dl_reg -#define BL OP_REG, bl_reg -#define AH OP_REG, ah_reg -#define CH OP_REG, ch_reg -#define DH OP_REG, dh_reg -#define BH OP_REG, bh_reg -#define AX OP_REG, ax_reg -#define DX OP_REG, dx_reg -#define indirDX OP_REG, indir_dx_reg - -#define Sw OP_SEG, w_mode -#define Ap OP_DIR, lptr -#define Av OP_DIR, v_mode -#define Ob OP_OFF, b_mode -#define Ov OP_OFF, v_mode -#define Xb OP_DSSI, b_mode -#define Xv OP_DSSI, v_mode -#define Yb OP_ESDI, b_mode -#define Yv OP_ESDI, v_mode - -#define es OP_REG, es_reg -#define ss OP_REG, ss_reg -#define cs OP_REG, cs_reg -#define ds OP_REG, ds_reg -#define fs OP_REG, fs_reg -#define gs OP_REG, gs_reg - -int OP_E(), OP_indirE(), OP_G(), OP_I(), OP_sI(), OP_REG(); -int OP_J(), OP_SEG(); -int OP_DIR(), OP_OFF(), OP_DSSI(), OP_ESDI(), OP_ONE(), OP_C(); -int OP_D(), OP_T(), OP_rm(); - -static void dofloat (), putop (), append_prefix (), set_op (); -static int get16 (), get32 (); - -#define b_mode 1 -#define v_mode 2 -#define w_mode 3 -#define d_mode 4 - -#define es_reg 100 -#define cs_reg 101 -#define ss_reg 102 -#define ds_reg 103 -#define fs_reg 104 -#define gs_reg 105 -#define eAX_reg 107 -#define eCX_reg 108 -#define eDX_reg 109 -#define eBX_reg 110 -#define eSP_reg 111 -#define eBP_reg 112 -#define eSI_reg 113 -#define eDI_reg 114 - -#define lptr 115 - -#define al_reg 116 -#define cl_reg 117 -#define dl_reg 118 -#define bl_reg 119 -#define ah_reg 120 -#define ch_reg 121 -#define dh_reg 122 -#define bh_reg 123 - -#define ax_reg 124 -#define cx_reg 125 -#define dx_reg 126 -#define bx_reg 127 -#define sp_reg 128 -#define bp_reg 129 -#define si_reg 130 -#define di_reg 131 - -#define indir_dx_reg 150 - -#define GRP1b NULL, NULL, 0 -#define GRP1S NULL, NULL, 1 -#define GRP1Ss NULL, NULL, 2 -#define GRP2b NULL, NULL, 3 -#define GRP2S NULL, NULL, 4 -#define GRP2b_one NULL, NULL, 5 -#define GRP2S_one NULL, NULL, 6 -#define GRP2b_cl NULL, NULL, 7 -#define GRP2S_cl NULL, NULL, 8 -#define GRP3b NULL, NULL, 9 -#define GRP3S NULL, NULL, 10 -#define GRP4 NULL, NULL, 11 -#define GRP5 NULL, NULL, 12 -#define GRP6 NULL, NULL, 13 -#define GRP7 NULL, NULL, 14 -#define GRP8 NULL, NULL, 15 - -#define FLOATCODE 50 -#define FLOAT NULL, NULL, FLOATCODE - -struct dis386 { - char *name; - int (*op1)(); - int bytemode1; - int (*op2)(); - int bytemode2; - int (*op3)(); - int bytemode3; -}; - -struct dis386 dis386[] = { - /* 00 */ - { "addb", Eb, Gb }, - { "addS", Ev, Gv }, - { "addb", Gb, Eb }, - { "addS", Gv, Ev }, - { "addb", AL, Ib }, - { "addS", eAX, Iv }, - { "pushl", es }, - { "popl", es }, - /* 08 */ - { "orb", Eb, Gb }, - { "orS", Ev, Gv }, - { "orb", Gb, Eb }, - { "orS", Gv, Ev }, - { "orb", AL, Ib }, - { "orS", eAX, Iv }, - { "pushl", cs }, - { "(bad)" }, /* 0x0f extended opcode escape */ - /* 10 */ - { "adcb", Eb, Gb }, - { "adcS", Ev, Gv }, - { "adcb", Gb, Eb }, - { "adcS", Gv, Ev }, - { "adcb", AL, Ib }, - { "adcS", eAX, Iv }, - { "pushl", ss }, - { "popl", ss }, - /* 18 */ - { "sbbb", Eb, Gb }, - { "sbbS", Ev, Gv }, - { "sbbb", Gb, Eb }, - { "sbbS", Gv, Ev }, - { "sbbb", AL, Ib }, - { "sbbS", eAX, Iv }, - { "pushl", ds }, - { "popl", ds }, - /* 20 */ - { "andb", Eb, Gb }, - { "andS", Ev, Gv }, - { "andb", Gb, Eb }, - { "andS", Gv, Ev }, - { "andb", AL, Ib }, - { "andS", eAX, Iv }, - { "(bad)" }, /* SEG ES prefix */ - { "daa" }, - /* 28 */ - { "subb", Eb, Gb }, - { "subS", Ev, Gv }, - { "subb", Gb, Eb }, - { "subS", Gv, Ev }, - { "subb", AL, Ib }, - { "subS", eAX, Iv }, - { "(bad)" }, /* SEG CS prefix */ - { "das" }, - /* 30 */ - { "xorb", Eb, Gb }, - { "xorS", Ev, Gv }, - { "xorb", Gb, Eb }, - { "xorS", Gv, Ev }, - { "xorb", AL, Ib }, - { "xorS", eAX, Iv }, - { "(bad)" }, /* SEG SS prefix */ - { "aaa" }, - /* 38 */ - { "cmpb", Eb, Gb }, - { "cmpS", Ev, Gv }, - { "cmpb", Gb, Eb }, - { "cmpS", Gv, Ev }, - { "cmpb", AL, Ib }, - { "cmpS", eAX, Iv }, - { "(bad)" }, /* SEG DS prefix */ - { "aas" }, - /* 40 */ - { "incS", eAX }, - { "incS", eCX }, - { "incS", eDX }, - { "incS", eBX }, - { "incS", eSP }, - { "incS", eBP }, - { "incS", eSI }, - { "incS", eDI }, - /* 48 */ - { "decS", eAX }, - { "decS", eCX }, - { "decS", eDX }, - { "decS", eBX }, - { "decS", eSP }, - { "decS", eBP }, - { "decS", eSI }, - { "decS", eDI }, - /* 50 */ - { "pushS", eAX }, - { "pushS", eCX }, - { "pushS", eDX }, - { "pushS", eBX }, - { "pushS", eSP }, - { "pushS", eBP }, - { "pushS", eSI }, - { "pushS", eDI }, - /* 58 */ - { "popS", eAX }, - { "popS", eCX }, - { "popS", eDX }, - { "popS", eBX }, - { "popS", eSP }, - { "popS", eBP }, - { "popS", eSI }, - { "popS", eDI }, - /* 60 */ - { "pusha" }, - { "popa" }, - { "boundS", Gv, Ma }, - { "arpl", Ew, Gw }, - { "(bad)" }, /* seg fs */ - { "(bad)" }, /* seg gs */ - { "(bad)" }, /* op size prefix */ - { "(bad)" }, /* adr size prefix */ - /* 68 */ - { "pushS", Iv }, /* 386 book wrong */ - { "imulS", Gv, Ev, Iv }, - { "pushl", sIb }, /* push of byte really pushes 4 bytes */ - { "imulS", Gv, Ev, Ib }, - { "insb", Yb, indirDX }, - { "insS", Yv, indirDX }, - { "outsb", indirDX, Xb }, - { "outsS", indirDX, Xv }, - /* 70 */ - { "jo", Jb }, - { "jno", Jb }, - { "jb", Jb }, - { "jae", Jb }, - { "je", Jb }, - { "jne", Jb }, - { "jbe", Jb }, - { "ja", Jb }, - /* 78 */ - { "js", Jb }, - { "jns", Jb }, - { "jp", Jb }, - { "jnp", Jb }, - { "jl", Jb }, - { "jnl", Jb }, - { "jle", Jb }, - { "jg", Jb }, - /* 80 */ - { GRP1b }, - { GRP1S }, - { "(bad)" }, - { GRP1Ss }, - { "testb", Eb, Gb }, - { "testS", Ev, Gv }, - { "xchgb", Eb, Gb }, - { "xchgS", Ev, Gv }, - /* 88 */ - { "movb", Eb, Gb }, - { "movS", Ev, Gv }, - { "movb", Gb, Eb }, - { "movS", Gv, Ev }, - { "movw", Ew, Sw }, - { "leaS", Gv, M }, - { "movw", Sw, Ew }, - { "popS", Ev }, - /* 90 */ - { "nop" }, - { "xchgS", eCX, eAX }, - { "xchgS", eDX, eAX }, - { "xchgS", eBX, eAX }, - { "xchgS", eSP, eAX }, - { "xchgS", eBP, eAX }, - { "xchgS", eSI, eAX }, - { "xchgS", eDI, eAX }, - /* 98 */ - { "cwtl" }, - { "cltd" }, - { "lcall", Ap }, - { "(bad)" }, /* fwait */ - { "pushf" }, - { "popf" }, - { "sahf" }, - { "lahf" }, - /* a0 */ - { "movb", AL, Ob }, - { "movS", eAX, Ov }, - { "movb", Ob, AL }, - { "movS", Ov, eAX }, - { "movsb", Yb, Xb }, - { "movsS", Yv, Xv }, - { "cmpsb", Yb, Xb }, - { "cmpsS", Yv, Xv }, - /* a8 */ - { "testb", AL, Ib }, - { "testS", eAX, Iv }, - { "stosb", Yb, AL }, - { "stosS", Yv, eAX }, - { "lodsb", AL, Xb }, - { "lodsS", eAX, Xv }, - { "scasb", AL, Yb }, - { "scasS", eAX, Yv }, - /* b0 */ - { "movb", AL, Ib }, - { "movb", CL, Ib }, - { "movb", DL, Ib }, - { "movb", BL, Ib }, - { "movb", AH, Ib }, - { "movb", CH, Ib }, - { "movb", DH, Ib }, - { "movb", BH, Ib }, - /* b8 */ - { "movS", eAX, Iv }, - { "movS", eCX, Iv }, - { "movS", eDX, Iv }, - { "movS", eBX, Iv }, - { "movS", eSP, Iv }, - { "movS", eBP, Iv }, - { "movS", eSI, Iv }, - { "movS", eDI, Iv }, - /* c0 */ - { GRP2b }, - { GRP2S }, - { "ret", Iw }, - { "ret" }, - { "lesS", Gv, Mp }, - { "ldsS", Gv, Mp }, - { "movb", Eb, Ib }, - { "movS", Ev, Iv }, - /* c8 */ - { "enter", Iw, Ib }, - { "leave" }, - { "lret", Iw }, - { "lret" }, - { "int3" }, - { "int", Ib }, - { "into" }, - { "iret" }, - /* d0 */ - { GRP2b_one }, - { GRP2S_one }, - { GRP2b_cl }, - { GRP2S_cl }, - { "aam", Ib }, - { "aad", Ib }, - { "(bad)" }, - { "xlat" }, - /* d8 */ - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - /* e0 */ - { "loopne", Jb }, - { "loope", Jb }, - { "loop", Jb }, - { "jCcxz", Jb }, - { "inb", AL, Ib }, - { "inS", eAX, Ib }, - { "outb", Ib, AL }, - { "outS", Ib, eAX }, - /* e8 */ - { "call", Av }, - { "jmp", Jv }, - { "ljmp", Ap }, - { "jmp", Jb }, - { "inb", AL, indirDX }, - { "inS", eAX, indirDX }, - { "outb", indirDX, AL }, - { "outS", indirDX, eAX }, - /* f0 */ - { "(bad)" }, /* lock prefix */ - { "(bad)" }, - { "(bad)" }, /* repne */ - { "(bad)" }, /* repz */ - { "hlt" }, - { "cmc" }, - { GRP3b }, - { GRP3S }, - /* f8 */ - { "clc" }, - { "stc" }, - { "cli" }, - { "sti" }, - { "cld" }, - { "std" }, - { GRP4 }, - { GRP5 }, -}; - -struct dis386 dis386_twobyte[] = { - /* 00 */ - { GRP6 }, - { GRP7 }, - { "larS", Gv, Ew }, - { "lslS", Gv, Ew }, - { "(bad)" }, - { "(bad)" }, - { "clts" }, - { "(bad)" }, - /* 08 */ - { "invd" }, - { "wbinvd" }, - { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 10 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 18 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 20 */ - /* these are all backward in appendix A of the intel book */ - { "movl", Rd, Cd }, - { "movl", Rd, Dd }, - { "movl", Cd, Rd }, - { "movl", Dd, Rd }, - { "movl", Rd, Td }, - { "(bad)" }, - { "movl", Td, Rd }, - { "(bad)" }, - /* 28 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 30 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 38 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 40 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 48 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 50 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 58 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 60 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 68 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 70 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 78 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 80 */ - { "jo", Jv }, - { "jno", Jv }, - { "jb", Jv }, - { "jae", Jv }, - { "je", Jv }, - { "jne", Jv }, - { "jbe", Jv }, - { "ja", Jv }, - /* 88 */ - { "js", Jv }, - { "jns", Jv }, - { "jp", Jv }, - { "jnp", Jv }, - { "jl", Jv }, - { "jge", Jv }, - { "jle", Jv }, - { "jg", Jv }, - /* 90 */ - { "seto", Eb }, - { "setno", Eb }, - { "setb", Eb }, - { "setae", Eb }, - { "sete", Eb }, - { "setne", Eb }, - { "setbe", Eb }, - { "seta", Eb }, - /* 98 */ - { "sets", Eb }, - { "setns", Eb }, - { "setp", Eb }, - { "setnp", Eb }, - { "setl", Eb }, - { "setge", Eb }, - { "setle", Eb }, - { "setg", Eb }, - /* a0 */ - { "pushl", fs }, - { "popl", fs }, - { "(bad)" }, - { "btS", Ev, Gv }, - { "shldS", Ev, Gv, Ib }, - { "shldS", Ev, Gv, CL }, - { "(bad)" }, - { "(bad)" }, - /* a8 */ - { "pushl", gs }, - { "popl", gs }, - { "(bad)" }, - { "btsS", Ev, Gv }, - { "shrdS", Ev, Gv, Ib }, - { "shrdS", Ev, Gv, CL }, - { "(bad)" }, - { "imulS", Gv, Ev }, - /* b0 */ - { "cmpxchgb", Eb, Gb }, - { "cmpxchgS", Ev, Gv }, - { "lssS", Gv, Mp }, /* 386 lists only Mp */ - { "btrS", Ev, Gv }, - { "lfsS", Gv, Mp }, /* 386 lists only Mp */ - { "lgsS", Gv, Mp }, /* 386 lists only Mp */ - { "movzbS", Gv, Eb }, - { "movzwS", Gv, Ew }, - /* b8 */ - { "(bad)" }, - { "(bad)" }, - { GRP8 }, - { "btcS", Ev, Gv }, - { "bsfS", Gv, Ev }, - { "bsrS", Gv, Ev }, - { "movsbS", Gv, Eb }, - { "movswS", Gv, Ew }, - /* c0 */ - { "xaddb", Eb, Gb }, - { "xaddS", Ev, Gv }, - { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* c8 */ - { "bswap", eAX }, - { "bswap", eCX }, - { "bswap", eDX }, - { "bswap", eBX }, - { "bswap", eSP }, - { "bswap", eBP }, - { "bswap", eSI }, - { "bswap", eDI }, - /* d0 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* d8 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* e0 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* e8 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* f0 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* f8 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, -}; - -static char obuf[100]; -static char *obufp; -static char scratchbuf[100]; -static unsigned char *start_codep; -static unsigned char *codep; -static disassemble_info *the_info; -static int mod; -static int rm; -static int reg; -static void oappend (); - -static char *names32[]={ - "%eax","%ecx","%edx","%ebx", "%esp","%ebp","%esi","%edi", -}; -static char *names16[] = { - "%ax","%cx","%dx","%bx","%sp","%bp","%si","%di", -}; -static char *names8[] = { - "%al","%cl","%dl","%bl","%ah","%ch","%dh","%bh", -}; -static char *names_seg[] = { - "%es","%cs","%ss","%ds","%fs","%gs","%?","%?", -}; - -struct dis386 grps[][8] = { - /* GRP1b */ - { - { "addb", Eb, Ib }, - { "orb", Eb, Ib }, - { "adcb", Eb, Ib }, - { "sbbb", Eb, Ib }, - { "andb", Eb, Ib }, - { "subb", Eb, Ib }, - { "xorb", Eb, Ib }, - { "cmpb", Eb, Ib } - }, - /* GRP1S */ - { - { "addS", Ev, Iv }, - { "orS", Ev, Iv }, - { "adcS", Ev, Iv }, - { "sbbS", Ev, Iv }, - { "andS", Ev, Iv }, - { "subS", Ev, Iv }, - { "xorS", Ev, Iv }, - { "cmpS", Ev, Iv } - }, - /* GRP1Ss */ - { - { "addS", Ev, sIb }, - { "orS", Ev, sIb }, - { "adcS", Ev, sIb }, - { "sbbS", Ev, sIb }, - { "andS", Ev, sIb }, - { "subS", Ev, sIb }, - { "xorS", Ev, sIb }, - { "cmpS", Ev, sIb } - }, - /* GRP2b */ - { - { "rolb", Eb, Ib }, - { "rorb", Eb, Ib }, - { "rclb", Eb, Ib }, - { "rcrb", Eb, Ib }, - { "shlb", Eb, Ib }, - { "shrb", Eb, Ib }, - { "(bad)" }, - { "sarb", Eb, Ib }, - }, - /* GRP2S */ - { - { "rolS", Ev, Ib }, - { "rorS", Ev, Ib }, - { "rclS", Ev, Ib }, - { "rcrS", Ev, Ib }, - { "shlS", Ev, Ib }, - { "shrS", Ev, Ib }, - { "(bad)" }, - { "sarS", Ev, Ib }, - }, - /* GRP2b_one */ - { - { "rolb", Eb }, - { "rorb", Eb }, - { "rclb", Eb }, - { "rcrb", Eb }, - { "shlb", Eb }, - { "shrb", Eb }, - { "(bad)" }, - { "sarb", Eb }, - }, - /* GRP2S_one */ - { - { "rolS", Ev }, - { "rorS", Ev }, - { "rclS", Ev }, - { "rcrS", Ev }, - { "shlS", Ev }, - { "shrS", Ev }, - { "(bad)" }, - { "sarS", Ev }, - }, - /* GRP2b_cl */ - { - { "rolb", Eb, CL }, - { "rorb", Eb, CL }, - { "rclb", Eb, CL }, - { "rcrb", Eb, CL }, - { "shlb", Eb, CL }, - { "shrb", Eb, CL }, - { "(bad)" }, - { "sarb", Eb, CL }, - }, - /* GRP2S_cl */ - { - { "rolS", Ev, CL }, - { "rorS", Ev, CL }, - { "rclS", Ev, CL }, - { "rcrS", Ev, CL }, - { "shlS", Ev, CL }, - { "shrS", Ev, CL }, - { "(bad)" }, - { "sarS", Ev, CL } - }, - /* GRP3b */ - { - { "testb", Eb, Ib }, - { "(bad)", Eb }, - { "notb", Eb }, - { "negb", Eb }, - { "mulb", AL, Eb }, - { "imulb", AL, Eb }, - { "divb", AL, Eb }, - { "idivb", AL, Eb } - }, - /* GRP3S */ - { - { "testS", Ev, Iv }, - { "(bad)" }, - { "notS", Ev }, - { "negS", Ev }, - { "mulS", eAX, Ev }, - { "imulS", eAX, Ev }, - { "divS", eAX, Ev }, - { "idivS", eAX, Ev }, - }, - /* GRP4 */ - { - { "incb", Eb }, - { "decb", Eb }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - }, - /* GRP5 */ - { - { "incS", Ev }, - { "decS", Ev }, - { "call", indirEv }, - { "lcall", indirEv }, - { "jmp", indirEv }, - { "ljmp", indirEv }, - { "pushS", Ev }, - { "(bad)" }, - }, - /* GRP6 */ - { - { "sldt", Ew }, - { "str", Ew }, - { "lldt", Ew }, - { "ltr", Ew }, - { "verr", Ew }, - { "verw", Ew }, - { "(bad)" }, - { "(bad)" } - }, - /* GRP7 */ - { - { "sgdt", Ew }, - { "sidt", Ew }, - { "lgdt", Ew }, - { "lidt", Ew }, - { "smsw", Ew }, - { "(bad)" }, - { "lmsw", Ew }, - { "invlpg", Ew }, - }, - /* GRP8 */ - { - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "btS", Ev, Ib }, - { "btsS", Ev, Ib }, - { "btrS", Ev, Ib }, - { "btcS", Ev, Ib }, - } -}; - -#define PREFIX_REPZ 1 -#define PREFIX_REPNZ 2 -#define PREFIX_LOCK 4 -#define PREFIX_CS 8 -#define PREFIX_SS 0x10 -#define PREFIX_DS 0x20 -#define PREFIX_ES 0x40 -#define PREFIX_FS 0x80 -#define PREFIX_GS 0x100 -#define PREFIX_DATA 0x200 -#define PREFIX_ADR 0x400 -#define PREFIX_FWAIT 0x800 - -static int prefixes; - -static void -ckprefix () -{ - prefixes = 0; - while (1) - { - FETCH_DATA (the_info, codep + 1); - switch (*codep) - { - case 0xf3: - prefixes |= PREFIX_REPZ; - break; - case 0xf2: - prefixes |= PREFIX_REPNZ; - break; - case 0xf0: - prefixes |= PREFIX_LOCK; - break; - case 0x2e: - prefixes |= PREFIX_CS; - break; - case 0x36: - prefixes |= PREFIX_SS; - break; - case 0x3e: - prefixes |= PREFIX_DS; - break; - case 0x26: - prefixes |= PREFIX_ES; - break; - case 0x64: - prefixes |= PREFIX_FS; - break; - case 0x65: - prefixes |= PREFIX_GS; - break; - case 0x66: - prefixes |= PREFIX_DATA; - break; - case 0x67: - prefixes |= PREFIX_ADR; - break; - case 0x9b: - prefixes |= PREFIX_FWAIT; - break; - default: - return; - } - codep++; - } -} - -static int dflag; -static int aflag; - -static char op1out[100], op2out[100], op3out[100]; -static int op_address[3], op_ad, op_index[3]; -static int start_pc; - - -/* - * On the 386's of 1988, the maximum length of an instruction is 15 bytes. - * (see topic "Redundant prefixes" in the "Differences from 8086" - * section of the "Virtual 8086 Mode" chapter.) - * 'pc' should be the address of this instruction, it will - * be used to print the target address if this is a relative jump or call - * The function returns the length of this instruction in bytes. - */ - -int -print_insn_i386 (pc, info) - bfd_vma pc; - disassemble_info *info; -{ - struct dis386 *dp; - int i; - int enter_instruction; - char *first, *second, *third; - int needcomma; - - struct dis_private priv; - bfd_byte *inbuf = priv.the_buffer; - - info->private_data = (PTR) &priv; - priv.max_fetched = priv.the_buffer; - priv.insn_start = pc; - if (setjmp (priv.bailout) != 0) - /* Error return. */ - return -1; - - obuf[0] = 0; - op1out[0] = 0; - op2out[0] = 0; - op3out[0] = 0; - - op_index[0] = op_index[1] = op_index[2] = -1; - - the_info = info; - start_pc = pc; - start_codep = inbuf; - codep = inbuf; - - ckprefix (); - - FETCH_DATA (info, codep + 1); - if (*codep == 0xc8) - enter_instruction = 1; - else - enter_instruction = 0; - - obufp = obuf; - - if (prefixes & PREFIX_REPZ) - oappend ("repz "); - if (prefixes & PREFIX_REPNZ) - oappend ("repnz "); - if (prefixes & PREFIX_LOCK) - oappend ("lock "); - - if ((prefixes & PREFIX_FWAIT) - && ((*codep < 0xd8) || (*codep > 0xdf))) - { - /* fwait not followed by floating point instruction */ - (*info->fprintf_func) (info->stream, "fwait"); - return (1); - } - - /* these would be initialized to 0 if disassembling for 8086 or 286 */ - dflag = 1; - aflag = 1; - - if (prefixes & PREFIX_DATA) - dflag ^= 1; - - if (prefixes & PREFIX_ADR) - { - aflag ^= 1; - oappend ("addr16 "); - } - - if (*codep == 0x0f) - { - FETCH_DATA (info, codep + 2); - dp = &dis386_twobyte[*++codep]; - } - else - dp = &dis386[*codep]; - codep++; - - /* Fetch the mod/reg/rm byte. FIXME: We should be only fetching - this if we need it. As it is, this code loses if there is a - one-byte instruction (without a mod/reg/rm byte) at the end of - the address space. */ - - FETCH_DATA (info, codep + 1); - mod = (*codep >> 6) & 3; - reg = (*codep >> 3) & 7; - rm = *codep & 7; - - if (dp->name == NULL && dp->bytemode1 == FLOATCODE) - { - dofloat (); - } - else - { - if (dp->name == NULL) - dp = &grps[dp->bytemode1][reg]; - - putop (dp->name); - - obufp = op1out; - op_ad = 2; - if (dp->op1) - (*dp->op1)(dp->bytemode1); - - obufp = op2out; - op_ad = 1; - if (dp->op2) - (*dp->op2)(dp->bytemode2); - - obufp = op3out; - op_ad = 0; - if (dp->op3) - (*dp->op3)(dp->bytemode3); - } - - obufp = obuf + strlen (obuf); - for (i = strlen (obuf); i < 6; i++) - oappend (" "); - oappend (" "); - (*info->fprintf_func) (info->stream, "%s", obuf); - - /* enter instruction is printed with operands in the - * same order as the intel book; everything else - * is printed in reverse order - */ - if (enter_instruction) - { - first = op1out; - second = op2out; - third = op3out; - op_ad = op_index[0]; - op_index[0] = op_index[2]; - op_index[2] = op_ad; - } - else - { - first = op3out; - second = op2out; - third = op1out; - } - needcomma = 0; - if (*first) - { - if (op_index[0] != -1) - (*info->print_address_func) (op_address[op_index[0]], info); - else - (*info->fprintf_func) (info->stream, "%s", first); - needcomma = 1; - } - if (*second) - { - if (needcomma) - (*info->fprintf_func) (info->stream, ","); - if (op_index[1] != -1) - (*info->print_address_func) (op_address[op_index[1]], info); - else - (*info->fprintf_func) (info->stream, "%s", second); - needcomma = 1; - } - if (*third) - { - if (needcomma) - (*info->fprintf_func) (info->stream, ","); - if (op_index[2] != -1) - (*info->print_address_func) (op_address[op_index[2]], info); - else - (*info->fprintf_func) (info->stream, "%s", third); - } - return (codep - inbuf); -} - -char *float_mem[] = { - /* d8 */ - "fadds", - "fmuls", - "fcoms", - "fcomps", - "fsubs", - "fsubrs", - "fdivs", - "fdivrs", - /* d9 */ - "flds", - "(bad)", - "fsts", - "fstps", - "fldenv", - "fldcw", - "fNstenv", - "fNstcw", - /* da */ - "fiaddl", - "fimull", - "ficoml", - "ficompl", - "fisubl", - "fisubrl", - "fidivl", - "fidivrl", - /* db */ - "fildl", - "(bad)", - "fistl", - "fistpl", - "(bad)", - "fldt", - "(bad)", - "fstpt", - /* dc */ - "faddl", - "fmull", - "fcoml", - "fcompl", - "fsubl", - "fsubrl", - "fdivl", - "fdivrl", - /* dd */ - "fldl", - "(bad)", - "fstl", - "fstpl", - "frstor", - "(bad)", - "fNsave", - "fNstsw", - /* de */ - "fiadd", - "fimul", - "ficom", - "ficomp", - "fisub", - "fisubr", - "fidiv", - "fidivr", - /* df */ - "fild", - "(bad)", - "fist", - "fistp", - "fbld", - "fildll", - "fbstp", - "fistpll", -}; - -#define ST OP_ST, 0 -#define STi OP_STi, 0 -int OP_ST(), OP_STi(); - -#define FGRPd9_2 NULL, NULL, 0 -#define FGRPd9_4 NULL, NULL, 1 -#define FGRPd9_5 NULL, NULL, 2 -#define FGRPd9_6 NULL, NULL, 3 -#define FGRPd9_7 NULL, NULL, 4 -#define FGRPda_5 NULL, NULL, 5 -#define FGRPdb_4 NULL, NULL, 6 -#define FGRPde_3 NULL, NULL, 7 -#define FGRPdf_4 NULL, NULL, 8 - -struct dis386 float_reg[][8] = { - /* d8 */ - { - { "fadd", ST, STi }, - { "fmul", ST, STi }, - { "fcom", STi }, - { "fcomp", STi }, - { "fsub", ST, STi }, - { "fsubr", ST, STi }, - { "fdiv", ST, STi }, - { "fdivr", ST, STi }, - }, - /* d9 */ - { - { "fld", STi }, - { "fxch", STi }, - { FGRPd9_2 }, - { "(bad)" }, - { FGRPd9_4 }, - { FGRPd9_5 }, - { FGRPd9_6 }, - { FGRPd9_7 }, - }, - /* da */ - { - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { FGRPda_5 }, - { "(bad)" }, - { "(bad)" }, - }, - /* db */ - { - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { FGRPdb_4 }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - }, - /* dc */ - { - { "fadd", STi, ST }, - { "fmul", STi, ST }, - { "(bad)" }, - { "(bad)" }, - { "fsub", STi, ST }, - { "fsubr", STi, ST }, - { "fdiv", STi, ST }, - { "fdivr", STi, ST }, - }, - /* dd */ - { - { "ffree", STi }, - { "(bad)" }, - { "fst", STi }, - { "fstp", STi }, - { "fucom", STi }, - { "fucomp", STi }, - { "(bad)" }, - { "(bad)" }, - }, - /* de */ - { - { "faddp", STi, ST }, - { "fmulp", STi, ST }, - { "(bad)" }, - { FGRPde_3 }, - { "fsubp", STi, ST }, - { "fsubrp", STi, ST }, - { "fdivp", STi, ST }, - { "fdivrp", STi, ST }, - }, - /* df */ - { - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { FGRPdf_4 }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - }, -}; - - -char *fgrps[][8] = { - /* d9_2 0 */ - { - "fnop","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", - }, - - /* d9_4 1 */ - { - "fchs","fabs","(bad)","(bad)","ftst","fxam","(bad)","(bad)", - }, - - /* d9_5 2 */ - { - "fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","(bad)", - }, - - /* d9_6 3 */ - { - "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp", - }, - - /* d9_7 4 */ - { - "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos", - }, - - /* da_5 5 */ - { - "(bad)","fucompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", - }, - - /* db_4 6 */ - { - "feni(287 only)","fdisi(287 only)","fNclex","fNinit", - "fNsetpm(287 only)","(bad)","(bad)","(bad)", - }, - - /* de_3 7 */ - { - "(bad)","fcompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", - }, - - /* df_4 8 */ - { - "fNstsw","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", - }, -}; - -static void -dofloat () -{ - struct dis386 *dp; - unsigned char floatop; - - floatop = codep[-1]; - - if (mod != 3) - { - putop (float_mem[(floatop - 0xd8) * 8 + reg]); - obufp = op1out; - OP_E (v_mode); - return; - } - codep++; - - dp = &float_reg[floatop - 0xd8][reg]; - if (dp->name == NULL) - { - putop (fgrps[dp->bytemode1][rm]); - /* instruction fnstsw is only one with strange arg */ - if (floatop == 0xdf - && FETCH_DATA (the_info, codep + 1) - && *codep == 0xe0) - strcpy (op1out, "%eax"); - } - else - { - putop (dp->name); - obufp = op1out; - if (dp->op1) - (*dp->op1)(dp->bytemode1); - obufp = op2out; - if (dp->op2) - (*dp->op2)(dp->bytemode2); - } -} - -/* ARGSUSED */ -int -OP_ST (ignore) - int ignore; -{ - oappend ("%st"); - return (0); -} - -/* ARGSUSED */ -int -OP_STi (ignore) - int ignore; -{ - sprintf (scratchbuf, "%%st(%d)", rm); - oappend (scratchbuf); - return (0); -} - - -/* capital letters in template are macros */ -static void -putop (template) - char *template; -{ - char *p; - - for (p = template; *p; p++) - { - switch (*p) - { - default: - *obufp++ = *p; - break; - case 'C': /* For jcxz/jecxz */ - if (aflag == 0) - *obufp++ = 'e'; - break; - case 'N': - if ((prefixes & PREFIX_FWAIT) == 0) - *obufp++ = 'n'; - break; - case 'S': - /* operand size flag */ - if (dflag) - *obufp++ = 'l'; - else - *obufp++ = 'w'; - break; - } - } - *obufp = 0; -} - -static void -oappend (s) - char *s; -{ - strcpy (obufp, s); - obufp += strlen (s); - *obufp = 0; -} - -static void -append_prefix () -{ - if (prefixes & PREFIX_CS) - oappend ("%cs:"); - if (prefixes & PREFIX_DS) - oappend ("%ds:"); - if (prefixes & PREFIX_SS) - oappend ("%ss:"); - if (prefixes & PREFIX_ES) - oappend ("%es:"); - if (prefixes & PREFIX_FS) - oappend ("%fs:"); - if (prefixes & PREFIX_GS) - oappend ("%gs:"); -} - -int -OP_indirE (bytemode) - int bytemode; -{ - oappend ("*"); - OP_E (bytemode); - return (0); -} - -int -OP_E (bytemode) - int bytemode; -{ - int disp; - int havesib; - int base; - int index; - int scale; - int havebase; - - /* skip mod/rm byte */ - codep++; - - havesib = 0; - havebase = 0; - disp = 0; - - if (mod == 3) - { - switch (bytemode) - { - case b_mode: - oappend (names8[rm]); - break; - case w_mode: - oappend (names16[rm]); - break; - case v_mode: - if (dflag) - oappend (names32[rm]); - else - oappend (names16[rm]); - break; - default: - oappend (""); - break; - } - return (0); - } - - append_prefix (); - if (rm == 4) - { - havesib = 1; - havebase = 1; - FETCH_DATA (the_info, codep + 1); - scale = (*codep >> 6) & 3; - index = (*codep >> 3) & 7; - base = *codep & 7; - codep++; - } - - switch (mod) - { - case 0: - switch (rm) - { - case 4: - /* implies havesib and havebase */ - if (base == 5) { - havebase = 0; - disp = get32 (); - } - break; - case 5: - disp = get32 (); - break; - default: - havebase = 1; - base = rm; - break; - } - break; - case 1: - FETCH_DATA (the_info, codep + 1); - disp = *(char *)codep++; - if (rm != 4) - { - havebase = 1; - base = rm; - } - break; - case 2: - disp = get32 (); - if (rm != 4) - { - havebase = 1; - base = rm; - } - break; - } - - if (mod != 0 || rm == 5 || (havesib && base == 5)) - { - sprintf (scratchbuf, "0x%x", disp); - oappend (scratchbuf); - } - - if (havebase || havesib) - { - oappend ("("); - if (havebase) - oappend (names32[base]); - if (havesib) - { - if (index != 4) - { - sprintf (scratchbuf, ",%s", names32[index]); - oappend (scratchbuf); - } - sprintf (scratchbuf, ",%d", 1 << scale); - oappend (scratchbuf); - } - oappend (")"); - } - return (0); -} - -int -OP_G (bytemode) - int bytemode; -{ - switch (bytemode) - { - case b_mode: - oappend (names8[reg]); - break; - case w_mode: - oappend (names16[reg]); - break; - case d_mode: - oappend (names32[reg]); - break; - case v_mode: - if (dflag) - oappend (names32[reg]); - else - oappend (names16[reg]); - break; - default: - oappend (""); - break; - } - return (0); -} - -static int -get32 () -{ - int x = 0; - - FETCH_DATA (the_info, codep + 4); - x = *codep++ & 0xff; - x |= (*codep++ & 0xff) << 8; - x |= (*codep++ & 0xff) << 16; - x |= (*codep++ & 0xff) << 24; - return (x); -} - -static int -get16 () -{ - int x = 0; - - FETCH_DATA (the_info, codep + 2); - x = *codep++ & 0xff; - x |= (*codep++ & 0xff) << 8; - return (x); -} - -static void -set_op (op) - int op; -{ - op_index[op_ad] = op_ad; - op_address[op_ad] = op; -} - -int -OP_REG (code) - int code; -{ - char *s; - - switch (code) - { - case indir_dx_reg: s = "(%dx)"; break; - case ax_reg: case cx_reg: case dx_reg: case bx_reg: - case sp_reg: case bp_reg: case si_reg: case di_reg: - s = names16[code - ax_reg]; - break; - case es_reg: case ss_reg: case cs_reg: - case ds_reg: case fs_reg: case gs_reg: - s = names_seg[code - es_reg]; - break; - case al_reg: case ah_reg: case cl_reg: case ch_reg: - case dl_reg: case dh_reg: case bl_reg: case bh_reg: - s = names8[code - al_reg]; - break; - case eAX_reg: case eCX_reg: case eDX_reg: case eBX_reg: - case eSP_reg: case eBP_reg: case eSI_reg: case eDI_reg: - if (dflag) - s = names32[code - eAX_reg]; - else - s = names16[code - eAX_reg]; - break; - default: - s = ""; - break; - } - oappend (s); - return (0); -} - -int -OP_I (bytemode) - int bytemode; -{ - int op; - - switch (bytemode) - { - case b_mode: - FETCH_DATA (the_info, codep + 1); - op = *codep++ & 0xff; - break; - case v_mode: - if (dflag) - op = get32 (); - else - op = get16 (); - break; - case w_mode: - op = get16 (); - break; - default: - oappend (""); - return (0); - } - sprintf (scratchbuf, "$0x%x", op); - oappend (scratchbuf); - return (0); -} - -int -OP_sI (bytemode) - int bytemode; -{ - int op; - - switch (bytemode) - { - case b_mode: - FETCH_DATA (the_info, codep + 1); - op = *(char *)codep++; - break; - case v_mode: - if (dflag) - op = get32 (); - else - op = (short)get16(); - break; - case w_mode: - op = (short)get16 (); - break; - default: - oappend (""); - return (0); - } - sprintf (scratchbuf, "$0x%x", op); - oappend (scratchbuf); - return (0); -} - -int -OP_J (bytemode) - int bytemode; -{ - int disp; - int mask = -1; - - switch (bytemode) - { - case b_mode: - FETCH_DATA (the_info, codep + 1); - disp = *(char *)codep++; - break; - case v_mode: - if (dflag) - disp = get32 (); - else - { - disp = (short)get16 (); - /* for some reason, a data16 prefix on a jump instruction - means that the pc is masked to 16 bits after the - displacement is added! */ - mask = 0xffff; - } - break; - default: - oappend (""); - return (0); - } - disp = (start_pc + codep - start_codep + disp) & mask; - set_op (disp); - sprintf (scratchbuf, "0x%x", disp); - oappend (scratchbuf); - return (0); -} - -/* ARGSUSED */ -int -OP_SEG (dummy) - int dummy; -{ - static char *sreg[] = { - "%es","%cs","%ss","%ds","%fs","%gs","%?","%?", - }; - - oappend (sreg[reg]); - return (0); -} - -int -OP_DIR (size) - int size; -{ - int seg, offset; - - switch (size) - { - case lptr: - if (aflag) - { - offset = get32 (); - seg = get16 (); - } - else - { - offset = get16 (); - seg = get16 (); - } - sprintf (scratchbuf, "0x%x,0x%x", seg, offset); - oappend (scratchbuf); - break; - case v_mode: - if (aflag) - offset = get32 (); - else - offset = (short)get16 (); - - offset = start_pc + codep - start_codep + offset; - set_op (offset); - sprintf (scratchbuf, "0x%x", offset); - oappend (scratchbuf); - break; - default: - oappend (""); - break; - } - return (0); -} - -/* ARGSUSED */ -int -OP_OFF (bytemode) - int bytemode; -{ - int off; - - if (aflag) - off = get32 (); - else - off = get16 (); - - sprintf (scratchbuf, "0x%x", off); - oappend (scratchbuf); - return (0); -} - -/* ARGSUSED */ -int -OP_ESDI (dummy) - int dummy; -{ - oappend ("%es:("); - oappend (aflag ? "%edi" : "%di"); - oappend (")"); - return (0); -} - -/* ARGSUSED */ -int -OP_DSSI (dummy) - int dummy; -{ - oappend ("%ds:("); - oappend (aflag ? "%esi" : "%si"); - oappend (")"); - return (0); -} - -/* ARGSUSED */ -int -OP_ONE (dummy) - int dummy; -{ - oappend ("1"); - return (0); -} - -/* ARGSUSED */ -int -OP_C (dummy) - int dummy; -{ - codep++; /* skip mod/rm */ - sprintf (scratchbuf, "%%cr%d", reg); - oappend (scratchbuf); - return (0); -} - -/* ARGSUSED */ -int -OP_D (dummy) - int dummy; -{ - codep++; /* skip mod/rm */ - sprintf (scratchbuf, "%%db%d", reg); - oappend (scratchbuf); - return (0); -} - -/* ARGSUSED */ -int -OP_T (dummy) - int dummy; -{ - codep++; /* skip mod/rm */ - sprintf (scratchbuf, "%%tr%d", reg); - oappend (scratchbuf); - return (0); -} - -int -OP_rm (bytemode) - int bytemode; -{ - switch (bytemode) - { - case d_mode: - oappend (names32[rm]); - break; - case w_mode: - oappend (names16[rm]); - break; - } - return (0); -} diff --git a/debugger/opcodes/obstack.h b/debugger/opcodes/obstack.h deleted file mode 100644 index 28061a02193..00000000000 --- a/debugger/opcodes/obstack.h +++ /dev/null @@ -1,513 +0,0 @@ -/* obstack.h - object stack macros - Copyright (C) 1988, 89, 90, 91, 92, 93, 94 Free Software Foundation, Inc. - -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU Library General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -This program 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 Library General Public License for more details. - -You should have received a copy of the GNU Library General Public License -along with this program; if not, write to the Free Software -Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Summary: - -All the apparent functions defined here are macros. The idea -is that you would use these pre-tested macros to solve a -very specific set of problems, and they would run fast. -Caution: no side-effects in arguments please!! They may be -evaluated MANY times!! - -These macros operate a stack of objects. Each object starts life -small, and may grow to maturity. (Consider building a word syllable -by syllable.) An object can move while it is growing. Once it has -been "finished" it never changes address again. So the "top of the -stack" is typically an immature growing object, while the rest of the -stack is of mature, fixed size and fixed address objects. - -These routines grab large chunks of memory, using a function you -supply, called `obstack_chunk_alloc'. On occasion, they free chunks, -by calling `obstack_chunk_free'. You must define them and declare -them before using any obstack macros. - -Each independent stack is represented by a `struct obstack'. -Each of the obstack macros expects a pointer to such a structure -as the first argument. - -One motivation for this package is the problem of growing char strings -in symbol tables. Unless you are "fascist pig with a read-only mind" ---Gosper's immortal quote from HAKMEM item 154, out of context--you -would not like to put any arbitrary upper limit on the length of your -symbols. - -In practice this often means you will build many short symbols and a -few long symbols. At the time you are reading a symbol you don't know -how long it is. One traditional method is to read a symbol into a -buffer, realloc()ating the buffer every time you try to read a symbol -that is longer than the buffer. This is beaut, but you still will -want to copy the symbol from the buffer to a more permanent -symbol-table entry say about half the time. - -With obstacks, you can work differently. Use one obstack for all symbol -names. As you read a symbol, grow the name in the obstack gradually. -When the name is complete, finalize it. Then, if the symbol exists already, -free the newly read name. - -The way we do this is to take a large chunk, allocating memory from -low addresses. When you want to build a symbol in the chunk you just -add chars above the current "high water mark" in the chunk. When you -have finished adding chars, because you got to the end of the symbol, -you know how long the chars are, and you can create a new object. -Mostly the chars will not burst over the highest address of the chunk, -because you would typically expect a chunk to be (say) 100 times as -long as an average object. - -In case that isn't clear, when we have enough chars to make up -the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) -so we just point to it where it lies. No moving of chars is -needed and this is the second win: potentially long strings need -never be explicitly shuffled. Once an object is formed, it does not -change its address during its lifetime. - -When the chars burst over a chunk boundary, we allocate a larger -chunk, and then copy the partly formed object from the end of the old -chunk to the beginning of the new larger chunk. We then carry on -accreting characters to the end of the object as we normally would. - -A special macro is provided to add a single char at a time to a -growing object. This allows the use of register variables, which -break the ordinary 'growth' macro. - -Summary: - We allocate large chunks. - We carve out one object at a time from the current chunk. - Once carved, an object never moves. - We are free to append data of any size to the currently - growing object. - Exactly one object is growing in an obstack at any one time. - You can run one obstack per control block. - You may have as many control blocks as you dare. - Because of the way we do it, you can `unwind' an obstack - back to a previous state. (You may remove objects much - as you would with a stack.) -*/ - - -/* Don't do the contents of this file more than once. */ - -#ifndef __OBSTACK_H__ -#define __OBSTACK_H__ - -/* We use subtraction of (char *)0 instead of casting to int - because on word-addressable machines a simple cast to int - may ignore the byte-within-word field of the pointer. */ - -#ifndef __PTR_TO_INT -#define __PTR_TO_INT(P) ((P) - (char *)0) -#endif - -#ifndef __INT_TO_PTR -#define __INT_TO_PTR(P) ((P) + (char *)0) -#endif - -/* We need the type of the resulting object. In ANSI C it is ptrdiff_t - but in traditional C it is usually long. If we are in ANSI C and - don't already have ptrdiff_t get it. */ - -#if defined (__STDC__) && ! defined (offsetof) -#if defined (__GNUC__) && defined (IN_GCC) -/* On Next machine, the system's stddef.h screws up if included - after we have defined just ptrdiff_t, so include all of stddef.h. - Otherwise, define just ptrdiff_t, which is all we need. */ -#ifndef __NeXT__ -#define __need_ptrdiff_t -#endif -#endif - -#include -#endif - -#ifdef __STDC__ -#define PTR_INT_TYPE ptrdiff_t -#else -#define PTR_INT_TYPE long -#endif - -struct _obstack_chunk /* Lives at front of each chunk. */ -{ - char *limit; /* 1 past end of this chunk */ - struct _obstack_chunk *prev; /* address of prior chunk or NULL */ - char contents[4]; /* objects begin here */ -}; - -struct obstack /* control current object in current chunk */ -{ - long chunk_size; /* preferred size to allocate chunks in */ - struct _obstack_chunk* chunk; /* address of current struct obstack_chunk */ - char *object_base; /* address of object we are building */ - char *next_free; /* where to add next char to current object */ - char *chunk_limit; /* address of char after current chunk */ - PTR_INT_TYPE temp; /* Temporary for some macros. */ - int alignment_mask; /* Mask of alignment for each object. */ - struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk. */ - void (*freefun) (); /* User's function to free a chunk. */ - char *extra_arg; /* first arg for chunk alloc/dealloc funcs */ - unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */ - unsigned maybe_empty_object:1;/* There is a possibility that the current - chunk contains a zero-length object. This - prevents freeing the chunk if we allocate - a bigger chunk to replace it. */ - unsigned alloc_failed:1; /* chunk alloc func returned 0 */ -}; - -/* Declare the external functions we use; they are in obstack.c. */ - -#ifdef __STDC__ -extern void _obstack_newchunk (struct obstack *, int); -extern void _obstack_free (struct obstack *, void *); -extern int _obstack_begin (struct obstack *, int, int, - void *(*) (), void (*) ()); -extern int _obstack_begin_1 (struct obstack *, int, int, - void *(*) (), void (*) (), void *); -#else -extern void _obstack_newchunk (); -extern void _obstack_free (); -extern int _obstack_begin (); -extern int _obstack_begin_1 (); -#endif - -#ifdef __STDC__ - -/* Do the function-declarations after the structs - but before defining the macros. */ - -void obstack_init (struct obstack *obstack); - -void * obstack_alloc (struct obstack *obstack, int size); - -void * obstack_copy (struct obstack *obstack, void *address, int size); -void * obstack_copy0 (struct obstack *obstack, void *address, int size); - -void obstack_free (struct obstack *obstack, void *block); - -void obstack_blank (struct obstack *obstack, int size); - -void obstack_grow (struct obstack *obstack, void *data, int size); -void obstack_grow0 (struct obstack *obstack, void *data, int size); - -void obstack_1grow (struct obstack *obstack, int data_char); -void obstack_ptr_grow (struct obstack *obstack, void *data); -void obstack_int_grow (struct obstack *obstack, int data); - -void * obstack_finish (struct obstack *obstack); - -int obstack_object_size (struct obstack *obstack); - -int obstack_room (struct obstack *obstack); -void obstack_1grow_fast (struct obstack *obstack, int data_char); -void obstack_ptr_grow_fast (struct obstack *obstack, void *data); -void obstack_int_grow_fast (struct obstack *obstack, int data); -void obstack_blank_fast (struct obstack *obstack, int size); - -void * obstack_base (struct obstack *obstack); -void * obstack_next_free (struct obstack *obstack); -int obstack_alignment_mask (struct obstack *obstack); -int obstack_chunk_size (struct obstack *obstack); - -#endif /* __STDC__ */ - -/* Non-ANSI C cannot really support alternative functions for these macros, - so we do not declare them. */ - -/* Pointer to beginning of object being allocated or to be allocated next. - Note that this might not be the final address of the object - because a new chunk might be needed to hold the final size. */ - -#define obstack_base(h) ((h)->alloc_failed ? 0 : (h)->object_base) - -/* Size for allocating ordinary chunks. */ - -#define obstack_chunk_size(h) ((h)->chunk_size) - -/* Pointer to next byte not yet allocated in current chunk. */ - -#define obstack_next_free(h) ((h)->alloc_failed ? 0 : (h)->next_free) - -/* Mask specifying low bits that should be clear in address of an object. */ - -#define obstack_alignment_mask(h) ((h)->alignment_mask) - -#define obstack_init(h) \ - _obstack_begin ((h), 0, 0, \ - (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free) - -#define obstack_begin(h, size) \ - _obstack_begin ((h), (size), 0, \ - (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free) - -#define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ - _obstack_begin ((h), (size), (alignment), \ - (void *(*) ()) (chunkfun), (void (*) ()) (freefun)) - -#define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ - _obstack_begin_1 ((h), (size), (alignment), \ - (void *(*) ()) (chunkfun), (void (*) ()) (freefun), (arg)) - -#define obstack_chunkfun(h, newchunkfun) \ - ((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun)) - -#define obstack_freefun(h, newfreefun) \ - ((h) -> freefun = (void (*)()) (newfreefun)) - -#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar) - -#define obstack_blank_fast(h,n) ((h)->next_free += (n)) - -#if defined (__GNUC__) && defined (__STDC__) -#if __GNUC__ < 2 -#define __extension__ -#endif - -/* For GNU C, if not -traditional, - we can define these macros to compute all args only once - without using a global variable. - Also, we can avoid using the `temp' slot, to make faster code. */ - -#define obstack_object_size(OBSTACK) \ - __extension__ \ - ({ struct obstack *__o = (OBSTACK); \ - __o->alloc_failed ? 0 : \ - (unsigned) (__o->next_free - __o->object_base); }) - -#define obstack_room(OBSTACK) \ - __extension__ \ - ({ struct obstack *__o = (OBSTACK); \ - (unsigned) (__o->chunk_limit - __o->next_free); }) - -#define obstack_grow(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->next_free + __len > __o->chunk_limit) \ - _obstack_newchunk (__o, __len); \ - if (!__o->alloc_failed) \ - { \ - bcopy (where, __o->next_free, __len); \ - __o->next_free += __len; \ - } \ - (void) 0; }) - -#define obstack_grow0(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->next_free + __len + 1 > __o->chunk_limit) \ - _obstack_newchunk (__o, __len + 1); \ - if (!__o->alloc_failed) \ - { \ - bcopy (where, __o->next_free, __len); \ - __o->next_free += __len; \ - *(__o->next_free)++ = 0; \ - } \ - (void) 0; }) - -#define obstack_1grow(OBSTACK,datum) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - if (__o->next_free + 1 > __o->chunk_limit) \ - _obstack_newchunk (__o, 1); \ - if (!__o->alloc_failed) \ - *(__o->next_free)++ = (datum); \ - (void) 0; }) - -/* These assume that the obstack alignment is good enough for pointers or ints, - and that the data added so far to the current object - shares that much alignment. */ - -#define obstack_ptr_grow(OBSTACK,datum) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - if (__o->next_free + sizeof (void *) > __o->chunk_limit) \ - _obstack_newchunk (__o, sizeof (void *)); \ - if (!__o->alloc_failed) \ - *((void **)__o->next_free)++ = ((void *)datum); \ - (void) 0; }) - -#define obstack_int_grow(OBSTACK,datum) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - if (__o->next_free + sizeof (int) > __o->chunk_limit) \ - _obstack_newchunk (__o, sizeof (int)); \ - if (!__o->alloc_failed) \ - *((int *)__o->next_free)++ = ((int)datum); \ - (void) 0; }) - -#define obstack_ptr_grow_fast(h,aptr) (*((void **)(h)->next_free)++ = (void *)aptr) -#define obstack_int_grow_fast(h,aint) (*((int *)(h)->next_free)++ = (int)aint) - -#define obstack_blank(OBSTACK,length) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - if (__o->chunk_limit - __o->next_free < __len) \ - _obstack_newchunk (__o, __len); \ - if (!__o->alloc_failed) \ - __o->next_free += __len; \ - (void) 0; }) - -#define obstack_alloc(OBSTACK,length) \ -__extension__ \ -({ struct obstack *__h = (OBSTACK); \ - obstack_blank (__h, (length)); \ - obstack_finish (__h); }) - -#define obstack_copy(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow (__h, (where), (length)); \ - obstack_finish (__h); }) - -#define obstack_copy0(OBSTACK,where,length) \ -__extension__ \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow0 (__h, (where), (length)); \ - obstack_finish (__h); }) - -/* The local variable is named __o1 to avoid a name conflict - when obstack_blank is called. */ -#define obstack_finish(OBSTACK) \ -__extension__ \ -({ struct obstack *__o1 = (OBSTACK); \ - void *value; \ - if (__o1->alloc_failed) \ - value = 0; \ - else \ - { \ - value = (void *) __o1->object_base; \ - if (__o1->next_free == value) \ - __o1->maybe_empty_object = 1; \ - __o1->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\ - & ~ (__o1->alignment_mask)); \ - if (__o1->next_free - (char *)__o1->chunk \ - > __o1->chunk_limit - (char *)__o1->chunk) \ - __o1->next_free = __o1->chunk_limit; \ - __o1->object_base = __o1->next_free; \ - } \ - value; }) - -#define obstack_free(OBSTACK, OBJ) \ -__extension__ \ -({ struct obstack *__o = (OBSTACK); \ - void *__obj = (OBJ); \ - if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ - __o->next_free = __o->object_base = __obj; \ - else (obstack_free) (__o, __obj); }) - -#else /* not __GNUC__ or not __STDC__ */ - -#define obstack_object_size(h) \ - (unsigned) ((h)->alloc_failed ? 0 : (h)->next_free - (h)->object_base) - -#define obstack_room(h) \ - (unsigned) ((h)->chunk_limit - (h)->next_free) - -/* Note that the call to _obstack_newchunk is enclosed in (..., 0) - so that we can avoid having void expressions - in the arms of the conditional expression. - Casting the third operand to void was tried before, - but some compilers won't accept it. */ - -#define obstack_grow(h,where,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ - ((h)->alloc_failed ? 0 : \ - (bcopy (where, (h)->next_free, (h)->temp), \ - (h)->next_free += (h)->temp))) - -#define obstack_grow0(h,where,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0), \ - ((h)->alloc_failed ? 0 : \ - (bcopy (where, (h)->next_free, (h)->temp), \ - (h)->next_free += (h)->temp, \ - *((h)->next_free)++ = 0))) - -#define obstack_1grow(h,datum) \ -( (((h)->next_free + 1 > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), 1), 0) : 0), \ - ((h)->alloc_failed ? 0 : \ - (*((h)->next_free)++ = (datum)))) - -#define obstack_ptr_grow(h,datum) \ -( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0), \ - ((h)->alloc_failed ? 0 : \ - (*((char **)(((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *)datum)))) - -#define obstack_int_grow(h,datum) \ -( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ - ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ - ((h)->alloc_failed ? 0 : \ - (*((int *)(((h)->next_free+=sizeof(int))-sizeof(int))) = ((int)datum)))) - -#define obstack_ptr_grow_fast(h,aptr) (*((char **)(h)->next_free)++ = (char *)aptr) -#define obstack_int_grow_fast(h,aint) (*((int *)(h)->next_free)++ = (int)aint) - -#define obstack_blank(h,length) \ -( (h)->temp = (length), \ - (((h)->chunk_limit - (h)->next_free < (h)->temp) \ - ? (_obstack_newchunk ((h), (h)->temp), 0) : 0), \ - ((h)->alloc_failed ? 0 : \ - ((h)->next_free += (h)->temp))) - -#define obstack_alloc(h,length) \ - (obstack_blank ((h), (length)), obstack_finish ((h))) - -#define obstack_copy(h,where,length) \ - (obstack_grow ((h), (where), (length)), obstack_finish ((h))) - -#define obstack_copy0(h,where,length) \ - (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) - -#define obstack_finish(h) \ -( (h)->alloc_failed ? 0 : \ - (((h)->next_free == (h)->object_base \ - ? (((h)->maybe_empty_object = 1), 0) \ - : 0), \ - (h)->temp = __PTR_TO_INT ((h)->object_base), \ - (h)->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \ - & ~ ((h)->alignment_mask)), \ - (((h)->next_free - (char *)(h)->chunk \ - > (h)->chunk_limit - (char *)(h)->chunk) \ - ? ((h)->next_free = (h)->chunk_limit) : 0), \ - (h)->object_base = (h)->next_free, \ - __INT_TO_PTR ((h)->temp))) - -#ifdef __STDC__ -#define obstack_free(h,obj) \ -( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \ - (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp + (char *) (h)->chunk) \ - : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0))) -#else -#define obstack_free(h,obj) \ -( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \ - (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp + (char *) (h)->chunk) \ - : (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0))) -#endif - -#endif /* not __GNUC__ or not __STDC__ */ - -#endif /* not __OBSTACK_H__ */ diff --git a/if1632/call.S b/if1632/call.S index e36f093ebf7..326c874396a 100644 --- a/if1632/call.S +++ b/if1632/call.S @@ -27,6 +27,11 @@ A(IF1632_Saved32_ebp:) .long 0 A(IF1632_Saved32_ss:) .word 0 +#ifdef __ELF__ +A(IF1632_ELF_KLUDGE:) + .long 0 + .word 0x0f +#endif /********************************************************************** * Places to keep info about the current 16-bit stack frame. @@ -74,6 +79,16 @@ A(CallToInit16:) pushl A(IF1632_Saved32_ebp) pushw A(IF1632_Saved32_ss) +#ifdef __ELF__ + /* change to the other code segment */ + movw $0x0f, %ax + movw %ax, A(IF1632_ELF_KLUDGE)+4 + movl $L4, %eax + andl $0x0000ffff, %eax + movl %eax,A(IF1632_ELF_KLUDGE) + ljmp A(IF1632_ELF_KLUDGE) +L4: +#endif /* * Get target address. */ @@ -147,6 +162,15 @@ A(CallToInit16:) popl A(IF1632_Saved32_ebp) popl A(IF1632_Saved32_esp) movl %eax,return_value +#ifdef __ELF__ + /* change back */ + movw $0x23, %ax + movw %ax, A(IF1632_ELF_KLUDGE)+4 + movl $L5, %eax + movl %eax,A(IF1632_ELF_KLUDGE) + ljmp A(IF1632_ELF_KLUDGE) +L5: +#endif popal movl return_value,%eax .align 2,0x90 @@ -182,7 +206,19 @@ A(CallTo16cx:) /* * Get target address and new ds */ -L1: movl 8(%ebp),%eax +L1: +#ifdef __ELF__ + /* change code segments */ + movw $0x0f, %ax + movw %ax, A(IF1632_ELF_KLUDGE)+4 + movl $L2, %eax + andl $0x0000ffff, %eax + movl %eax,A(IF1632_ELF_KLUDGE) + ljmp A(IF1632_ELF_KLUDGE) +L2: +#endif + /* At this point we have changed segments. */ + movl 8(%ebp),%eax movl %eax,jump_target lea jump_target,%edx movw 12(%ebp),%ax @@ -244,6 +280,18 @@ L1: movl 8(%ebp),%eax movl %eax,return_value movw return_value+2,%dx + /* switch segments */ +#ifdef __ELF__ + movw $0x23, %ax + movw %ax, A(IF1632_ELF_KLUDGE)+4 + movl $L3, %eax + movl %eax,A(IF1632_ELF_KLUDGE) + ljmp A(IF1632_ELF_KLUDGE) +L3: + /* back in the regular segment set up. */ + /* restore eax */ + movl return_value, %eax +#endif .align 2,0x90 leave ret diff --git a/if1632/callback.c b/if1632/callback.c index a38d13bb6e5..c820f6b890c 100644 --- a/if1632/callback.c +++ b/if1632/callback.c @@ -174,15 +174,15 @@ LONG CallWindowProc( WNDPROC func, HWND hwnd, WORD message, user_tab = FindDLLTable("USER"); /* DefWindowProc */ - if (user_tab[107].address == address) + if (((LONG)user_tab[107].address &0xffff) == (LONG) address) return DefWindowProc(hwnd, message, wParam, lParam); /* DefDlgProc */ - else if (user_tab[308].address == address) + else if (((LONG)user_tab[308].address &0xffff) == (LONG)address) return DefDlgProc(hwnd, message, wParam, lParam); /* DefMDIChildProc */ - else if (user_tab[447].address == address) + else if (((LONG)user_tab[447].address &0xffff) == (LONG)address) return DefMDIChildProc(hwnd, message, wParam, lParam); /* default */ diff --git a/include/nonclient.h b/include/nonclient.h index 87bc71ef403..0e8c665acba 100644 --- a/include/nonclient.h +++ b/include/nonclient.h @@ -1,7 +1,17 @@ +/* + * Window non-client functions definitions + * + * Copyright 1995 Alexandre Julliard + */ + #ifndef __WINE_NONCLIENT_H #define __WINE_NONCLIENT_H -extern LONG NC_HandleNCPaint( HWND hwnd, HRGN hrgn ); +#include "windows.h" + +extern void NC_GetInsideRect( HWND hwnd, RECT *rect ); +extern void NC_DoNCPaint( HWND hwnd, BOOL active, BOOL suppress_menupaint ); +extern LONG NC_HandleNCPaint( HWND hwnd ); extern LONG NC_HandleNCActivate( HWND hwnd, WORD wParam ); extern LONG NC_HandleNCCalcSize( HWND hwnd, NCCALCSIZE_PARAMS *params ); extern LONG NC_HandleNCHitTest( HWND hwnd, POINT pt ); diff --git a/include/region.h b/include/region.h index a6fef596ac8..7d87c1360cc 100644 --- a/include/region.h +++ b/include/region.h @@ -9,23 +9,14 @@ #include "gdi.h" -typedef struct -{ - WORD type; - RECT box; - Pixmap pixmap; - Region xrgn; -} REGION; - /* GDI logical region object */ typedef struct { GDIOBJHDR header; - REGION region; + Region xrgn; } RGNOBJ; -extern BOOL REGION_Init(void); extern BOOL REGION_DeleteObject( HRGN hrgn, RGNOBJ * obj ); #endif /* __WINE_REGION_H */ diff --git a/include/segmem.h b/include/segmem.h index 4aa3f86739e..527002aeed1 100644 --- a/include/segmem.h +++ b/include/segmem.h @@ -28,6 +28,7 @@ */ #define MAX_SELECTORS 512 #define SELECTOR_ISFREE 0x8000 +#define SELECTOR_IS32BIT 0x4000 #define SELECTOR_INDEXMASK 0x0fff extern unsigned short SelectorMap[MAX_SELECTORS]; @@ -75,10 +76,16 @@ extern int IPCCopySelector(int i_old, unsigned long new, int swap_type); #define GLOBAL_FLAGS_EXECUTEONLY 0x00020000 #define GLOBAL_FLAGS_READONLY 0x00020000 +#ifdef __ELF__ +#define FIRST_SELECTOR 2 +#define IS_16_BIT_ADDRESS(addr) \ + (!(SelectorMap[(unsigned int)(addr)>>19]& SELECTOR_IS32BIT)) +#else #define FIRST_SELECTOR 8 - #define IS_16_BIT_ADDRESS(addr) \ ((unsigned int)(addr) >= (((FIRST_SELECTOR << 3) | 0x0007) << 16)) +#endif + extern SEGDESC Segments[]; diff --git a/include/selectors.h b/include/selectors.h index 921e65b73ab..7724f5cb771 100644 --- a/include/selectors.h +++ b/include/selectors.h @@ -23,5 +23,6 @@ extern unsigned int GetEntryDLLOrdinal(char *dll_name, int ordinal, int *sel, int *addr); extern unsigned int GetEntryPointFromOrdinal(struct w_files * wpnt, int ordinal); +extern void InitSelectors(void); #endif /* __WINE_SELECTORS_H */ diff --git a/include/win.h b/include/win.h index 9bb1087c5ff..0ffedbf0f6c 100644 --- a/include/win.h +++ b/include/win.h @@ -56,12 +56,13 @@ typedef struct tagWND } WND; /* WND flags values */ -#define WIN_ERASE_UPDATERGN 0x01 /* Update region needs erasing */ -#define WIN_NEEDS_BEGINPAINT 0x02 /* WM_PAINT sent to window */ -#define WIN_GOT_SIZEMSG 0x04 /* WM_SIZE has been sent to the window */ +#define WIN_NEEDS_BEGINPAINT 0x01 /* WM_PAINT sent to window */ +#define WIN_NEEDS_ERASEBKGND 0x02 /* WM_ERASEBKGND must be sent to window*/ +#define WIN_NEEDS_NCPAINT 0x04 /* WM_NCPAINT must be sent to window */ #define WIN_RESTORE_MAX 0x08 /* Maximize when restoring */ #define WIN_INTERNAL_PAINT 0x10 /* Internal WM_PAINT message pending */ #define WIN_NO_REDRAW 0x20 /* WM_SETREDRAW called for this window */ +#define WIN_GOT_SIZEMSG 0x40 /* WM_SIZE has been sent to the window */ #define WIN_CLASS_INFO(wndPtr) (CLASS_FindClassPtr((wndPtr)->hClass)->wc) #define WIN_CLASS_STYLE(wndPtr) (WIN_CLASS_INFO(wndPtr).style) diff --git a/include/windows.h b/include/windows.h index cb60ce0c4eb..65ebf083d6a 100644 --- a/include/windows.h +++ b/include/windows.h @@ -1468,9 +1468,6 @@ enum { WM_NULL, WM_CREATE, WM_DESTROY, WM_MOVE, WM_UNUSED0, WM_SIZE, WM_ACTIVATE #define SW_SHOWMINNOACTIVE 7 #define SW_SHOWNA 8 #define SW_RESTORE 9 -#define SW_INTERNAL_HIDE 20 -#define SW_INTERNAL_RESTORE 21 - /* WM_SIZE message wParam values */ #define SIZE_RESTORED 0 diff --git a/include/wine.h b/include/wine.h index cf7dfdc5792..bd426f378e7 100644 --- a/include/wine.h +++ b/include/wine.h @@ -1,5 +1,8 @@ #ifndef WINE_H #define WINE_H +#if 0 +#define __ELF__ +#endif extern char *WineIniFileName(void); extern char *WinIniFileName(void); @@ -33,8 +36,12 @@ struct sigcontext_struct { unsigned long cr2; }; #define WINE_DATA_SELECTOR 0x2b +#ifdef __ELF__ +#define WINE_CODE_SELECTOR 0x0f +#else #define WINE_CODE_SELECTOR 0x23 #endif +#endif #if defined(__NetBSD__) || defined(__FreeBSD__) #include diff --git a/loader/resource.c b/loader/resource.c index e09927b7ab7..e836aa49e18 100644 --- a/loader/resource.c +++ b/loader/resource.c @@ -355,11 +355,8 @@ HICON LoadIcon(HANDLE instance, LPSTR icon_name) BITMAPINFO *bmi; BITMAPINFOHEADER *bih; RGBQUAD *rgbq; - HDC hMemDC; - HDC hMemDC2; HDC hdc; int image_size; - HBITMAP hbmpOld1, hbmpOld2; if(debugging_resource){ printf("LoadIcon(%04X", instance); @@ -422,14 +419,9 @@ HICON LoadIcon(HANDLE instance, LPSTR icon_name) lpico->hBitmap = 0; bih->biBitCount = 1; bih->biClrUsed = bih->biClrImportant = 2; - rgbq[0].rgbBlue = 0xFF; - rgbq[0].rgbGreen = 0xFF; - rgbq[0].rgbRed = 0xFF; - rgbq[0].rgbReserved = 0x00; - rgbq[1].rgbBlue = 0x00; - rgbq[1].rgbGreen = 0x00; - rgbq[1].rgbRed = 0x00; - rgbq[1].rgbReserved = 0x00; + rgbq[0].rgbBlue = rgbq[0].rgbGreen = rgbq[0].rgbRed = 0x00; + rgbq[1].rgbBlue = rgbq[1].rgbGreen = rgbq[1].rgbRed = 0xff; + rgbq[0].rgbReserved = rgbq[1].rgbReserved = 0; if (bih->biSizeImage == 0) { if (bih->biCompression != BI_RGB) { fprintf(stderr,"Unknown size for compressed Icon bitmap.\n"); @@ -445,15 +437,6 @@ HICON LoadIcon(HANDLE instance, LPSTR icon_name) (BITMAPINFO *)bih, DIB_RGB_COLORS ); GlobalUnlock(rsc_mem); GlobalFree(rsc_mem); - hMemDC = CreateCompatibleDC(hdc); - hMemDC2 = CreateCompatibleDC(hdc); - hbmpOld1 = SelectObject(hMemDC, lpico->hBitmap); - hbmpOld2 = SelectObject(hMemDC2, lpico->hBitMask); - BitBlt(hMemDC, 0, 0, bih->biWidth, bih->biHeight, hMemDC2, 0, 0,SRCINVERT); - SelectObject( hMemDC, hbmpOld1 ); - SelectObject( hMemDC2, hbmpOld2 ); - DeleteDC(hMemDC); - DeleteDC(hMemDC2); ReleaseDC(GetDesktopWindow(), hdc); GlobalUnlock(hIcon); dprintf_resource(stddeb,"LoadIcon Alloc hIcon=%X\n", hIcon); diff --git a/loader/selector.c b/loader/selector.c index fe9ec2a6576..82544602e77 100644 --- a/loader/selector.c +++ b/loader/selector.c @@ -37,8 +37,12 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; #ifdef linux #define DEV_ZERO +#ifdef __ELF__ +#define UTEXTSEL 0x0f +#else #define UTEXTSEL 0x23 #endif +#endif #if defined(__NetBSD__) || defined(__FreeBSD__) #define PAGE_SIZE getpagesize() @@ -72,6 +76,35 @@ extern char **environ; unsigned int GetEntryPointFromOrdinal(struct w_files * wpnt, int ordinal); + + +/********************************************************************** + * InitSelectors + */ +void +InitSelectors(void) { + int i; + for (i = 0; i < MAX_SELECTORS; i++) { + if (i < FIRST_SELECTOR) { + SelectorMap[i] = SELECTOR_IS32BIT; +#ifdef __ELF__ + /* quick hack, just reserves 4 meg for wine. */ + } else if ((i << 19) >= 0x8000000 && + (i << 19) <= 0x8400000) { + SelectorMap[i]= SELECTOR_IS32BIT; +#endif + } else { + SelectorMap[i]=0; + } + } +#ifdef __ELF__ + /* create an ldt. */ + if (set_ldt_entry(1, 0x8000000, 65535, 1,0x1a ,1,0)) { + perror ("set_ldt_entry"); + exit (1); + } +#endif + } /********************************************************************** * FindUnusedSelectors @@ -90,6 +123,8 @@ FindUnusedSelectors(int n_selectors) n_found = 0; i = FIRST_SELECTOR; } + + if (SelectorMap[i] && n_found) n_found=0; if (!SelectorMap[i] && ++n_found == n_selectors) break; @@ -364,13 +399,13 @@ unsigned int PrestoChangoSelector(unsigned src_selector, unsigned dst_selector) if (zfile == NULL) zfile = fopen("/dev/zero","r"); p = (void *) mmap((char *) dst_s->base_addr, - ((dst_s->length + PAGE_SIZE) + ((dst_s->length + PAGE_SIZE-1) & ~(PAGE_SIZE - 1)), PROT_EXEC | PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, fileno(zfile), 0); #else p = (void *) mmap((char *) dst_s->base_addr, - ((dst_s->length + PAGE_SIZE) + ((dst_s->length + PAGE_SIZE-1) & ~(PAGE_SIZE - 1)), PROT_EXEC | PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0); diff --git a/loader/signal.c b/loader/signal.c index 51fa4306cb1..285571bea9b 100644 --- a/loader/signal.c +++ b/loader/signal.c @@ -13,12 +13,6 @@ #else #include #endif -#ifdef linux -#define inline __inline__ /* So we can compile with -ansi */ -#include -#include -#undef inline -#endif #include "wine.h" #include "dos_fs.h" diff --git a/misc/main.c b/misc/main.c index 03c7584b72f..b42072b6eda 100644 --- a/misc/main.c +++ b/misc/main.c @@ -25,6 +25,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1994"; #include "desktop.h" #include "prototypes.h" #include "texts.h" +#include "selectors.h" /* for InitSelectors prototype */ #define DEBUG_DEFINE_VARIABLES #include "stddebug.h" #include "debug.h" @@ -488,6 +489,7 @@ int main( int argc, char *argv[] ) if (Options.desktopGeometry) MAIN_CreateDesktop( argc, argv ); else rootWindow = DefaultRootWindow( display ); + InitSelectors(); MAIN_SaveSetup(); DOS_InitFS(); Comm_Init(); diff --git a/multimedia/audio.c b/multimedia/audio.c index e595c111676..84b8fb3635e 100644 --- a/multimedia/audio.c +++ b/multimedia/audio.c @@ -18,7 +18,7 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994"; #include #include #include -#include "win.h" +#include "windows.h" #include "user.h" #include "driver.h" #include "mmsystem.h" diff --git a/multimedia/mcianim.c b/multimedia/mcianim.c index 331ea5217dc..5b764e553b7 100644 --- a/multimedia/mcianim.c +++ b/multimedia/mcianim.c @@ -17,7 +17,7 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994"; #include #include #include -#include "win.h" +#include "windows.h" #include "user.h" #include "driver.h" #include "mmsystem.h" diff --git a/multimedia/mcicda.c b/multimedia/mcicda.c index 1339f1dd3e0..f60163d400d 100644 --- a/multimedia/mcicda.c +++ b/multimedia/mcicda.c @@ -17,7 +17,7 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994"; #include #include #include -#include "win.h" +#include "windows.h" #include "user.h" #include "driver.h" #include "mmsystem.h" diff --git a/multimedia/midi.c b/multimedia/midi.c index 05f271ba32b..6f4507a3005 100644 --- a/multimedia/midi.c +++ b/multimedia/midi.c @@ -16,7 +16,7 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994"; #include #include #include -#include "win.h" +#include "windows.h" #include "user.h" #include "driver.h" #include "mmsystem.h" diff --git a/multimedia/mmaux.c b/multimedia/mmaux.c index ea19e547b9a..78b9bf177cd 100644 --- a/multimedia/mmaux.c +++ b/multimedia/mmaux.c @@ -18,7 +18,7 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994"; #include #include #include -#include "win.h" +#include "windows.h" #include "user.h" #include "driver.h" #include "mmsystem.h" diff --git a/objects/bitblt.c b/objects/bitblt.c index a7b32708683..41f889d5da4 100644 --- a/objects/bitblt.c +++ b/objects/bitblt.c @@ -547,7 +547,7 @@ static void BITBLT_StretchRow( int *rowSrc, int *rowDst, */ static void BITBLT_ShrinkRow( int *rowSrc, int *rowDst, short startSrc, short widthSrc, - short xinc, WORD mode ) + int xinc, WORD mode ) { register int xdst = xinc * startSrc; rowSrc += startSrc; @@ -643,6 +643,10 @@ static void BITBLT_StretchImage( XImage *srcImage, XImage *dstImage, if ((widthSrc < widthDst) && (heightSrc < heightDst)) mode = STRETCH_DELETESCANS; + if (mode != STRETCH_DELETESCANS) + memset( rowDst, (mode == STRETCH_ANDSCANS) ? 0xff : 0x00, + widthDst*sizeof(int) ); + hstretch = ((widthSrc < widthDst) || (mode == STRETCH_DELETESCANS)); vstretch = ((heightSrc < heightDst) || (mode == STRETCH_DELETESCANS)); xinc = hstretch ? ((int)widthSrc << 16) / widthDst : @@ -1225,7 +1229,8 @@ BOOL BitBlt( HDC hdcDst, short xDst, short yDst, short width, short height, "BitBlt: %04x %d,%d %d bpp -> %04x %d,%d %dx%dx%d rop=%06lx\n", hdcSrc, xSrc, ySrc, dcSrc ? dcSrc->w.bitsPerPixel : 0, hdcDst, xDst, yDst, width, height, dcDst->w.bitsPerPixel, rop); - + dprintf_bitblt(stddeb," src org=%d,%d dst org=%d,%d\n", + dcSrc->w.DCOrgX, dcSrc->w.DCOrgY, dcDst->w.DCOrgX, dcDst->w.DCOrgY ); return BITBLT_InternalStretchBlt( dcDst, xDst, yDst, width, height, dcSrc, xSrc, ySrc, width, height, rop ); } diff --git a/objects/clipping.c b/objects/clipping.c index c6336138c29..42dda4e6eae 100644 --- a/objects/clipping.c +++ b/objects/clipping.c @@ -24,18 +24,11 @@ static void CLIPPING_SetDeviceClipping( DC * dc ) fprintf( stderr, "SetDeviceClipping: Rgn is 0. Please report this.\n"); exit(1); } - if (obj->region.xrgn) + if (obj->xrgn) { - XSetRegion( display, dc->u.x.gc, obj->region.xrgn ); + XSetRegion( display, dc->u.x.gc, obj->xrgn ); XSetClipOrigin( display, dc->u.x.gc, dc->w.DCOrgX, dc->w.DCOrgY ); } - else if (obj->region.pixmap) - { - XSetClipMask( display, dc->u.x.gc, obj->region.pixmap ); - XSetClipOrigin( display, dc->u.x.gc, - dc->w.DCOrgX + obj->region.box.left, - dc->w.DCOrgY + obj->region.box.top ); - } else /* Clip everything */ { XSetClipRectangles( display, dc->u.x.gc, 0, 0, NULL, 0, 0 ); @@ -74,7 +67,7 @@ int SelectClipRgn( HDC hdc, HRGN hrgn ) DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; - dprintf_clipping(stddeb, "SelectClipRgn: %d %d\n", hdc, hrgn ); + dprintf_clipping(stddeb, "SelectClipRgn: %x %x\n", hdc, hrgn ); if (hrgn) { @@ -101,7 +94,7 @@ int SelectVisRgn( HDC hdc, HRGN hrgn ) DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc || !hrgn) return ERROR; - dprintf_clipping(stddeb, "SelectVisRgn: %d %d\n", hdc, hrgn ); + dprintf_clipping(stddeb, "SelectVisRgn: %x %x\n", hdc, hrgn ); retval = CombineRgn( dc->w.hVisRgn, hrgn, 0, RGN_COPY ); CLIPPING_UpdateGCRegion( dc ); @@ -123,7 +116,7 @@ int OffsetClipRgn( HDC hdc, short x, short y ) return NULLREGION; /* ?? */ } - dprintf_clipping(stddeb, "OffsetClipRgn: %d %d,%d\n", hdc, x, y ); + dprintf_clipping(stddeb, "OffsetClipRgn: %x %d,%d\n", hdc, x, y ); if (dc->w.hClipRgn) { @@ -143,7 +136,7 @@ int OffsetVisRgn( HDC hdc, short x, short y ) int retval; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; - dprintf_clipping(stddeb, "OffsetVisRgn: %d %d,%d\n", hdc, x, y ); + dprintf_clipping(stddeb, "OffsetVisRgn: %x %d,%d\n", hdc, x, y ); retval = OffsetRgn( dc->w.hVisRgn, x, y ); CLIPPING_UpdateGCRegion( dc ); return retval; @@ -202,7 +195,7 @@ int ExcludeClipRect( HDC hdc, short left, short top, return NULLREGION; /* ?? */ } - dprintf_clipping(stddeb, "ExcludeClipRect: %d %dx%d,%dx%d\n", + dprintf_clipping(stddeb, "ExcludeClipRect: %x %dx%d,%dx%d\n", hdc, left, top, right, bottom ); return CLIPPING_IntersectClipRect( dc, left, top, right, bottom, TRUE ); } @@ -223,7 +216,7 @@ int IntersectClipRect( HDC hdc, short left, short top, return NULLREGION; /* ?? */ } - dprintf_clipping(stddeb, "IntersectClipRect: %d %dx%d,%dx%d\n", + dprintf_clipping(stddeb, "IntersectClipRect: %x %dx%d,%dx%d\n", hdc, left, top, right, bottom ); return CLIPPING_IntersectClipRect( dc, left, top, right, bottom, FALSE ); } @@ -276,7 +269,7 @@ int ExcludeVisRect( HDC hdc, short left, short top, short right, short bottom ) { DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; - dprintf_clipping(stddeb, "ExcludeVisRect: %d %dx%d,%dx%d\n", + dprintf_clipping(stddeb, "ExcludeVisRect: %x %dx%d,%dx%d\n", hdc, left, top, right, bottom ); return CLIPPING_IntersectVisRect( dc, left, top, right, bottom, TRUE ); } @@ -290,7 +283,7 @@ int IntersectVisRect( HDC hdc, short left, short top, { DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; - dprintf_clipping(stddeb, "IntersectVisRect: %d %dx%d,%dx%d\n", + dprintf_clipping(stddeb, "IntersectVisRect: %x %dx%d,%dx%d\n", hdc, left, top, right, bottom ); return CLIPPING_IntersectVisRect( dc, left, top, right, bottom, FALSE ); } @@ -304,7 +297,7 @@ BOOL PtVisible( HDC hdc, short x, short y ) DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; - dprintf_clipping(stddeb, "PtVisible: %d %d,%d\n", hdc, x, y ); + dprintf_clipping(stddeb, "PtVisible: %x %d,%d\n", hdc, x, y ); if (!dc->w.hGCClipRgn) return FALSE; return PtInRegion( dc->w.hGCClipRgn, XLPTODP(dc,x), YLPTODP(dc,y) ); } @@ -318,7 +311,8 @@ BOOL RectVisible( HDC hdc, LPRECT rect ) RECT tmpRect; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return FALSE; - dprintf_clipping(stddeb,"RectVisible: %d %p\n", hdc, rect ); + dprintf_clipping(stddeb,"RectVisible: %x %d,%dx%d,%d\n", + hdc, rect->left, rect->top, rect->right, rect->bottom ); if (!dc->w.hGCClipRgn) return FALSE; LPtoDP( hdc, (LPPOINT)rect, 2 ); return RectInRegion( dc->w.hGCClipRgn, &tmpRect ); @@ -333,7 +327,7 @@ int GetClipBox( HDC hdc, LPRECT rect ) int ret; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; - dprintf_clipping(stddeb, "GetClipBox: %d %p\n", hdc, rect ); + dprintf_clipping(stddeb, "GetClipBox: %x %p\n", hdc, rect ); ret = GetRgnBox( dc->w.hGCClipRgn, rect ); DPtoLP( hdc, (LPPOINT)rect, 2 ); return ret; @@ -349,7 +343,7 @@ HRGN SaveVisRgn( HDC hdc ) RGNOBJ *obj, *copyObj; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return 0; - dprintf_clipping(stddeb, "SaveVisRgn: %d\n", hdc ); + dprintf_clipping(stddeb, "SaveVisRgn: %x\n", hdc ); if (!dc->w.hVisRgn) { fprintf( stderr, "SaveVisRgn: hVisRgn is zero. Please report this.\n" ); @@ -376,7 +370,7 @@ int RestoreVisRgn( HDC hdc ) RGNOBJ *obj, *savedObj; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc || !dc->w.hVisRgn) return ERROR; - dprintf_clipping(stddeb, "RestoreVisRgn: %d\n", hdc ); + dprintf_clipping(stddeb, "RestoreVisRgn: %x\n", hdc ); if (!(obj = (RGNOBJ *) GDI_GetObjPtr( dc->w.hVisRgn, REGION_MAGIC ))) return ERROR; if (!(saved = obj->header.hNext)) return ERROR; @@ -385,5 +379,5 @@ int RestoreVisRgn( HDC hdc ) DeleteObject( dc->w.hVisRgn ); dc->w.hVisRgn = saved; CLIPPING_UpdateGCRegion( dc ); - return savedObj->region.type; + return savedObj->xrgn ? COMPLEXREGION : NULLREGION; } diff --git a/objects/color.c b/objects/color.c index 68b029e4387..07acaf3c7af 100644 --- a/objects/color.c +++ b/objects/color.c @@ -105,19 +105,25 @@ static HPALETTE COLOR_InitPalette(void) size = DefaultVisual( display, DefaultScreen(display) )->map_entries; COLOR_ColormapSize = size; - if (!(hSysColorTranslation = GDI_HEAP_ALLOC( GMEM_MOVEABLE, - sizeof(WORD)*NB_RESERVED_COLORS ))) - return FALSE; - if (!(hRevSysColorTranslation = GDI_HEAP_ALLOC( GMEM_MOVEABLE, - sizeof(WORD)*size ))) - return FALSE; - colorTranslation = (WORD *) GDI_HEAP_ADDR( hSysColorTranslation ); - revTranslation = (WORD *) GDI_HEAP_ADDR( hRevSysColorTranslation ); + if (screenDepth <= 8) + { + if (!(hSysColorTranslation = GDI_HEAP_ALLOC( GMEM_MOVEABLE, + sizeof(WORD)*NB_RESERVED_COLORS ))) + return FALSE; + if (!(hRevSysColorTranslation = GDI_HEAP_ALLOC( GMEM_MOVEABLE, + sizeof(WORD)*size ))) + return FALSE; + colorTranslation = (WORD *) GDI_HEAP_ADDR( hSysColorTranslation ); + revTranslation = (WORD *) GDI_HEAP_ADDR( hRevSysColorTranslation ); + } + else colorTranslation = revTranslation = NULL; if ((COLOR_WinColormap == DefaultColormapOfScreen(screen)) && (screenDepth <= 8)) { COLOR_PaletteToPixel = (int *)malloc( sizeof(int) * size ); COLOR_PixelToPalette = (int *)malloc( sizeof(int) * size ); + for (i = 0; i < size; i++) /* Set the default mapping */ + COLOR_PaletteToPixel[i] = COLOR_PixelToPalette[i] = i; } for (i = 0; i < NB_RESERVED_COLORS; i++) @@ -157,8 +163,8 @@ static HPALETTE COLOR_InitPalette(void) COLOR_PixelToPalette[color.pixel] = pixel; } } - colorTranslation[i] = color.pixel; - revTranslation[color.pixel] = i; + if (colorTranslation) colorTranslation[i] = color.pixel; + if (revTranslation) revTranslation[color.pixel] = i; /* Set EGA mapping if color in the first or last eight */ if (i < 8) COLOR_mapEGAPixel[i] = color.pixel; diff --git a/objects/dib.c b/objects/dib.c index 40039af1162..d0549492517 100644 --- a/objects/dib.c +++ b/objects/dib.c @@ -670,33 +670,14 @@ BOOL DrawIcon(HDC hDC, short x, short y, HICON hIcon) if (hIcon == (HICON)NULL) return FALSE; lpico = (ICONALLOC *)GlobalLock(hIcon); GetObject(lpico->hBitmap, sizeof(BITMAP), (LPSTR)&bm); - dprintf_icon(stddeb,"DrawIcon / x=%d y=%d\n", x, y); - dprintf_icon(stddeb,"DrawIcon / icon Width=%d\n", - (int)lpico->descriptor.Width); - dprintf_icon(stddeb,"DrawIcon / icon Height=%d\n", - (int)lpico->descriptor.Height); - dprintf_icon(stddeb,"DrawIcon / icon ColorCount=%d\n", - (int)lpico->descriptor.ColorCount); - dprintf_icon(stddeb,"DrawIcon / icon icoDIBSize=%lX\n", - (DWORD)lpico->descriptor.icoDIBSize); - dprintf_icon(stddeb,"DrawIcon / icon icoDIBOffset=%lX\n", - (DWORD)lpico->descriptor.icoDIBOffset); - dprintf_icon(stddeb,"DrawIcon / bitmap bmWidth=%d bmHeight=%d\n", - bm.bmWidth, bm.bmHeight); hMemDC = CreateCompatibleDC(hDC); - if(debugging_icon){ - hBitTemp = SelectObject(hMemDC, lpico->hBitmap); - BitBlt(hDC, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); - SelectObject(hMemDC, lpico->hBitMask); - BitBlt(hDC, x, y + bm.bmHeight, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY); - }else{ hBitTemp = SelectObject(hMemDC, lpico->hBitMask); BitBlt(hDC, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCAND); SelectObject(hMemDC, lpico->hBitmap); - BitBlt(hDC, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCPAINT); - } + BitBlt(hDC, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCINVERT); SelectObject( hMemDC, hBitTemp ); DeleteDC(hMemDC); + GlobalUnlock( hIcon ); return TRUE; } diff --git a/objects/gdiobj.c b/objects/gdiobj.c index 3d591d680ec..340c95d7b6b 100644 --- a/objects/gdiobj.c +++ b/objects/gdiobj.c @@ -181,10 +181,6 @@ BOOL GDI_Init(void) if (!BITMAP_Init()) return FALSE; - /* Initialise regions */ - - if (!REGION_Init()) return FALSE; - /* Initialise brush dithering */ if (!BRUSH_Init()) return FALSE; diff --git a/objects/region.c b/objects/region.c index c83a2c12e2d..288d70f5452 100644 --- a/objects/region.c +++ b/objects/region.c @@ -1,10 +1,10 @@ /* * GDI region objects * - * Copyright 1993, 1994 Alexandre Julliard + * Copyright 1993, 1994, 1995 Alexandre Julliard * -static char Copyright[] = "Copyright Alexandre Julliard, 1993, 1994"; -*/ + */ + #include #include @@ -13,109 +13,14 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993, 1994"; /* #define DEBUG_REGION */ #include "debug.h" - /* GC used for region operations */ -static GC regionGC = 0; - -/*********************************************************************** - * REGION_Init - */ -BOOL REGION_Init(void) -{ - Pixmap tmpPixmap; - - /* CreateGC needs a drawable */ - tmpPixmap = XCreatePixmap( display, rootWindow, 1, 1, 1 ); - if (tmpPixmap) - { - regionGC = XCreateGC( display, tmpPixmap, 0, NULL ); - XFreePixmap( display, tmpPixmap ); - if (!regionGC) return FALSE; - XSetForeground( display, regionGC, 1 ); - XSetGraphicsExposures( display, regionGC, False ); - return TRUE; - } - else return FALSE; -} - - -/*********************************************************************** - * REGION_MakePixmap - * - * Make a pixmap of an X region. - */ -static BOOL REGION_MakePixmap( REGION *region ) -{ - int width = region->box.right - region->box.left; - int height = region->box.bottom - region->box.top; - - if (!region->xrgn) return TRUE; /* Null region */ - region->pixmap = XCreatePixmap( display, rootWindow, width, height, 1 ); - if (!region->pixmap) return FALSE; - XSetRegion( display, regionGC, region->xrgn ); - XSetClipOrigin( display, regionGC, -region->box.left, -region->box.top ); - XSetFunction( display, regionGC, GXset ); - XFillRectangle( display, region->pixmap, regionGC, 0, 0, width, height ); - XSetClipMask( display, regionGC, None ); /* Clear clip region */ - return TRUE; -} - - -/*********************************************************************** - * REGION_SetRect - * - * Set the bounding box of the region and create the pixmap (or the X rgn). - * The hrgn must be valid. - */ -static BOOL REGION_SetRect( HRGN hrgn, LPRECT rect, BOOL createXrgn ) -{ - int width, height; - - /* Fill region */ - - REGION * region = &((RGNOBJ *)GDI_HEAP_ADDR( hrgn ))->region; - width = rect->right - rect->left; - height = rect->bottom - rect->top; - if ((width <= 0) || (height <= 0)) - { - region->type = NULLREGION; - region->box.left = 0; - region->box.right = 0; - region->box.top = 0; - region->box.bottom = 0; - region->pixmap = 0; - region->xrgn = 0; - return TRUE; - } - region->type = SIMPLEREGION; - region->box = *rect; - region->xrgn = 0; - region->pixmap = 0; - - if (createXrgn) /* Create and set the X region */ - { - XRectangle xrect = { region->box.left, region->box.top, width, height}; - if (!(region->xrgn = XCreateRegion())) return FALSE; - XUnionRectWithRegion( &xrect, region->xrgn, region->xrgn ); - } - else /* Create the pixmap */ - { - region->pixmap = XCreatePixmap( display, rootWindow, width, height, 1); - if (!region->pixmap) return FALSE; - /* Fill the pixmap */ - XSetFunction( display, regionGC, GXclear ); - XFillRectangle(display, region->pixmap, regionGC, 0, 0, width, height); - } - return TRUE; -} - /*********************************************************************** * REGION_DeleteObject */ BOOL REGION_DeleteObject( HRGN hrgn, RGNOBJ * obj ) { - if (obj->region.pixmap) XFreePixmap( display, obj->region.pixmap ); - if (obj->region.xrgn) XDestroyRegion( obj->region.xrgn ); + dprintf_region(stddeb, "DeleteRegion: %x\n", hrgn ); + if (obj->xrgn) XDestroyRegion( obj->xrgn ); return GDI_FreeObject( hrgn ); } @@ -128,9 +33,9 @@ int OffsetRgn( HRGN hrgn, short x, short y ) RGNOBJ * obj = (RGNOBJ *) GDI_GetObjPtr( hrgn, REGION_MAGIC ); if (!obj) return ERROR; dprintf_region(stddeb, "OffsetRgn: %d %d,%d\n", hrgn, x, y ); - OffsetRect( &obj->region.box, x, y ); - if (obj->region.xrgn) XOffsetRegion( obj->region.xrgn, x, y ); - return obj->region.type; + if (!obj->xrgn) return NULLREGION; + XOffsetRegion( obj->xrgn, x, y ); + return COMPLEXREGION; } @@ -142,8 +47,19 @@ int GetRgnBox( HRGN hrgn, LPRECT rect ) RGNOBJ * obj = (RGNOBJ *) GDI_GetObjPtr( hrgn, REGION_MAGIC ); if (!obj) return ERROR; dprintf_region(stddeb, "GetRgnBox: %d\n", hrgn ); - *rect = obj->region.box; - return obj->region.type; + if (!obj->xrgn) + { + SetRectEmpty( rect ); + return NULLREGION; + } + else + { + XRectangle xrect; + XClipBox( obj->xrgn, &xrect ); + SetRect( rect, xrect.x, xrect.y, + xrect.x + xrect.width, xrect.y + xrect.height); + return COMPLEXREGION; + } } @@ -152,8 +68,25 @@ int GetRgnBox( HRGN hrgn, LPRECT rect ) */ HRGN CreateRectRgn( short left, short top, short right, short bottom ) { - RECT rect = { left, top, right, bottom }; - return CreateRectRgnIndirect( &rect ); + HRGN hrgn; + RGNOBJ *obj; + + if (!(hrgn = GDI_AllocObject( sizeof(RGNOBJ), REGION_MAGIC ))) return 0; + obj = (RGNOBJ *) GDI_HEAP_ADDR( hrgn ); + if ((right > left) && (bottom > top)) + { + XRectangle rect = { left, top, right - left, bottom - top }; + if (!(obj->xrgn = XCreateRegion())) + { + GDI_FreeObject( hrgn ); + return 0; + } + XUnionRectWithRegion( &rect, obj->xrgn, obj->xrgn ); + } + else obj->xrgn = 0; + dprintf_region( stddeb, "CreateRectRgn(%d,%d-%d,%d): returning %x\n", + left, top, right, bottom, hrgn ); + return hrgn; } @@ -162,20 +95,29 @@ HRGN CreateRectRgn( short left, short top, short right, short bottom ) */ HRGN CreateRectRgnIndirect( LPRECT rect ) { - HRGN hrgn; + return CreateRectRgn( rect->left, rect->top, rect->right, rect->bottom ); +} - dprintf_region(stddeb, "CreateRectRgnIndirect: %d,%d-%d,%d\n", - rect->left, rect->top, rect->right, rect->bottom ); + +/*********************************************************************** + * SetRectRgn (GDI.172) + */ +void SetRectRgn( HRGN hrgn, short left, short top, short right, short bottom ) +{ + RGNOBJ * obj; + + dprintf_region(stddeb, "SetRectRgn: %x %d,%d-%d,%d\n", + hrgn, left, top, right, bottom ); - /* Create region */ - - if (!(hrgn = GDI_AllocObject( sizeof(RGNOBJ), REGION_MAGIC ))) return 0; - if (!REGION_SetRect( hrgn, rect, TRUE )) + if (!(obj = (RGNOBJ *) GDI_GetObjPtr( hrgn, REGION_MAGIC ))) return; + if (obj->xrgn) XDestroyRegion( obj->xrgn ); + if ((right > left) && (bottom > top)) { - GDI_FreeObject( hrgn ); - return 0; + XRectangle rect = { left, top, right - left, bottom - top }; + if ((obj->xrgn = XCreateRegion()) != 0) + XUnionRectWithRegion( &rect, obj->xrgn, obj->xrgn ); } - return hrgn; + else obj->xrgn = 0; } @@ -185,81 +127,103 @@ HRGN CreateRectRgnIndirect( LPRECT rect ) HRGN CreateRoundRectRgn( short left, short top, short right, short bottom, short ellipse_width, short ellipse_height ) { - RECT rect = { left, top, right, bottom }; - RGNOBJ * rgnObj; + RGNOBJ * obj; HRGN hrgn; + XRectangle rect; + int asq, bsq, d, xd, yd; + + /* Check if we can do a normal rectangle instead */ + + if ((right <= left) || (bottom <= top) || + (ellipse_width <= 0) || (ellipse_height <= 0)) + return CreateRectRgn( left, top, right, bottom ); - dprintf_region(stddeb, "CreateRoundRectRgn: %d,%d-%d,%d %dx%d\n", - left, top, right, bottom, ellipse_width, ellipse_height ); - /* Create region */ if (!(hrgn = GDI_AllocObject( sizeof(RGNOBJ), REGION_MAGIC ))) return 0; - if (!REGION_SetRect( hrgn, &rect, FALSE )) - { - GDI_FreeObject( hrgn ); - return 0; - } - rgnObj = (RGNOBJ *) GDI_HEAP_ADDR( hrgn ); + obj = (RGNOBJ *) GDI_HEAP_ADDR( hrgn ); + obj->xrgn = XCreateRegion(); + dprintf_region(stddeb,"CreateRoundRectRgn(%d,%d-%d,%d %dx%d): return=%x\n", + left, top, right, bottom, ellipse_width, ellipse_height, hrgn ); - /* Fill pixmap */ - - if (rgnObj->region.type != NULLREGION) + /* Check parameters */ + + if (ellipse_width > right-left) ellipse_width = right-left; + if (ellipse_height > bottom-top) ellipse_height = bottom-top; + + /* Ellipse algorithm, based on an article by K. Porter */ + /* in DDJ Graphics Programming Column, 8/89 */ + + asq = ellipse_width * ellipse_width / 4; /* a^2 */ + bsq = ellipse_height * ellipse_height / 4; /* b^2 */ + d = bsq - asq * ellipse_height / 2 + asq / 4; /* b^2 - a^2b + a^2/4 */ + xd = 0; + yd = asq * ellipse_height; /* 2a^2b */ + + rect.x = left + ellipse_width / 2; + rect.width = right - left - ellipse_width; + rect.height = 1; + + /* Loop to draw first half of quadrant */ + + while (xd < yd) { - int width = rgnObj->region.box.right - rgnObj->region.box.left; - int height = rgnObj->region.box.bottom - rgnObj->region.box.top; - XSetFunction( display, regionGC, GXcopy ); - XFillRectangle( display, rgnObj->region.pixmap, regionGC, - 0, ellipse_height / 2, - width, height - ellipse_height ); - XFillRectangle( display, rgnObj->region.pixmap, regionGC, - ellipse_width / 2, 0, - width - ellipse_width, height ); - XFillArc( display, rgnObj->region.pixmap, regionGC, - 0, 0, - ellipse_width, ellipse_height, 0, 360*64 ); - XFillArc( display, rgnObj->region.pixmap, regionGC, - width - ellipse_width, 0, - ellipse_width, ellipse_height, 0, 360*64 ); - XFillArc( display, rgnObj->region.pixmap, regionGC, - 0, height - ellipse_height, - ellipse_width, ellipse_height, 0, 360*64 ); - XFillArc( display, rgnObj->region.pixmap, regionGC, - width - ellipse_width, height - ellipse_height, - ellipse_width, ellipse_height, 0, 360*64 ); + if (d > 0) /* if nearest pixel is toward the center */ + { + /* move toward center */ + rect.y = top++; + XUnionRectWithRegion( &rect, obj->xrgn, obj->xrgn ); + rect.y = --bottom; + XUnionRectWithRegion( &rect, obj->xrgn, obj->xrgn ); + yd -= 2*asq; + d -= yd; + } + rect.x--; /* next horiz point */ + rect.width += 2; + xd += 2*bsq; + d += bsq + xd; + } + + /* Loop to draw second half of quadrant */ + + d += (3 * (asq-bsq) / 2 - (xd+yd)) / 2; + while (yd >= 0) + { + /* next vertical point */ + rect.y = top++; + XUnionRectWithRegion( &rect, obj->xrgn, obj->xrgn ); + rect.y = --bottom; + XUnionRectWithRegion( &rect, obj->xrgn, obj->xrgn ); + if (d < 0) /* if nearest pixel is outside ellipse */ + { + rect.x--; /* move away from center */ + rect.width += 2; + xd += 2*bsq; + d += xd; + } + yd -= 2*asq; + d += asq - yd; + } + + /* Add the inside rectangle */ + + if (top <= bottom) + { + rect.y = top; + rect.height = bottom - top + 1; + XUnionRectWithRegion( &rect, obj->xrgn, obj->xrgn ); } - return hrgn; } -/*********************************************************************** - * SetRectRgn (GDI.172) - */ -void SetRectRgn( HRGN hrgn, short left, short top, short right, short bottom ) -{ - RECT rect = { left, top, right, bottom }; - RGNOBJ * rgnObj; - - dprintf_region(stddeb, "SetRectRgn: %d %d,%d-%d,%d\n", - hrgn, left, top, right, bottom ); - - /* Free previous pixmap */ - - if (!(rgnObj = (RGNOBJ *) GDI_GetObjPtr( hrgn, REGION_MAGIC ))) return; - if (rgnObj->region.pixmap) XFreePixmap( display, rgnObj->region.pixmap ); - if (rgnObj->region.xrgn) XDestroyRegion( rgnObj->region.xrgn ); - REGION_SetRect( hrgn, &rect, TRUE ); -} - - /*********************************************************************** * CreateEllipticRgn (GDI.54) */ HRGN CreateEllipticRgn( short left, short top, short right, short bottom ) { - RECT rect = { left, top, right, bottom }; - return CreateEllipticRgnIndirect( &rect ); + return CreateRoundRectRgn( left, top, right, bottom, + right-left, bottom-top ); } @@ -268,34 +232,8 @@ HRGN CreateEllipticRgn( short left, short top, short right, short bottom ) */ HRGN CreateEllipticRgnIndirect( LPRECT rect ) { - RGNOBJ * rgnObj; - HRGN hrgn; - - dprintf_region(stddeb, "CreateEllipticRgnIndirect: %d,%d-%d,%d\n", - rect->left, rect->top, rect->right, rect->bottom ); - - /* Create region */ - - if (!(hrgn = GDI_AllocObject( sizeof(RGNOBJ), REGION_MAGIC ))) return 0; - if (!REGION_SetRect( hrgn, rect, FALSE )) - { - GDI_FreeObject( hrgn ); - return 0; - } - rgnObj = (RGNOBJ *) GDI_HEAP_ADDR( hrgn ); - - /* Fill pixmap */ - - if (rgnObj->region.type != NULLREGION) - { - int width = rgnObj->region.box.right - rgnObj->region.box.left; - int height = rgnObj->region.box.bottom - rgnObj->region.box.top; - XSetFunction( display, regionGC, GXcopy ); - XFillArc( display, rgnObj->region.pixmap, regionGC, - 0, 0, width, height, 0, 360*64 ); - } - - return hrgn; + return CreateRoundRectRgn(rect->left, rect->top, rect->right, rect->bottom, + rect->right-rect->left, rect->bottom-rect->top ); } @@ -314,15 +252,12 @@ HRGN CreatePolygonRgn( POINT * points, short count, short mode ) HRGN CreatePolyPolygonRgn( POINT * points, short * count, short nbpolygons, short mode ) { - RGNOBJ * rgnObj; + RGNOBJ * obj; HRGN hrgn; int i, j, maxPoints; XPoint *xpoints, *pt; - XRectangle rect; Region xrgn; - dprintf_region(stddeb, "CreatePolyPolygonRgn: %d polygons\n", nbpolygons ); - /* Allocate points array */ if (!nbpolygons) return 0; @@ -339,10 +274,10 @@ HRGN CreatePolyPolygonRgn( POINT * points, short * count, free( xpoints ); return 0; } - rgnObj = (RGNOBJ *) GDI_HEAP_ADDR( hrgn ); - rgnObj->region.type = SIMPLEREGION; - rgnObj->region.xrgn = 0; - rgnObj->region.pixmap = 0; + obj = (RGNOBJ *) GDI_HEAP_ADDR( hrgn ); + obj->xrgn = 0; + dprintf_region(stddeb, "CreatePolyPolygonRgn: %d polygons, returning %x\n", + nbpolygons, hrgn ); /* Create X region */ @@ -357,7 +292,7 @@ HRGN CreatePolyPolygonRgn( POINT * points, short * count, (mode == WINDING) ? WindingRule : EvenOddRule ); if (!xrgn) { - if (rgnObj->region.xrgn) XDestroyRegion( rgnObj->region.xrgn ); + if (obj->xrgn) XDestroyRegion( obj->xrgn ); free( xpoints ); GDI_FreeObject( hrgn ); return 0; @@ -365,18 +300,15 @@ HRGN CreatePolyPolygonRgn( POINT * points, short * count, if (i > 0) { Region tmprgn = XCreateRegion(); - if (mode == WINDING) XUnionRegion(xrgn,rgnObj->region.xrgn,tmprgn); - else XXorRegion( xrgn, rgnObj->region.xrgn, tmprgn ); - XDestroyRegion( rgnObj->region.xrgn ); - rgnObj->region.xrgn = tmprgn; + if (mode == WINDING) XUnionRegion( xrgn, obj->xrgn, tmprgn ); + else XXorRegion( xrgn, obj->xrgn, tmprgn ); + XDestroyRegion( obj->xrgn ); + obj->xrgn = tmprgn; } - else rgnObj->region.xrgn = xrgn; + else obj->xrgn = xrgn; } free( xpoints ); - XClipBox( rgnObj->region.xrgn, &rect ); - SetRect( &rgnObj->region.box, rect.x, rect.y, - rect.x + rect.width, rect.y + rect.height); return hrgn; } @@ -386,26 +318,11 @@ HRGN CreatePolyPolygonRgn( POINT * points, short * count, */ BOOL PtInRegion( HRGN hrgn, short x, short y ) { - BOOL res; RGNOBJ * obj; - POINT pt = { x, y }; if (!(obj = (RGNOBJ *) GDI_GetObjPtr( hrgn, REGION_MAGIC ))) return FALSE; - if (!PtInRect( &obj->region.box, pt )) return FALSE; - if (obj->region.xrgn) - { - return XPointInRegion( obj->region.xrgn, x, y ); - } - else - { - XImage *image = XGetImage( display, obj->region.pixmap, - x - obj->region.box.left, y - obj->region.box.top, - 1, 1, AllPlanes, ZPixmap ); - if (!image) return FALSE; - res = (XGetPixel( image, 0, 0 ) != 0); - XDestroyImage( image ); - } - return res; + if (!obj->xrgn) return FALSE; + return XPointInRegion( obj->xrgn, x, y ); } @@ -414,40 +331,13 @@ BOOL PtInRegion( HRGN hrgn, short x, short y ) */ BOOL RectInRegion( HRGN hrgn, LPRECT rect ) { - XImage * image; RGNOBJ * obj; - RECT intersect; - int x, y; if (!(obj = (RGNOBJ *) GDI_GetObjPtr( hrgn, REGION_MAGIC ))) return FALSE; - if (obj->region.xrgn) - { - return (XRectInRegion( obj->region.xrgn, rect->left, rect->top, - rect->right-rect->left, - rect->bottom-rect->top ) != RectangleOut); - } - else - { - if (!IntersectRect( &intersect, &obj->region.box, rect )) return FALSE; - - image = XGetImage( display, obj->region.pixmap, - intersect.left - obj->region.box.left, - intersect.top - obj->region.box.top, - intersect.right - intersect.left, - intersect.bottom - intersect.top, - AllPlanes, ZPixmap ); - if (!image) return FALSE; - for (y = 0; y < image->height; y++) - for (x = 0; x < image->width; x++) - if (XGetPixel( image, x, y ) != 0) - { - XDestroyImage( image ); - return TRUE; - } - - XDestroyImage( image ); - } - return FALSE; + if (!obj->xrgn) return FALSE; + return (XRectInRegion( obj->xrgn, rect->left, rect->top, + rect->right-rect->left, + rect->bottom-rect->top ) != RectangleOut); } @@ -457,72 +347,10 @@ BOOL RectInRegion( HRGN hrgn, LPRECT rect ) BOOL EqualRgn( HRGN rgn1, HRGN rgn2 ) { RGNOBJ *obj1, *obj2; - XImage *image1, *image2; - Pixmap pixmap1, pixmap2; - int width, height, x, y; - - /* Compare bounding boxes */ - if (!(obj1 = (RGNOBJ *) GDI_GetObjPtr( rgn1, REGION_MAGIC ))) return FALSE; if (!(obj2 = (RGNOBJ *) GDI_GetObjPtr( rgn2, REGION_MAGIC ))) return FALSE; - if (obj1->region.type == NULLREGION) - return (obj2->region.type == NULLREGION); - else if (obj2->region.type == NULLREGION) return FALSE; - if (!EqualRect( &obj1->region.box, &obj2->region.box )) return FALSE; - if (obj1->region.xrgn && obj2->region.xrgn) - { - return XEqualRegion( obj1->region.xrgn, obj2->region.xrgn ); - } - - /* Get pixmap contents */ - - if (!(pixmap1 = obj1->region.pixmap) && - !REGION_MakePixmap( &obj1->region )) return FALSE; - if (!(pixmap2 = obj2->region.pixmap) && - !REGION_MakePixmap( &obj2->region )) return FALSE; - width = obj1->region.box.right - obj1->region.box.left; - height = obj1->region.box.bottom - obj1->region.box.top; - image1 = XGetImage( display, obj1->region.pixmap, - 0, 0, width, height, AllPlanes, ZPixmap ); - image2 = XGetImage( display, obj2->region.pixmap, - 0, 0, width, height, AllPlanes, ZPixmap ); - if (!image1 || !image2) - { - if (image1) XDestroyImage( image1 ); - if (image2) XDestroyImage( image2 ); - return FALSE; - } - - /* Compare pixmaps */ - for (y = 0; y < height; y++) - for (x = 0; x < width; x++) - if (XGetPixel( image1, x, y ) != XGetPixel( image2, x, y)) - { - XDestroyImage( image1 ); - XDestroyImage( image2 ); - return FALSE; - } - - XDestroyImage( image1 ); - XDestroyImage( image2 ); - return TRUE; -} - - -/*********************************************************************** - * REGION_CopyIntersection - * - * Copy to dest->pixmap the area of src->pixmap delimited by - * the intersection of dest and src regions, using the current GC function. - */ -void REGION_CopyIntersection( REGION * dest, REGION * src ) -{ - RECT inter; - if (!IntersectRect( &inter, &dest->box, &src->box )) return; - XCopyArea( display, src->pixmap, dest->pixmap, regionGC, - inter.left - src->box.left, inter.top - src->box.top, - inter.right - inter.left, inter.bottom - inter.top, - inter.left - dest->box.left, inter.top - dest->box.top ); + if (!obj1->xrgn || !obj2->xrgn) return (!obj1->xrgn && !obj2->xrgn); + return XEqualRegion( obj1->xrgn, obj2->xrgn ); } @@ -533,37 +361,20 @@ void REGION_CopyIntersection( REGION * dest, REGION * src ) */ static int REGION_CopyRegion( RGNOBJ *src, RGNOBJ *dest ) { - if (dest->region.pixmap) XFreePixmap( display, dest->region.pixmap ); - dest->region.type = src->region.type; - dest->region.box = src->region.box; - dest->region.pixmap = 0; - if (src->region.xrgn) /* Copy only the X region */ + if (src->xrgn) { Region tmprgn = XCreateRegion(); - if (!dest->region.xrgn) dest->region.xrgn = XCreateRegion(); - XUnionRegion( tmprgn, src->region.xrgn, dest->region.xrgn ); + if (!dest->xrgn) dest->xrgn = XCreateRegion(); + XUnionRegion( tmprgn, src->xrgn, dest->xrgn ); XDestroyRegion( tmprgn ); + return COMPLEXREGION; } - else /* Copy the pixmap (if any) */ + else { - if (dest->region.xrgn) - { - XDestroyRegion( dest->region.xrgn ); - dest->region.xrgn = 0; - } - if (src->region.pixmap) - { - int width = src->region.box.right - src->region.box.left; - int height = src->region.box.bottom - src->region.box.top; - - dest->region.pixmap = XCreatePixmap( display, rootWindow, - width, height, 1 ); - XSetFunction( display, regionGC, GXcopy ); - XCopyArea( display, src->region.pixmap, dest->region.pixmap, - regionGC, 0, 0, width, height, 0, 0 ); - } + if (dest->xrgn) XDestroyRegion( dest->xrgn ); + dest->xrgn = 0; + return NULLREGION; } - return dest->region.type; } @@ -573,12 +384,9 @@ static int REGION_CopyRegion( RGNOBJ *src, RGNOBJ *dest ) int CombineRgn( HRGN hDest, HRGN hSrc1, HRGN hSrc2, short mode ) { RGNOBJ *destObj, *src1Obj, *src2Obj; - REGION * region; - int width, height; - BOOL res; - dprintf_region(stddeb, "CombineRgn: %d %d %d %d\n", - hDest, hSrc1, hSrc2, mode ); + dprintf_region(stddeb, "CombineRgn: %x,%x -> %x mode=%x\n", + hSrc1, hSrc2, hDest, mode ); if (!(destObj = (RGNOBJ *) GDI_GetObjPtr( hDest, REGION_MAGIC ))) return ERROR; @@ -588,183 +396,57 @@ int CombineRgn( HRGN hDest, HRGN hSrc1, HRGN hSrc2, short mode ) if (!(src2Obj = (RGNOBJ *) GDI_GetObjPtr( hSrc2, REGION_MAGIC ))) return ERROR; - region = &destObj->region; /* Some optimizations for null regions */ - if (src1Obj->region.type == NULLREGION) + if (!src1Obj->xrgn || !src2Obj->xrgn) { switch(mode) { - case RGN_AND: case RGN_DIFF: - if (region->xrgn) XDestroyRegion( region->xrgn ); - if (region->pixmap) XFreePixmap( display, region->pixmap ); - region->type = NULLREGION; - region->xrgn = 0; + if (src1Obj->xrgn) + return REGION_CopyRegion( src1Obj, destObj ); + /* else fall through */ + case RGN_AND: + if (destObj->xrgn) XDestroyRegion( destObj->xrgn ); + destObj->xrgn = 0; return NULLREGION; case RGN_OR: case RGN_XOR: - return REGION_CopyRegion( src2Obj, destObj ); - default: - return ERROR; - } - } - else if (src2Obj->region.type == NULLREGION) - { - switch(mode) - { - case RGN_AND: - if (region->xrgn) XDestroyRegion( region->xrgn ); - if (region->pixmap) XFreePixmap( display, region->pixmap ); - region->type = NULLREGION; - region->xrgn = 0; - return NULLREGION; - case RGN_OR: - case RGN_XOR: - case RGN_DIFF: - return REGION_CopyRegion( src1Obj, destObj ); + if (src1Obj->xrgn) + return REGION_CopyRegion( src1Obj, destObj ); + else + return REGION_CopyRegion( src2Obj, destObj ); default: return ERROR; } } - if (src1Obj->region.xrgn && src2Obj->region.xrgn) - { - /* Perform the operation with X regions */ - - if (region->pixmap) XFreePixmap( display, region->pixmap ); - region->pixmap = 0; - if (!region->xrgn) region->xrgn = XCreateRegion(); - switch(mode) - { - case RGN_AND: - XIntersectRegion( src1Obj->region.xrgn, src2Obj->region.xrgn, - region->xrgn ); - break; - case RGN_OR: - XUnionRegion( src1Obj->region.xrgn, src2Obj->region.xrgn, - region->xrgn ); - break; - case RGN_XOR: - XXorRegion( src1Obj->region.xrgn, src2Obj->region.xrgn, - region->xrgn ); - break; - case RGN_DIFF: - XSubtractRegion( src1Obj->region.xrgn, src2Obj->region.xrgn, - region->xrgn ); - break; - default: - return ERROR; - } - if (XEmptyRegion(region->xrgn)) - { - XDestroyRegion( region->xrgn ); - region->type = NULLREGION; - region->xrgn = 0; - return NULLREGION; - } - else - { - XRectangle rect; - XClipBox( region->xrgn, &rect ); - region->type = COMPLEXREGION; - region->box.left = rect.x; - region->box.top = rect.y; - region->box.right = rect.x + rect.width; - region->box.bottom = rect.y + rect.height; - return COMPLEXREGION; - } - } - else /* Create pixmaps if needed */ - { - if (!src1Obj->region.pixmap) - if (!REGION_MakePixmap( &src1Obj->region )) return ERROR; - if (!src2Obj->region.pixmap) - if (!REGION_MakePixmap( &src2Obj->region )) return ERROR; - } - + /* Perform the operation with the two X regions */ + if (!destObj->xrgn) destObj->xrgn = XCreateRegion(); switch(mode) { - case RGN_AND: - res = IntersectRect( ®ion->box, &src1Obj->region.box, - &src2Obj->region.box ); - region->type = COMPLEXREGION; - break; - - case RGN_OR: - case RGN_XOR: - res = UnionRect( ®ion->box, &src1Obj->region.box, - &src2Obj->region.box ); - region->type = COMPLEXREGION; - break; - - case RGN_DIFF: - res = SubtractRect( ®ion->box, &src1Obj->region.box, - &src2Obj->region.box ); - region->type = COMPLEXREGION; - break; - - default: - return ERROR; + case RGN_AND: + XIntersectRegion( src1Obj->xrgn, src2Obj->xrgn, destObj->xrgn ); + break; + case RGN_OR: + XUnionRegion( src1Obj->xrgn, src2Obj->xrgn, destObj->xrgn ); + break; + case RGN_XOR: + XXorRegion( src1Obj->xrgn, src2Obj->xrgn, destObj->xrgn ); + break; + case RGN_DIFF: + XSubtractRegion( src1Obj->xrgn, src2Obj->xrgn, destObj->xrgn ); + break; + default: + return ERROR; } - - if (region->pixmap) XFreePixmap( display, region->pixmap ); - if (region->xrgn) XDestroyRegion( region->xrgn ); - if (!res) + if (XEmptyRegion(destObj->xrgn)) { - region->type = NULLREGION; - region->pixmap = 0; - region->xrgn = 0; - return NULLREGION; + XDestroyRegion( destObj->xrgn ); + destObj->xrgn = 0; + return NULLREGION; } - - width = region->box.right - region->box.left; - height = region->box.bottom - region->box.top; - if (!width || !height) - { - fprintf(stderr, "CombineRgn: width or height is 0. Please report this.\n" ); - fprintf(stderr, "src1=%d,%d-%d,%d src2=%d,%d-%d,%d dst=%d,%d-%d,%d op=%d\n", - src1Obj->region.box.left, src1Obj->region.box.top, - src1Obj->region.box.right, src1Obj->region.box.bottom, - src2Obj->region.box.left, src2Obj->region.box.top, - src2Obj->region.box.right, src2Obj->region.box.bottom, - region->box.left, region->box.top, - region->box.right, region->box.bottom, mode ); - exit(1); - } - region->pixmap = XCreatePixmap( display, rootWindow, width, height, 1 ); - region->xrgn = 0; - - switch(mode) - { - case RGN_AND: - XSetFunction( display, regionGC, GXcopy ); - REGION_CopyIntersection( region, &src1Obj->region ); - XSetFunction( display, regionGC, GXand ); - REGION_CopyIntersection( region, &src2Obj->region ); - break; - - case RGN_OR: - case RGN_XOR: - XSetFunction( display, regionGC, GXclear ); - XFillRectangle( display, region->pixmap, regionGC, - 0, 0, width, height ); - XSetFunction( display, regionGC, (mode == RGN_OR) ? GXor : GXxor); - REGION_CopyIntersection( region, &src1Obj->region ); - REGION_CopyIntersection( region, &src2Obj->region ); - break; - - case RGN_DIFF: - XSetFunction( display, regionGC, GXclear ); - XFillRectangle( display, region->pixmap, regionGC, - 0, 0, width, height ); - XSetFunction( display, regionGC, GXcopy ); - REGION_CopyIntersection( region, &src1Obj->region ); - XSetFunction( display, regionGC, GXandInverted ); - REGION_CopyIntersection( region, &src2Obj->region ); - break; - } - return region->type; + else return COMPLEXREGION; } diff --git a/rc/Imakefile b/rc/Imakefile index 79ca9b87539..36decda65ca 100644 --- a/rc/Imakefile +++ b/rc/Imakefile @@ -25,7 +25,7 @@ $(RCOBJS): winerc $(TOP)/include/windows.h includes:: clean:: - $(RM) $(RCSRCS:.rc=.c) + $(RM) $(RCSRCS:.rc=.c) $(RCSRCS:.rc=.h) XCOMM Rules to build the winerc program diff --git a/tools/build.c b/tools/build.c index 9f8725394d0..9a4bce6f61e 100644 --- a/tools/build.c +++ b/tools/build.c @@ -7,8 +7,12 @@ #include "wine.h" #ifdef linux +#ifdef __ELF__ +#define UTEXTSEL 0x0f +#else #define UTEXTSEL 0x23 #endif +#endif #if defined(__NetBSD__) || defined(__FreeBSD__) #define UTEXTSEL 0x1f #endif @@ -753,20 +757,29 @@ int main(int argc, char **argv) sprintf(filename, "dll_%s.S", LowerDLLName); fp = fopen(filename, "w"); - + fprintf (fp, "#define __ASSEMBLY__\n"); + fprintf (fp, "#include \n"); fprintf(fp, "\t.globl " PREFIX "%s_Dispatch\n", UpperDLLName); fprintf(fp, PREFIX "%s_Dispatch:\n", UpperDLLName); fprintf(fp, "\tandl\t$0x0000ffff,%%esp\n"); fprintf(fp, "\tandl\t$0x0000ffff,%%ebp\n"); fprintf(fp, "\torl\t$0x%08x,%%eax\n", DLLId << 16); - fprintf(fp, "\tjmp\t" PREFIX "CallTo32\n\n"); +#ifdef __ELF__ + fprintf(fp, "\tljmp\t$USER_CS, $" PREFIX "CallTo32\n\n"); +#else + fprintf(fp, "\tjmp\t_CallTo32\n\n"); +#endif fprintf(fp, "\t.globl " PREFIX "%s_Dispatch_16\n", UpperDLLName); fprintf(fp, PREFIX "%s_Dispatch_16:\n", UpperDLLName); fprintf(fp, "\tandl\t$0x0000ffff,%%esp\n"); fprintf(fp, "\tandl\t$0x0000ffff,%%ebp\n"); fprintf(fp, "\torl\t$0x%08x,%%eax\n", DLLId << 16); - fprintf(fp, "\tjmp\t" PREFIX "CallTo32_16\n\n"); +#ifdef __ELF__ + fprintf(fp, "\tljmp\t$USER_CS, $" PREFIX "CallTo32_16\n\n"); +#else + fprintf(fp, "\tjmp\t_CallTo32_16\n\n"); +#endif odp = OrdinalDefinitions; for (i = 0; i <= Limit; i++, odp++) diff --git a/tools/newbuild.c b/tools/newbuild.c index 647594f239c..f9f8e42cf54 100644 --- a/tools/newbuild.c +++ b/tools/newbuild.c @@ -7,7 +7,11 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; #include #ifdef linux +#ifdef __ELF__ +#define UTEXTSEL 0x0f +#else #define UTEXTSEL 0x23 +#endif #define UDATASEL 0x2b #endif #if defined(__NetBSD__) || defined(__FreeBSD__) diff --git a/windows/cursor.c b/windows/cursor.c index 5ba75a7f6f7..7c98f92114f 100644 --- a/windows/cursor.c +++ b/windows/cursor.c @@ -416,7 +416,8 @@ int ShowCursor(BOOL bShow) */ void ClipCursor(LPRECT lpNewClipRect) { - CopyRect(&ClipCursorRect, lpNewClipRect); + if (!lpNewClipRect) SetRectEmpty( &ClipCursorRect ); + else CopyRect( &ClipCursorRect, lpNewClipRect ); } diff --git a/windows/defwnd.c b/windows/defwnd.c index a8c53192edb..37ed5aaa284 100644 --- a/windows/defwnd.c +++ b/windows/defwnd.c @@ -69,7 +69,7 @@ LONG DefWindowProc( HWND hwnd, WORD msg, WORD wParam, LONG lParam ) case WM_PAINTICON: case WM_NCPAINT: - return NC_HandleNCPaint( hwnd, (HRGN)wParam ); + return NC_HandleNCPaint( hwnd ); case WM_NCHITTEST: return NC_HandleNCHitTest( hwnd, MAKEPOINT(lParam) ); @@ -145,8 +145,8 @@ LONG DefWindowProc( HWND hwnd, WORD msg, WORD wParam, LONG lParam ) case WM_ERASEBKGND: case WM_ICONERASEBKGND: { - if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) return 1; - if (!classPtr->wc.hbrBackground) return 1; + if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) return 0; + if (!classPtr->wc.hbrBackground) return 0; if (classPtr->wc.hbrBackground <= COLOR_MAX+1) { HBRUSH hbrush; @@ -158,7 +158,7 @@ LONG DefWindowProc( HWND hwnd, WORD msg, WORD wParam, LONG lParam ) else FillWindow( GetParent(hwnd), hwnd, (HDC)wParam, classPtr->wc.hbrBackground ); - return 0; + return 1; } case WM_GETDLGCODE: @@ -211,7 +211,7 @@ LONG DefWindowProc( HWND hwnd, WORD msg, WORD wParam, LONG lParam ) case WM_SETTEXT: DEFWND_SetText( hwnd, (LPSTR)lParam ); - NC_HandleNCPaint( hwnd, (HRGN)1 ); /* Repaint caption */ + NC_HandleNCPaint( hwnd ); /* Repaint caption */ return 0; case WM_SETCURSOR: diff --git a/windows/event.c b/windows/event.c index 71469b7808b..4f4a2cf0065 100644 --- a/windows/event.c +++ b/windows/event.c @@ -256,7 +256,6 @@ static WORD EVENT_XStateToKeyState( int state ) static void EVENT_Expose( HWND hwnd, XExposeEvent *event ) { RECT rect; - UINT flags; WND * wndPtr = WIN_FindWndPtr( hwnd ); if (!wndPtr) return; @@ -266,10 +265,9 @@ static void EVENT_Expose( HWND hwnd, XExposeEvent *event ) rect.right = rect.left + event->width; rect.bottom = rect.top + event->height; - flags = RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN; - /* Erase desktop background synchronously */ -/* if (event->window == rootWindow) flags |= RDW_ERASENOW | RDW_NOCHILDREN; */ - RedrawWindow( hwnd, &rect, 0, flags ); + RedrawWindow( hwnd, &rect, 0, + RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN | RDW_ERASE | + (event->count ? 0 : RDW_ERASENOW) ); } diff --git a/windows/graphics.c b/windows/graphics.c index cd8013b6e7c..8ed3f8c117b 100644 --- a/windows/graphics.c +++ b/windows/graphics.c @@ -542,8 +542,6 @@ BOOL PaintRgn( HDC hdc, HRGN hrgn ) DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return FALSE; - /* FIXME: the region is supposed to be in logical coordinates */ - /* Modify visible region */ if (!(prevVisRgn = SaveVisRgn( hdc ))) return FALSE; @@ -558,7 +556,7 @@ BOOL PaintRgn( HDC hdc, HRGN hrgn ) /* Fill the region */ - GetClipBox( hdc, &box ); + GetRgnBox( dc->w.hGCClipRgn, &box ); if (DC_SetupGCForBrush( dc )) XFillRectangle( display, dc->u.x.drawable, dc->u.x.gc, dc->w.DCOrgX + box.left, dc->w.DCOrgY + box.top, @@ -717,21 +715,13 @@ BOOL Polyline (HDC hdc, LPPOINT pt, int count) } if (DC_SetupGCForPen( dc )) - { for (i = 0; i < count-1; i ++) XDrawLine (display, dc->u.x.drawable, dc->u.x.gc, dc->w.DCOrgX + XLPTODP(dc, pt [i].x), dc->w.DCOrgY + YLPTODP(dc, pt [i].y), dc->w.DCOrgX + XLPTODP(dc, pt [i+1].x), dc->w.DCOrgY + YLPTODP(dc, pt [i+1].y)); - XDrawLine (display, dc->u.x.drawable, dc->u.x.gc, - dc->w.DCOrgX + XLPTODP(dc, pt [count-1].x), - dc->w.DCOrgY + YLPTODP(dc, pt [count-1].y), - dc->w.DCOrgX + XLPTODP(dc, pt [0].x), - dc->w.DCOrgY + YLPTODP(dc, pt [0].y)); - } - - return (TRUE); + return TRUE; } @@ -915,7 +905,7 @@ BOOL ExtFloodFill( HDC hdc, INT x, INT y, COLORREF color, WORD fillType ) } if (!PtVisible( hdc, x, y )) return FALSE; - if (GetClipBox( hdc, &rect ) == ERROR) return FALSE; + if (GetRgnBox( dc->w.hGCClipRgn, &rect ) == ERROR) return FALSE; pixel = COLOR_ToPhysical( dc, color ); if (!(image = XGetImage( display, dc->u.x.drawable, diff --git a/windows/keyboard.c b/windows/keyboard.c index ab15b9db6d3..e02ebd7e48a 100644 --- a/windows/keyboard.c +++ b/windows/keyboard.c @@ -3,9 +3,6 @@ * * Copyright 1993 Bob Amstadt */ - -static char Copyright[] = "Copyright Bob Amstadt, 1993"; - #include #include "win.h" #include "windows.h" diff --git a/windows/mdi.c b/windows/mdi.c index 43abdf43b54..ee6f5759f52 100644 --- a/windows/mdi.c +++ b/windows/mdi.c @@ -9,6 +9,7 @@ #include #include "windows.h" #include "win.h" +#include "nonclient.h" #include "mdi.h" #include "user.h" #include "menu.h" @@ -271,7 +272,7 @@ LONG MDIMaximizeChild(HWND parent, HWND child, MDICLIENTINFO *ci) SendMessage(child, WM_SIZE, SIZE_MAXIMIZED, MAKELONG(w->rectClient.right-w->rectClient.left, w->rectClient.bottom-w->rectClient.top)); - SendMessage(GetParent(parent), WM_NCPAINT, 1, 0); + SendMessage(GetParent(parent), WM_NCPAINT, 0, 0); return 0; } @@ -298,7 +299,7 @@ LONG MDIRestoreChild(HWND parent, MDICLIENTINFO *ci) ci->flagChildMaximized = FALSE; ShowWindow(child, SW_RESTORE); /* display the window */ - SendMessage(GetParent(parent), WM_NCPAINT, 1, 0); + SendMessage(GetParent(parent), WM_NCPAINT, 0, 0); MDIBringChildToTop(parent, child, FALSE, FALSE); return 0; @@ -496,7 +497,6 @@ LONG MDIPaintMaximized(HWND hwndFrame, HWND hwndClient, WORD message, MDICLIENTINFO *ci; WND *w; - LONG rv; HDC hdc, hdcMem; RECT rect; WND *wndPtr = WIN_FindWndPtr(hwndFrame); @@ -512,11 +512,10 @@ LONG MDIPaintMaximized(HWND hwndFrame, HWND hwndClient, WORD message, if (ci->flagChildMaximized && wndPtr && wndPtr->wIDmenu != 0) { - rv = NC_DoNCPaint( hwndFrame, (HRGN) 1, wParam, TRUE); - + NC_DoNCPaint( hwndFrame, wParam, TRUE); + hdc = GetDCEx(hwndFrame, 0, DCX_CACHE | DCX_WINDOW); - if (!hdc) - return rv; + if (!hdc) return 0; hdcMem = CreateCompatibleDC(hdc); @@ -563,7 +562,7 @@ LONG MDIPaintMaximized(HWND hwndFrame, HWND hwndClient, WORD message, else DefWindowProc(hwndFrame, message, wParam, lParam); - return rv; + return 0; } /********************************************************************** @@ -725,8 +724,8 @@ DefMDIChildProc(HWND hwnd, WORD message, WORD wParam, LONG lParam) break; case WM_NCPAINT: - return NC_DoNCPaint(hwnd, (HRGN)1, - hwnd == ci->hwndActiveChild); + NC_DoNCPaint( hwnd, hwnd == ci->hwndActiveChild, FALSE ); + return 0; case WM_SYSCOMMAND: switch (wParam) diff --git a/windows/message.c b/windows/message.c index 072635e19e9..2fd510e3350 100644 --- a/windows/message.c +++ b/windows/message.c @@ -209,7 +209,7 @@ static void MSG_RemoveMsg( MESSAGEQUEUE * msgQueue, int pos ) static BOOL MSG_TranslateMouseMsg( MSG *msg, BOOL remove ) { BOOL eatMsg = FALSE; - LONG hittest_result; + INT hittest_result; static DWORD lastClickTime = 0; static WORD lastClickMsg = 0; static POINT lastClickPos = { 0, 0 }; @@ -231,14 +231,14 @@ static BOOL MSG_TranslateMouseMsg( MSG *msg, BOOL remove ) /* Send the WM_NCHITTEST message */ - hittest_result = SendMessage( msg->hwnd, WM_NCHITTEST, 0, - MAKELONG( msg->pt.x, msg->pt.y ) ); + hittest_result = (INT)SendMessage( msg->hwnd, WM_NCHITTEST, 0, + MAKELONG( msg->pt.x, msg->pt.y ) ); while ((hittest_result == HTTRANSPARENT) && (msg->hwnd)) { msg->hwnd = WINPOS_NextWindowFromPoint( msg->hwnd, msg->pt ); if (msg->hwnd) - hittest_result = SendMessage( msg->hwnd, WM_NCHITTEST, 0, - MAKELONG( msg->pt.x, msg->pt.y ) ); + hittest_result = (INT)SendMessage( msg->hwnd, WM_NCHITTEST, 0, + MAKELONG( msg->pt.x, msg->pt.y )); } if (!msg->hwnd) msg->hwnd = GetDesktopWindow(); diff --git a/windows/nonclient.c b/windows/nonclient.c index bab7953051e..6d0903f988c 100644 --- a/windows/nonclient.c +++ b/windows/nonclient.c @@ -537,33 +537,18 @@ static void NC_DrawCaption( HDC hdc, RECT *rect, HWND hwnd, * NC_DoNCPaint * * Paint the non-client area. - * 'hrgn' is the update rgn to use (in client coords) or 1 if no update rgn. */ -void NC_DoNCPaint( HWND hwnd, HRGN hrgn, BOOL active, BOOL suppress_menupaint ) +void NC_DoNCPaint( HWND hwnd, BOOL active, BOOL suppress_menupaint ) { HDC hdc; RECT rect; WND *wndPtr = WIN_FindWndPtr( hwnd ); - dprintf_nonclient(stddeb, "NC_DoNCPaint: %d %d\n", hwnd, hrgn ); - if (!wndPtr || !hrgn) return; - if (!(wndPtr->dwStyle & WS_VISIBLE)) return; /* Nothing to do */ - if (!(wndPtr->dwStyle & (WS_BORDER | WS_DLGFRAME | WS_THICKFRAME)) && - !(wndPtr->dwExStyle & WS_EX_DLGMODALFRAME)) return; /* Nothing to do */ - - if (hrgn == 1) hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW ); - else - { - /* Make region relative to window area */ - int xoffset = wndPtr->rectWindow.left - wndPtr->rectClient.left; - int yoffset = wndPtr->rectWindow.top - wndPtr->rectClient.top; - OffsetRgn( hrgn, -xoffset, -yoffset ); - hdc = GetDCEx( hwnd, hrgn, DCX_USESTYLE|DCX_WINDOW|DCX_INTERSECTRGN ); - OffsetRgn( hrgn, xoffset, yoffset ); /* Restore region */ - } - if (!hdc) return; + dprintf_nonclient(stddeb, "NC_DoNCPaint: %x %d\n", hwnd, active ); + if (!wndPtr || !(wndPtr->dwStyle & WS_VISIBLE)) return; /* Nothing to do */ + if (!(hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW ))) return; /* * If this is an icon, we don't want to do any more nonclient painting @@ -654,9 +639,9 @@ void NC_DoNCPaint( HWND hwnd, HRGN hrgn, BOOL active, BOOL suppress_menupaint ) * * Handle a WM_NCPAINT message. Called from DefWindowProc(). */ -LONG NC_HandleNCPaint( HWND hwnd, HRGN hrgn ) +LONG NC_HandleNCPaint( HWND hwnd ) { - NC_DoNCPaint( hwnd, hrgn, hwnd == GetActiveWindow(), FALSE ); + NC_DoNCPaint( hwnd, hwnd == GetActiveWindow(), FALSE ); return 0; } @@ -668,7 +653,7 @@ LONG NC_HandleNCPaint( HWND hwnd, HRGN hrgn ) */ LONG NC_HandleNCActivate( HWND hwnd, WORD wParam ) { - NC_DoNCPaint( hwnd, (HRGN)1, wParam, FALSE ); + NC_DoNCPaint( hwnd, wParam, FALSE ); return TRUE; } diff --git a/windows/painting.c b/windows/painting.c index fe45db7c820..e44110bd070 100644 --- a/windows/painting.c +++ b/windows/painting.c @@ -10,6 +10,9 @@ #include "win.h" #include "message.h" #include "gdi.h" +#include "stddebug.h" +/* #define DEBUG_WIN */ +#include "debug.h" /* Last CTLCOLOR id */ #define CTLCOLOR_MAX CTLCOLOR_STATIC @@ -34,21 +37,29 @@ HDC BeginPaint( HWND hwnd, LPPAINTSTRUCT lps ) wndPtr->hrgnUpdate = 0; wndPtr->flags &= ~(WIN_NEEDS_BEGINPAINT | WIN_INTERNAL_PAINT); - if (!(lps->hdc = GetDCEx( hwnd, hrgnUpdate, - DCX_INTERSECTRGN | DCX_USESTYLE ))) + if (wndPtr->flags & WIN_NEEDS_NCPAINT) { - fprintf( stderr, "GetDCEx() failed in BeginPaint(), hwnd=%d\n", hwnd ); - DeleteObject( hrgnUpdate ); + SendMessage( hwnd, WM_NCPAINT, 0, 0 ); + wndPtr->flags &= ~WIN_NEEDS_NCPAINT; + } + + lps->hdc = GetDCEx( hwnd, hrgnUpdate, DCX_INTERSECTRGN | DCX_USESTYLE ); + DeleteObject( hrgnUpdate ); + if (!lps->hdc) + { + fprintf( stderr, "GetDCEx() failed in BeginPaint(), hwnd=%x\n", hwnd ); return 0; } + GetRgnBox( InquireVisRgn(lps->hdc), &lps->rcPaint ); DPtoLP( lps->hdc, (LPPOINT)&lps->rcPaint, 2 ); - SendMessage( hwnd, WM_NCPAINT, hrgnUpdate, 0 ); - DeleteObject( hrgnUpdate ); - - if (!(wndPtr->flags & WIN_ERASE_UPDATERGN)) lps->fErase = TRUE; - else lps->fErase = !SendMessage( hwnd, WM_ERASEBKGND, lps->hdc, 0 ); + if (wndPtr->flags & WIN_NEEDS_ERASEBKGND) + { + lps->fErase = !SendMessage( hwnd, WM_ERASEBKGND, lps->hdc, 0 ); + wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND; + } + else lps->fErase = TRUE; return lps->hdc; } @@ -86,7 +97,7 @@ void PaintRect(HWND hwndParent, HWND hwnd, HDC hdc, HBRUSH hbrush, LPRECT rect) { if (!hwndParent) return; hbrush = (HBRUSH)SendMessage( hwndParent, WM_CTLCOLOR, - hdc, hwnd | (hbrush << 16) ); + hdc, MAKELONG( hwnd, hbrush ) ); } if (hbrush) FillRect( hdc, rect, hbrush ); } @@ -106,14 +117,23 @@ BOOL RedrawWindow( HWND hwnd, LPRECT rectUpdate, HRGN hrgnUpdate, UINT flags ) if (!(wndPtr->dwStyle & WS_VISIBLE) || (wndPtr->flags & WIN_NO_REDRAW)) return TRUE; /* No redraw needed */ + if (rectUpdate) + { + dprintf_win( stddeb, "RedrawWindow: %x %d,%d-%d,%d %x flags=%04x\n", + hwnd, rectUpdate->left, rectUpdate->top, + rectUpdate->right, rectUpdate->bottom, hrgnUpdate, flags); + } + else + { + dprintf_win( stddeb, "RedrawWindow: %x NULL %x flags=%04x\n", + hwnd, hrgnUpdate, flags); + } GetClientRect( hwnd, &rectClient ); rectWindow = wndPtr->rectWindow; OffsetRect(&rectWindow, -wndPtr->rectClient.left, -wndPtr->rectClient.top); if (flags & RDW_INVALIDATE) /* Invalidate */ { - if (flags & RDW_ERASE) wndPtr->flags |= WIN_ERASE_UPDATERGN; - if (hrgnUpdate) /* Invalidate a region */ { if (flags & RDW_FRAME) tmpRgn = CreateRectRgnIndirect(&rectWindow); @@ -162,11 +182,13 @@ BOOL RedrawWindow( HWND hwnd, LPRECT rectUpdate, HRGN hrgnUpdate, UINT flags ) wndPtr->hrgnUpdate = tmpRgn; } } + if (flags & RDW_FRAME) wndPtr->flags |= WIN_NEEDS_NCPAINT; + if (flags & RDW_ERASE) wndPtr->flags |= WIN_NEEDS_ERASEBKGND; flags |= RDW_FRAME; /* Force invalidating the frame of children */ } else if (flags & RDW_VALIDATE) /* Validate */ { - if (flags & RDW_NOERASE) wndPtr->flags &= ~WIN_ERASE_UPDATERGN; + if (flags & RDW_NOERASE) wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND; if (!(hrgn = CreateRectRgn( 0, 0, 0, 0 ))) return FALSE; /* Remove frame from update region */ @@ -231,22 +253,31 @@ BOOL RedrawWindow( HWND hwnd, LPRECT rectUpdate, HRGN hrgnUpdate, UINT flags ) /* Erase/update window */ - if (flags & RDW_UPDATENOW) UpdateWindow( hwnd ); + if (flags & RDW_UPDATENOW) SendMessage( hwnd, WM_PAINT, 0, 0 ); else if (flags & RDW_ERASENOW) { - HDC hdc = GetDCEx( hwnd, wndPtr->hrgnUpdate, - DCX_INTERSECTRGN | DCX_USESTYLE ); - if (hdc) - { - SendMessage( hwnd, WM_NCPAINT, wndPtr->hrgnUpdate, 0 ); - + if (wndPtr->flags & WIN_NEEDS_NCPAINT) + { + SendMessage( hwnd, WM_NCPAINT, 0, 0 ); + wndPtr->flags &= ~WIN_NEEDS_NCPAINT; + } + if (wndPtr->flags & WIN_NEEDS_ERASEBKGND) + { + HDC hdc = GetDCEx( hwnd, wndPtr->hrgnUpdate, + DCX_INTERSECTRGN | DCX_USESTYLE ); + if (hdc) + { /* Don't send WM_ERASEBKGND to icons */ /* (WM_ICONERASEBKGND is sent during processing of WM_NCPAINT) */ - if (!(wndPtr->dwStyle & WS_MINIMIZE) - || !WIN_CLASS_INFO(wndPtr).hIcon) - SendMessage( hwnd, WM_ERASEBKGND, hdc, 0 ); - ReleaseDC( hwnd, hdc ); - } + if (!(wndPtr->dwStyle & WS_MINIMIZE) + || !WIN_CLASS_INFO(wndPtr).hIcon) + { + if (SendMessage( hwnd, WM_ERASEBKGND, hdc, 0 )) + wndPtr->flags &= ~WIN_NEEDS_ERASEBKGND; + } + ReleaseDC( hwnd, hdc ); + } + } } /* Recursively process children */ @@ -294,10 +325,7 @@ BOOL RedrawWindow( HWND hwnd, LPRECT rectUpdate, HRGN hrgnUpdate, UINT flags ) */ void UpdateWindow( HWND hwnd ) { - if (GetUpdateRect( hwnd, NULL, FALSE )) - { - if (IsWindowVisible( hwnd )) SendMessage( hwnd, WM_PAINT, 0, 0 ); - } + RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_NOCHILDREN ); } @@ -372,27 +400,15 @@ int GetUpdateRgn( HWND hwnd, HRGN hrgn, BOOL erase ) if (!wndPtr->hrgnUpdate) { - if (!(hrgnClip = CreateRectRgn( 0, 0, 0, 0 ))) return ERROR; - retval = CombineRgn( hrgn, hrgnClip, 0, RGN_COPY ); - } - else - { - hrgnClip = CreateRectRgn( 0, 0, - wndPtr->rectClient.right-wndPtr->rectClient.left, - wndPtr->rectClient.bottom-wndPtr->rectClient.top ); - if (!hrgnClip) return ERROR; - retval = CombineRgn( hrgn, wndPtr->hrgnUpdate, hrgnClip, RGN_AND ); - if (erase) - { - HDC hdc = GetDCEx( hwnd, wndPtr->hrgnUpdate, - DCX_INTERSECTRGN | DCX_USESTYLE ); - if (hdc) - { - SendMessage( hwnd, WM_ERASEBKGND, hdc, 0 ); - ReleaseDC( hwnd, hdc ); - } - } + SetRectRgn( hrgn, 0, 0, 0, 0 ); + return NULLREGION; } + hrgnClip = CreateRectRgn( 0, 0, + wndPtr->rectClient.right-wndPtr->rectClient.left, + wndPtr->rectClient.bottom-wndPtr->rectClient.top); + if (!hrgnClip) return ERROR; + retval = CombineRgn( hrgn, wndPtr->hrgnUpdate, hrgnClip, RGN_AND ); + if (erase) RedrawWindow( hwnd, NULL, 0, RDW_ERASENOW | RDW_NOCHILDREN ); DeleteObject( hrgnClip ); return retval; } diff --git a/windows/scroll.c b/windows/scroll.c index 4a1a51f75ed..d662983e36c 100644 --- a/windows/scroll.c +++ b/windows/scroll.c @@ -154,8 +154,8 @@ int ScrollWindowEx(HWND hwnd, short dx, short dy, LPRECT rect, LPRECT clipRect, if (flags | SW_INVALIDATE) { - RedrawWindow(hwnd, NULL, hrgnUpdate, - RDW_INVALIDATE | ((flags & SW_ERASE) ? RDW_ERASENOW : 0)); + RedrawWindow( hwnd, NULL, hrgnUpdate, RDW_INVALIDATE | RDW_ERASE | + ((flags & SW_ERASE) ? RDW_ERASENOW : 0)); } ReleaseDC(hwnd, hdc); diff --git a/windows/win.c b/windows/win.c index 779fbf7a148..809c333dd6a 100644 --- a/windows/win.c +++ b/windows/win.c @@ -3,9 +3,6 @@ * * Copyright 1993, 1994 Alexandre Julliard */ - -static char Copyright[] = "Copyright Alexandre Julliard, 1993, 1994"; - #include #include #include diff --git a/windows/winpos.c b/windows/winpos.c index 659211e63ba..6de8899110d 100644 --- a/windows/winpos.c +++ b/windows/winpos.c @@ -11,7 +11,6 @@ #include "winpos.h" #include "stddebug.h" /* #define DEBUG_WIN */ -/* #undef DEBUG_WIN */ #include "debug.h" static HWND hwndActive = 0; /* Currently active window */ @@ -274,7 +273,7 @@ BOOL ShowWindow( HWND hwnd, int cmd ) */ MoveWindow(hwnd, wndPtr->ptIconPos.x, wndPtr->ptIconPos.y, SYSMETRICS_CXICON, SYSMETRICS_CYICON, FALSE); - RedrawWindow( hwnd, NULL, 0, RDW_FRAME | RDW_ERASENOW ); + RedrawWindow( hwnd, NULL, 0, RDW_FRAME | RDW_ERASE | RDW_ERASENOW); break; case SW_SHOWNA: @@ -604,7 +603,7 @@ static void WINPOS_MoveWindowZOrder( HWND hwnd, HWND hwndAfter, BOOL erase ) OffsetRect( &rect, -wndPtr->rectClient.left, -wndPtr->rectClient.top ); RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN | - RDW_FRAME | (erase ? RDW_ERASENOW : RDW_ERASE) ); + RDW_FRAME | RDW_ERASE | (erase ? RDW_ERASENOW : 0) ); hwndCur = curPtr->hwndNext; } } @@ -620,7 +619,7 @@ static void WINPOS_MoveWindowZOrder( HWND hwnd, HWND hwndAfter, BOOL erase ) OffsetRect( &rect, -curPtr->rectClient.left, -curPtr->rectClient.top ); RedrawWindow( hwndCur, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN | - RDW_FRAME | (erase ? RDW_ERASENOW : RDW_ERASE) ); + RDW_FRAME | RDW_ERASE | (erase ? RDW_ERASENOW : 0) ); hwndCur = curPtr->hwndNext; } } @@ -775,12 +774,13 @@ static BOOL WINPOS_InternalSetWindowPos( WINDOWPOS *winpos ) HRGN hrgn3 = CreateRectRgn( 0, 0, 0, 0 ); CombineRgn( hrgn3, hrgn1, hrgn2, RGN_DIFF ); RedrawWindow( wndPtr->hwndParent, NULL, hrgn3, - RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASENOW ); + RDW_INVALIDATE | RDW_ALLCHILDREN | + RDW_ERASE | RDW_ERASENOW ); if ((oldWindowRect.left != wndPtr->rectWindow.left) || (oldWindowRect.top != wndPtr->rectWindow.top)) { RedrawWindow( winpos->hwnd, NULL, 0, RDW_INVALIDATE | - RDW_FRAME | RDW_ALLCHILDREN | RDW_ERASENOW ); + RDW_FRAME | RDW_ALLCHILDREN | RDW_ERASE | RDW_ERASENOW ); } DeleteObject( hrgn1 ); DeleteObject( hrgn2 ); @@ -794,9 +794,11 @@ static BOOL WINPOS_InternalSetWindowPos( WINDOWPOS *winpos ) if (wndPtr->window) { XMapWindow( display, wndPtr->window ); - MSG_Synchronize(); - if (flags & SWP_NOREDRAW) /* Validate the whole window */ - RedrawWindow( winpos->hwnd, NULL, 0, RDW_VALIDATE ); + } + else + { + RedrawWindow( winpos->hwnd, NULL, 0, + RDW_INVALIDATE | RDW_FRAME | RDW_ERASE ); } } else if (flags & SWP_HIDEWINDOW) @@ -810,7 +812,7 @@ static BOOL WINPOS_InternalSetWindowPos( WINDOWPOS *winpos ) { RedrawWindow( wndPtr->hwndParent, &wndPtr->rectWindow, 0, RDW_INVALIDATE | RDW_FRAME | - RDW_ALLCHILDREN | RDW_ERASENOW ); + RDW_ALLCHILDREN | RDW_ERASE | RDW_ERASENOW ); } if ((winpos->hwnd == GetFocus()) || IsChild(winpos->hwnd, GetFocus())) SetFocus( GetParent(winpos->hwnd) ); /* Revert focus to parent */ @@ -835,23 +837,14 @@ static BOOL WINPOS_InternalSetWindowPos( WINDOWPOS *winpos ) WINPOS_ChangeActiveWindow( winpos->hwnd, FALSE ); } - /* Send WM_NCPAINT message if needed */ + /* Repaint the window */ - if (flags & SWP_SHOWWINDOW) - { - /* Repaint the window frame and background */ - RedrawWindow( winpos->hwnd, NULL, 0, - RDW_INVALIDATE | RDW_FRAME | RDW_ERASENOW ); - } - else - { - if ((flags & SWP_FRAMECHANGED) || - (!(flags & SWP_NOSIZE)) || - (!(flags & SWP_NOMOVE)) || - (!(flags & SWP_NOACTIVATE)) || - (!(flags & SWP_NOZORDER))) - SendMessage( winpos->hwnd, WM_NCPAINT, 1, 0L ); - } + if (wndPtr->window) MSG_Synchronize(); /* Wait for all expose events */ + if (flags & SWP_FRAMECHANGED) + RedrawWindow( winpos->hwnd, NULL, 0, + RDW_INVALIDATE | RDW_FRAME | RDW_ERASE ); + RedrawWindow( winpos->hwnd, NULL, 0, + (flags & SWP_NOREDRAW) ? RDW_VALIDATE : RDW_ERASENOW ); /* And last, send the WM_WINDOWPOSCHANGED message */