> I re-submitted a patch that should at least be easier to read (diffs > with context, plus whitespace differences are ignored. (I had told > emacs to do some silly untabifying when saving C-mode buffers, which > I've stopped)). Sorry about the bad format the first time :-/ > > If it will be a few days before you submit your patch, could you send > it my way as-is? I'm particularly curious to see what you did with > winebuilder. Anyway, I'd like to get a start making (hopefully) > compatible ppc additions to your sparc patch, if you can get it to me. OK; to build on Sparc you need the three (minor) patches I just sent to wine-patches, and in addition two 'big' ones; the first one fixes winebuild (and related parts of the NE loader), and the second one 'fixes' wrc to work on Sparc. Note that winebuild patch is nearly ready for submission; it should compile out-of-the box on PPC with one change: you need to define the import thunk assembly glue at the point the #error directive asks you to. The only reason why I'm not submitting it yet is that I'm not completely happy with some of the alignment hacks ... The wrc patch is rather hackish at the moment and definitly needs to be cleaned up. Bye, Ulrich -- Dr. Ulrich Weigand [EMAIL PROTECTED]
diff -ur wine-cvs/tools/wrc/genres.c wine-uw/tools/wrc/genres.c --- wine-cvs/tools/wrc/genres.c Sun Dec 10 15:45:54 2000 +++ wine-uw/tools/wrc/genres.c Sun Dec 17 18:11:32 2000 @@ -65,7 +65,7 @@ { if(res->allocsize - res->size < sizeof(char)) grow_res(res, RES_BLOCKSIZE); - *(char *)&(res->data[res->size]) = (char)c; + res->data[res->size] = (char)c; res->size += sizeof(char); } @@ -75,15 +75,20 @@ grow_res(res, RES_BLOCKSIZE); switch(byteorder) { -#ifndef WORDS_BIGENDIAN - case WRC_BO_BIG: -#else - case WRC_BO_LITTLE: +#ifdef WORDS_BIGENDIAN + default: #endif - *(WORD *)&(res->data[res->size]) = BYTESWAP_WORD((WORD)w); + case WRC_BO_BIG: + res->data[res->size+0] = HIBYTE(w); + res->data[res->size+1] = LOBYTE(w); break; + +#ifndef WORDS_BIGENDIAN default: - *(WORD *)&(res->data[res->size]) = (WORD)w; +#endif + case WRC_BO_LITTLE: + res->data[res->size+1] = HIBYTE(w); + res->data[res->size+0] = LOBYTE(w); break; } res->size += sizeof(WORD); @@ -95,15 +100,24 @@ grow_res(res, RES_BLOCKSIZE); switch(byteorder) { -#ifndef WORDS_BIGENDIAN - case WRC_BO_BIG: -#else - case WRC_BO_LITTLE: +#ifdef WORDS_BIGENDIAN + default: #endif - *(DWORD *)&(res->data[res->size]) = BYTESWAP_DWORD((DWORD)d); + case WRC_BO_BIG: + res->data[res->size+0] = HIBYTE(HIWORD(d)); + res->data[res->size+1] = LOBYTE(HIWORD(d)); + res->data[res->size+2] = HIBYTE(LOWORD(d)); + res->data[res->size+3] = LOBYTE(LOWORD(d)); break; + +#ifndef WORDS_BIGENDIAN default: - *(DWORD *)&(res->data[res->size]) = (DWORD)d; +#endif + case WRC_BO_LITTLE: + res->data[res->size+3] = HIBYTE(HIWORD(d)); + res->data[res->size+2] = LOBYTE(HIWORD(d)); + res->data[res->size+1] = HIBYTE(LOWORD(d)); + res->data[res->size+0] = LOBYTE(LOWORD(d)); break; } res->size += sizeof(DWORD); @@ -135,15 +149,20 @@ { switch(byteorder) { -#ifndef WORDS_BIGENDIAN - case WRC_BO_BIG: -#else - case WRC_BO_LITTLE: +#ifdef WORDS_BIGENDIAN + default: #endif - *(WORD *)&(res->data[ofs]) = BYTESWAP_WORD((WORD)w); + case WRC_BO_BIG: + res->data[ofs+0] = HIBYTE(w); + res->data[ofs+1] = LOBYTE(w); break; + +#ifndef WORDS_BIGENDIAN default: - *(WORD *)&(res->data[ofs]) = (WORD)w; +#endif + case WRC_BO_LITTLE: + res->data[ofs+1] = HIBYTE(w); + res->data[ofs+0] = LOBYTE(w); break; } } @@ -152,15 +171,24 @@ { switch(byteorder) { -#ifndef WORDS_BIGENDIAN - case WRC_BO_BIG: -#else - case WRC_BO_LITTLE: +#ifdef WORDS_BIGENDIAN + default: #endif - *(DWORD *)&(res->data[ofs]) = BYTESWAP_DWORD((DWORD)d); + case WRC_BO_BIG: + res->data[ofs+0] = HIBYTE(HIWORD(d)); + res->data[ofs+1] = LOBYTE(HIWORD(d)); + res->data[ofs+2] = HIBYTE(LOWORD(d)); + res->data[ofs+3] = LOBYTE(LOWORD(d)); break; + +#ifndef WORDS_BIGENDIAN default: - *(DWORD *)&(res->data[ofs]) = (DWORD)d; +#endif + case WRC_BO_LITTLE: + res->data[ofs+3] = HIBYTE(HIWORD(d)); + res->data[ofs+2] = LOBYTE(HIWORD(d)); + res->data[ofs+1] = HIBYTE(LOWORD(d)); + res->data[ofs+0] = LOBYTE(LOWORD(d)); break; } } @@ -184,14 +212,19 @@ { switch(byteorder) { -#ifndef WORDS_BIGENDIAN - case WRC_BO_BIG: -#else - case WRC_BO_LITTLE: +#ifdef WORDS_BIGENDIAN + default: #endif - return BYTESWAP_WORD(*(WORD *)&(res->data[ofs])); + case WRC_BO_BIG: + return (res->data[ofs+0] << 8) + | res->data[ofs+1]; + +#ifndef WORDS_BIGENDIAN default: - return *(WORD *)&(res->data[ofs]); +#endif + case WRC_BO_LITTLE: + return (res->data[ofs+1] << 8) + | res->data[ofs+0]; } } @@ -199,14 +232,23 @@ { switch(byteorder) { -#ifndef WORDS_BIGENDIAN - case WRC_BO_BIG: -#else - case WRC_BO_LITTLE: +#ifdef WORDS_BIGENDIAN + default: #endif - return BYTESWAP_DWORD(*(DWORD *)&(res->data[ofs])); + case WRC_BO_BIG: + return (res->data[ofs+0] << 24) + | (res->data[ofs+1] << 16) + | (res->data[ofs+2] << 8) + | res->data[ofs+3]; + +#ifndef WORDS_BIGENDIAN default: - return *(DWORD *)&(res->data[ofs]); +#endif + case WRC_BO_LITTLE: + return (res->data[ofs+3] << 24) + | (res->data[ofs+2] << 16) + | (res->data[ofs+1] << 8) + | res->data[ofs+0]; } } diff -ur wine-cvs/tools/wrc/newstruc.c wine-uw/tools/wrc/newstruc.c --- wine-cvs/tools/wrc/newstruc.c Sun Dec 10 15:45:54 2000 +++ wine-uw/tools/wrc/newstruc.c Sun Dec 17 18:11:32 2000 @@ -374,7 +374,6 @@ { int cnt; int i; - icon_dir_entry_t *ide; icon_t *ico; icon_t *list = NULL; icon_header_t *ih = (icon_header_t *)rd->data; @@ -388,31 +387,34 @@ yyerror("Icon resource data has invalid type id %d", ih->type); cnt = swap ? BYTESWAP_WORD(ih->count) : ih->count; - ide = (icon_dir_entry_t *)((char *)rd->data + sizeof(icon_header_t)); for(i = 0; i < cnt; i++) { + icon_dir_entry_t ide; + BITMAPINFOHEADER info; + memcpy(&ide, rd->data + sizeof(icon_header_t) + + i*sizeof(icon_dir_entry_t), sizeof(ide)); + ico = new_icon(); ico->id = alloc_icon_id(icog->lvc.language); ico->lvc = icog->lvc; if(swap) { - ide[i].offset = BYTESWAP_DWORD(ide[i].offset); - ide[i].ressize= BYTESWAP_DWORD(ide[i].ressize); + ide.offset = BYTESWAP_DWORD(ide.offset); + ide.ressize= BYTESWAP_DWORD(ide.ressize); } - if(ide[i].offset > rd->size - || ide[i].offset + ide[i].ressize > rd->size) + if(ide.offset > rd->size + || ide.offset + ide.ressize > rd->size) yyerror("Icon resource data corrupt"); - ico->width = ide[i].width; - ico->height = ide[i].height; - ico->nclr = ide[i].nclr; - ico->planes = swap ? BYTESWAP_WORD(ide[i].planes) : ide[i].planes; - ico->bits = swap ? BYTESWAP_WORD(ide[i].bits) : ide[i].bits; - convert_bitmap((char *)rd->data + ide[i].offset, 0); + ico->width = ide.width; + ico->height = ide.height; + ico->nclr = ide.nclr; + ico->planes = swap ? BYTESWAP_WORD(ide.planes) : ide.planes; + ico->bits = swap ? BYTESWAP_WORD(ide.bits) : ide.bits; + convert_bitmap((char *)rd->data + ide.offset, 0); + memcpy(&info, rd->data + ide.offset, sizeof(info)); if(!ico->planes) { - WORD planes; /* Argh! They did not fill out the resdir structure */ - planes = ((BITMAPINFOHEADER *)((char *)rd->data + ide[i].offset))->biPlanes; /* The bitmap is in destination byteorder. We want native for our structures */ switch(byteorder) { @@ -421,17 +423,15 @@ #else case WRC_BO_BIG: #endif - ico->planes = BYTESWAP_WORD(planes); + ico->planes = BYTESWAP_WORD(info.biPlanes); break; default: - ico->planes = planes; + ico->planes = info.biPlanes; } } if(!ico->bits) { - WORD bits; /* Argh! They did not fill out the resdir structure */ - bits = ((BITMAPINFOHEADER *)((char *)rd->data + ide[i].offset))->biBitCount; /* The bitmap is in destination byteorder. We want native for our structures */ switch(byteorder) { @@ -440,14 +440,14 @@ #else case WRC_BO_BIG: #endif - ico->bits = BYTESWAP_WORD(bits); + ico->bits = BYTESWAP_WORD(info.biBitCount); break; default: - ico->bits = bits; + ico->bits = info.biBitCount; } } ico->data = new_raw_data(); - copy_raw_data(ico->data, rd, ide[i].offset, ide[i].ressize); + copy_raw_data(ico->data, rd, ide.offset, ide.ressize); if(!list) { list = ico; @@ -467,7 +467,6 @@ { int cnt; int i; - cursor_dir_entry_t *cde; cursor_t *cur; cursor_t *list = NULL; cursor_header_t *ch = (cursor_header_t *)rd->data; @@ -480,29 +479,29 @@ else yyerror("Cursor resource data has invalid type id %d", ch->type); cnt = swap ? BYTESWAP_WORD(ch->count) : ch->count; - cde = (cursor_dir_entry_t *)((char *)rd->data + sizeof(cursor_header_t)); for(i = 0; i < cnt; i++) { - WORD planes; - WORD bits; + cursor_dir_entry_t cde; + BITMAPINFOHEADER info; + memcpy(&cde, rd->data + sizeof(cursor_header_t) + + i*sizeof(cursor_dir_entry_t), sizeof(cde)); + cur = new_cursor(); cur->id = alloc_cursor_id(curg->lvc.language); cur->lvc = curg->lvc; if(swap) { - cde[i].offset = BYTESWAP_DWORD(cde[i].offset); - cde[i].ressize= BYTESWAP_DWORD(cde[i].ressize); + cde.offset = BYTESWAP_DWORD(cde.offset); + cde.ressize= BYTESWAP_DWORD(cde.ressize); } - if(cde[i].offset > rd->size - || cde[i].offset + cde[i].ressize > rd->size) + if(cde.offset > rd->size + || cde.offset + cde.ressize > rd->size) yyerror("Cursor resource data corrupt"); - cur->width = cde[i].width; - cur->height = cde[i].height; - cur->nclr = cde[i].nclr; - convert_bitmap((char *)rd->data + cde[i].offset, 0); - /* The next two are to support color cursors */ - planes = ((BITMAPINFOHEADER *)((char *)rd->data + cde[i].offset))->biPlanes; - bits = ((BITMAPINFOHEADER *)((char *)rd->data + cde[i].offset))->biBitCount; + cur->width = cde.width; + cur->height = cde.height; + cur->nclr = cde.nclr; + convert_bitmap((char *)rd->data + cde.offset, 0); + memcpy(&info, rd->data + cde.offset, sizeof(info)); /* The bitmap is in destination byteorder. We want native for our structures */ switch(byteorder) { @@ -511,19 +510,19 @@ #else case WRC_BO_BIG: #endif - cur->planes = BYTESWAP_WORD(planes); - cur->bits = BYTESWAP_WORD(bits); + cur->planes = BYTESWAP_WORD(info.biPlanes); + cur->bits = BYTESWAP_WORD(info.biBitCount); break; default: - cur->planes = planes; - cur->bits = bits; + cur->planes = info.biPlanes; + cur->bits = info.biBitCount; } if(!win32 && (cur->planes != 1 || cur->bits != 1)) yywarning("Win16 cursor contains colors"); - cur->xhot = swap ? BYTESWAP_WORD(cde[i].xhot) : cde[i].xhot; - cur->yhot = swap ? BYTESWAP_WORD(cde[i].yhot) : cde[i].yhot; + cur->xhot = swap ? BYTESWAP_WORD(cde.xhot) : cde.xhot; + cur->yhot = swap ? BYTESWAP_WORD(cde.yhot) : cde.yhot; cur->data = new_raw_data(); - copy_raw_data(cur->data, rd, cde[i].offset, cde[i].ressize); + copy_raw_data(cur->data, rd, cde.offset, cde.ressize); if(!list) { list = cur; @@ -941,6 +940,7 @@ if(!hi && !lo) yyerror("Invalid messagetable block count 0"); +#if 0 #ifdef WORDS_BIGENDIAN if(!hi && lo && byteorder != WRC_BO_LITTLE) #else @@ -960,10 +960,16 @@ mbp[i].idhi = BYTESWAP_DWORD(mbp[i].idhi); mbp[i].offset = BYTESWAP_DWORD(mbp[i].offset); mep = (msgtab_entry_t *)(((char *)rd->data) + mbp[i].offset); + +printf( "idlo: %d idhi: %d offset: %x\n", mbp[i].idlo, mbp[i].idhi, mbp[i].offset ); + for(id = mbp[i].idlo; id <= mbp[i].idhi; id++) { mep->length = BYTESWAP_WORD(mep->length); mep->flags = BYTESWAP_WORD(mep->flags); + +printf( "length: %d flags: %d\n", mep->length, mep->flags ); + if(MSGTAB_BAD_PTR(mep, rd->data, rd->size, mep->length)) yyerror("Messagetable's data for block %d, ID 0x%08lx is outside of defined data", (int)i, id); if(mep->flags == 1) /* Docu says 'flags == 0x0001' for unicode */ @@ -982,6 +988,7 @@ } } } +#endif return msg; } diff -ur wine-cvs/tools/wrc/parser.y wine-uw/tools/wrc/parser.y --- wine-cvs/tools/wrc/parser.y Sun Dec 10 15:45:54 2000 +++ wine-uw/tools/wrc/parser.y Sun Dec 17 18:11:32 2000 @@ -2329,15 +2329,20 @@ rd->data = (char *)xmalloc(rd->size); switch(byteorder) { -#ifndef WORDS_BIGENDIAN - case WRC_BO_BIG: -#else - case WRC_BO_LITTLE: +#ifdef WORDS_BIGENDIAN + default: #endif - *(WORD *)(rd->data) = BYTESWAP_WORD((WORD)i); + case WRC_BO_BIG: + rd->data[0] = HIBYTE(i); + rd->data[1] = LOBYTE(i); break; + +#ifndef WORDS_BIGENDIAN default: - *(WORD *)(rd->data) = (WORD)i; +#endif + case WRC_BO_LITTLE: + rd->data[1] = HIBYTE(i); + rd->data[0] = LOBYTE(i); break; } return rd; @@ -2351,15 +2356,24 @@ rd->data = (char *)xmalloc(rd->size); switch(byteorder) { -#ifndef WORDS_BIGENDIAN - case WRC_BO_BIG: -#else - case WRC_BO_LITTLE: +#ifdef WORDS_BIGENDIAN + default: #endif - *(DWORD *)(rd->data) = BYTESWAP_DWORD((DWORD)i); + case WRC_BO_BIG: + rd->data[0] = HIBYTE(HIWORD(i)); + rd->data[1] = LOBYTE(HIWORD(i)); + rd->data[2] = HIBYTE(LOWORD(i)); + rd->data[3] = LOBYTE(LOWORD(i)); break; + +#ifndef WORDS_BIGENDIAN default: - *(DWORD *)(rd->data) = (DWORD)i; +#endif + case WRC_BO_LITTLE: + rd->data[3] = HIBYTE(HIWORD(i)); + rd->data[2] = LOBYTE(HIWORD(i)); + rd->data[1] = HIBYTE(LOWORD(i)); + rd->data[0] = LOBYTE(LOWORD(i)); break; } return rd; @@ -2378,17 +2392,25 @@ int i; switch(byteorder) { -#ifndef WORDS_BIGENDIAN - case WRC_BO_BIG: -#else - case WRC_BO_LITTLE: +#ifdef WORDS_BIGENDIAN + default: #endif + case WRC_BO_BIG: for(i = 0; i < str->size; i++) - *(WORD *)&(rd->data[2*i]) = BYTESWAP_WORD((WORD)str->str.wstr[i]); + { + rd->data[2*i + 0] = HIBYTE((WORD)str->str.wstr[i]); + rd->data[2*i + 1] = LOBYTE((WORD)str->str.wstr[i]); + } break; +#ifndef WORDS_BIGENDIAN default: +#endif + case WRC_BO_LITTLE: for(i = 0; i < str->size; i++) - *(WORD *)&(rd->data[2*i]) = (WORD)str->str.wstr[i]; + { + rd->data[2*i + 1] = HIBYTE((WORD)str->str.wstr[i]); + rd->data[2*i + 0] = LOBYTE((WORD)str->str.wstr[i]); + } break; } }
diff -ur wine-cvs/include/builtin16.h wine-uw/include/builtin16.h --- wine-cvs/include/builtin16.h Sun Dec 10 15:45:19 2000 +++ wine-uw/include/builtin16.h Sun Dec 17 23:45:25 2000 @@ -13,6 +13,7 @@ struct _CONTEXT86; struct _STACK16FRAME; +#ifdef __i386__ #include "pshpack1.h" typedef struct @@ -38,6 +39,20 @@ } CALLFROM16; #include "poppack.h" +#else + +typedef struct +{ + void (*target)(); + int callfrom16; +} ENTRYPOINT16; + +typedef struct +{ + LPCSTR profile; +} CALLFROM16; + +#endif typedef struct { diff -ur wine-cvs/loader/module.c wine-uw/loader/module.c --- wine-cvs/loader/module.c Sun Dec 17 18:03:32 2000 +++ wine-uw/loader/module.c Sun Dec 17 18:11:31 2000 @@ -347,7 +347,7 @@ + strlen(filename) + 1; size = sizeof(NE_MODULE) + /* loaded file info */ - of_size + + ((of_size + 3) & ~3) + /* segment table: DS,CS */ 2 * sizeof(SEGTABLEENTRY) + /* name table */ @@ -396,7 +396,7 @@ ofs->cBytes = of_size < 256 ? of_size : 255; /* FIXME */ strcpy( ofs->szPathName, filename ); - pSegment = (SEGTABLEENTRY*)((char*)(pModule + 1) + of_size); + pSegment = (SEGTABLEENTRY*)((char*)(pModule + 1) + ((of_size + 3) & ~3)); pModule->seg_table = (int)pSegment - (int)pModule; /* Data segment */ pSegment->size = 0; diff -ur wine-cvs/loader/ne/module.c wine-uw/loader/ne/module.c --- wine-cvs/loader/ne/module.c Sun Dec 17 18:03:32 2000 +++ wine-uw/loader/ne/module.c Mon Dec 18 00:21:05 2000 @@ -238,6 +238,7 @@ unsigned char buffer[256], *cpnt; BYTE len; NE_MODULE *pModule; + WORD ordinal; if (!(pModule = NE_GetPtr( hModule ))) return 0; assert( !(pModule->flags & NE_FFLAGS_WIN32) ); @@ -264,9 +265,9 @@ { if (((BYTE)*cpnt == len) && !memcmp( cpnt+1, buffer, len )) { - TRACE(" Found: ordinal=%d\n", - *(WORD *)(cpnt + *cpnt + 1) ); - return *(WORD *)(cpnt + *cpnt + 1); + memcpy( &ordinal, cpnt + *cpnt + 1, sizeof(WORD) ); + TRACE(" Found: ordinal=%d\n", ordinal ); + return ordinal; } cpnt += *cpnt + 1 + sizeof(WORD); } @@ -282,9 +283,9 @@ { if (((BYTE)*cpnt == len) && !memcmp( cpnt+1, buffer, len )) { - TRACE(" Found: ordinal=%d\n", - *(WORD *)(cpnt + *cpnt + 1) ); - return *(WORD *)(cpnt + *cpnt + 1); + memcpy( &ordinal, cpnt + *cpnt + 1, sizeof(WORD) ); + TRACE(" Found: ordinal=%d\n", ordinal ); + return ordinal; } cpnt += *cpnt + 1 + sizeof(WORD); } @@ -312,7 +313,7 @@ NE_MODULE *pModule; WORD sel, offset, i; - ET_ENTRY *entry; + ET_ENTRY entry; ET_BUNDLE *bundle; if (!(pModule = NE_GetPtr( hModule ))) return 0; @@ -326,12 +327,12 @@ bundle = (ET_BUNDLE *)((BYTE *)pModule + bundle->next); } - entry = (ET_ENTRY *)((BYTE *)bundle+6); - for (i=0; i < (ordinal - bundle->first - 1); i++) - entry++; + memcpy( &entry, (BYTE *)(bundle+1) + + (ordinal - bundle->first - 1) * sizeof(ET_ENTRY), + sizeof(ET_ENTRY) ); - sel = entry->segnum; - offset = entry->offs; + sel = entry.segnum; + offset = entry.offs; if (sel == 0xfe) sel = 0xffff; /* constant entry */ else sel = GlobalHandleToSel16(NE_SEG_TABLE(pModule)[sel-1].hSeg); @@ -353,7 +354,7 @@ BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset ) { NE_MODULE *pModule; - ET_ENTRY *entry; + ET_ENTRY entry; ET_BUNDLE *bundle; int i; @@ -368,11 +369,16 @@ return 0; } - entry = (ET_ENTRY *)((BYTE *)bundle+6); - for (i=0; i < (ordinal - bundle->first - 1); i++) - entry++; + memcpy( &entry, (BYTE *)(bundle+1) + + (ordinal - bundle->first - 1) * sizeof(ET_ENTRY), + sizeof(ET_ENTRY) ); + + entry.offs = offset; + + memcpy( (BYTE *)(bundle+1) + + (ordinal - bundle->first - 1) * sizeof(ET_ENTRY), + &entry, sizeof(ET_ENTRY) ); - entry->offs = offset; return TRUE; } diff -ur wine-cvs/tools/winebuild/import.c wine-uw/tools/winebuild/import.c --- wine-cvs/tools/winebuild/import.c Sun Dec 17 18:03:38 2000 +++ wine-uw/tools/winebuild/import.c Sun Dec 17 21:49:44 2000 @@ -44,14 +44,19 @@ /* locate a symbol in a (sorted) list */ inline static const char *find_symbol( const char *name, char **table, int size ) { - char **res = bsearch( &name, table, size, sizeof(*table), name_cmp ); - return res ? *res : NULL; + if ( table && size ) + { + char **res = bsearch( &name, table, size, sizeof(*table), name_cmp ); + return res ? *res : NULL; + } + return NULL; } /* sort a symbol table */ inline static void sort_symbols( char **table, int size ) { - qsort( table, size, sizeof(*table), name_cmp ); + if ( table && size ) + qsort( table, size, sizeof(*table), name_cmp ); } /* open the .so library for a given dll in a specified path */ @@ -276,7 +281,8 @@ char *p = buffer + strlen(buffer) - 1; if (p < buffer) continue; if (*p == '\n') *p-- = 0; - add_undef_symbol( buffer ); + p = buffer; while (*p == ' ') p++; + add_undef_symbol( p ); } if ((err = pclose( f ))) fatal_error( "nm -u %s error %d\n", name, err ); } @@ -373,7 +379,7 @@ fprintf( outfile, "#ifndef __GNUC__\nstatic void __asm__dummy_import(void) {\n#endif\n\n" ); pos = 20 * (nb_imports + 1); /* offset of imports.data from start of imports */ - fprintf( outfile, "asm(\".align 8\\n\"\n" ); + fprintf( outfile, "asm(\".data\\n\\t.align 8\\n\"\n" ); for (i = 0; i < nb_imports; i++, pos += 4) { for (j = 0; j < dll_imports[i]->nb_imports; j++, pos += 4) @@ -382,14 +388,39 @@ dll_imports[i]->imports[j] ); fprintf( outfile, " \"\\t.globl " PREFIX "%s\\n\"\n", dll_imports[i]->imports[j] ); - fprintf( outfile, " \"" PREFIX "%s:\\t", dll_imports[i]->imports[j] ); + fprintf( outfile, " \"" PREFIX "%s:\\n\\t", dll_imports[i]->imports[j] +); + +#if defined(__i386__) if (strstr( dll_imports[i]->imports[j], "__wine_call_from_16" )) - fprintf( outfile, ".byte 0x2e\\n\\tjmp *(imports+%d)\\n\\tnop\\n\"\n", pos ); + fprintf( outfile, ".byte 0x2e\\n\\tjmp *(imports+%d)\\n\\tnop\\n", +pos ); else - fprintf( outfile, "jmp *(imports+%d)\\n\\tmovl %%esi,%%esi\\n\"\n", pos ); + fprintf( outfile, "jmp *(imports+%d)\\n\\tmovl %%esi,%%esi\\n", pos ); +#elif defined(__sparc__) + if ( !UsePIC ) + { + fprintf( outfile, "sethi %%hi(imports+%d), %%g1\\n\\t", pos ); + fprintf( outfile, "ld [%%g1+%%lo(imports+%d)], %%g1\\n\\t", pos ); + fprintf( outfile, "jmp %%g1\\n\\tnop\\n" ); + } + else + { + /* Hmpf. Stupid sparc assembler always interprets global variable + names as GOT offsets, so we have to do it the long way ... */ + fprintf( outfile, "save %%sp, -96, %%sp\\n" ); + fprintf( outfile, "0:\\tcall 1f\\n\\tnop\\n" ); + fprintf( outfile, "1:\\tsethi %%hi(imports+%d-0b), %%g1\\n\\t", pos ); + fprintf( outfile, "or %%g1, %%lo(imports+%d-0b), %%g1\\n\\t", pos ); + fprintf( outfile, "ld [%%g1+%%o7], %%g1\\n\\t" ); + fprintf( outfile, "jmp %%g1\\n\\trestore\\n" ); + } +#else +#error You need to define import thunks for your architecture! +#endif + + fprintf( outfile, "\"\n" ); } } - fprintf( outfile, ");\n#ifndef __GNUC__\n}\n#endif\n\n" ); + fprintf( outfile, "\".previous\");\n#ifndef __GNUC__\n}\n#endif\n\n" ); done: return nb_imports; diff -ur wine-cvs/tools/winebuild/res16.c wine-uw/tools/winebuild/res16.c --- wine-cvs/tools/winebuild/res16.c Sun Nov 26 00:54:12 2000 +++ wine-uw/tools/winebuild/res16.c Mon Dec 18 00:51:51 2000 @@ -89,17 +89,26 @@ static WORD get_word(void) { /* might not be aligned */ - /* FIXME: should we change this on big-endian machines? */ +#ifdef WORDS_BIGENDIAN + unsigned char high = get_byte(); + unsigned char low = get_byte(); +#else unsigned char low = get_byte(); unsigned char high = get_byte(); +#endif return low | (high << 8); } /* get the next dword from the current resource file */ static DWORD get_dword(void) { +#ifdef WORDS_BIGENDIAN + WORD high = get_word(); + WORD low = get_word(); +#else WORD low = get_word(); WORD high = get_word(); +#endif return low | (high << 16); } @@ -207,8 +216,13 @@ inline static void put_word( unsigned char **buffer, WORD val ) { +#ifdef WORDS_BIGENDIAN + put_byte( buffer, HIBYTE(val) ); + put_byte( buffer, LOBYTE(val) ); +#else put_byte( buffer, LOBYTE(val) ); put_byte( buffer, HIBYTE(val) ); +#endif } /* output a string preceded by its length */ diff -ur wine-cvs/tools/winebuild/spec16.c wine-uw/tools/winebuild/spec16.c --- wine-cvs/tools/winebuild/spec16.c Sun Dec 17 18:03:38 2000 +++ wine-uw/tools/winebuild/spec16.c Mon Dec 18 01:07:10 2000 @@ -12,6 +12,7 @@ #include <ctype.h> #include "config.h" +#include "winnt.h" #include "wine/exception.h" #include "builtin16.h" #include "module.h" @@ -19,12 +20,6 @@ #include "build.h" -#ifdef __i386__ -extern unsigned short __get_cs(void); -__ASM_GLOBAL_FUNC( __get_cs, "movw %cs,%ax\n\tret" ); -#else -static inline unsigned short __get_cs(void) { return 0; } -#endif /* __i386__ */ /******************************************************************* @@ -64,14 +59,14 @@ static int BuildModule16( FILE *outfile, int max_code_offset, int max_data_offset ) { - int i; + WORD i; char *buffer; NE_MODULE *pModule; SEGTABLEENTRY *pSegment; OFSTRUCT *pFileInfo; BYTE *pstr; ET_BUNDLE *bundle = 0; - ET_ENTRY *entry = 0; + ET_ENTRY entry; /* Module layout: * NE_MODULE Module @@ -125,9 +120,7 @@ pFileInfo->cBytes = sizeof(*pFileInfo) - sizeof(pFileInfo->szPathName) + strlen(DLLFileName); strcpy( pFileInfo->szPathName, DLLFileName ); - pstr = (char *)pFileInfo + pFileInfo->cBytes + 1; - -#ifdef __i386__ /* FIXME: Alignment problems! */ + pstr = (char *)pFileInfo + ((pFileInfo->cBytes + 1 + 3) & ~3); /* Segment table */ @@ -150,9 +143,9 @@ /* Resource table */ - pstr = (char *)pSegment; + pstr = (char *)pSegment + 2; pModule->res_table = (int)pstr - (int)pModule; - pstr += output_res16_directory( pstr ); + pstr += (output_res16_directory( pstr ) + 3) & ~3; /* Imported names table */ @@ -164,10 +157,11 @@ pModule->name_table = (int)pstr - (int)pModule; /* First entry is module name */ - *pstr = strlen(DLLName ); + *pstr = strlen( DLLName ); strcpy( pstr + 1, DLLName ); pstr += *pstr + 1; - *(WORD *)pstr = 0; + i = 0; + memcpy( pstr, &i, sizeof(WORD) ); pstr += sizeof(WORD); /* Store all ordinals */ for (i = 1; i <= Limit; i++) @@ -178,10 +172,11 @@ strcpy( pstr + 1, odp->name ); strupper( pstr + 1 ); pstr += *pstr + 1; - *(WORD *)pstr = i; + memcpy( pstr, &i, sizeof(WORD) ); pstr += sizeof(WORD); } *pstr++ = 0; + pstr = (char *)(((long)pstr + 3) & ~3); /* Entry table */ @@ -223,6 +218,7 @@ bundle->last++; else { + pstr = (char *)(((long)pstr + 1) & ~1); if ( bundle ) bundle->next = (char *)pstr - (char *)pModule; @@ -234,15 +230,15 @@ } /* FIXME: is this really correct ?? */ - entry = (ET_ENTRY *)pstr; - entry->type = 0xff; /* movable */ - entry->flags = 3; /* exported & public data */ - entry->segnum = selector; - entry->offs = odp->offset; + entry.type = 0xff; /* movable */ + entry.flags = 3; /* exported & public data */ + entry.segnum = selector; + entry.offs = odp->offset; + memcpy( pstr, &entry, sizeof(ET_ENTRY) ); pstr += sizeof(ET_ENTRY); } *pstr++ = 0; -#endif + pstr = (char *)(((long)pstr + 3) & ~3); /* Dump the module content */ @@ -557,7 +553,9 @@ int i, nFuncs, nTypes; int code_offset, data_offset, module_size, res_size; unsigned char *data; +#ifdef __i386__ unsigned short code_selector = __get_cs(); +#endif /* File header */ @@ -613,7 +611,7 @@ } /* Output CallFrom16 routines needed by this .spec file */ - +#ifdef __i386__ for ( i = 0; i < nTypes; i++ ) { char profile[101]; @@ -627,6 +625,7 @@ BuildCallFrom16Func( outfile, profile, DLLName, TRUE ); } +#endif /* Output the DLL functions prototypes */ @@ -686,6 +685,7 @@ if ( typelist[i]->type == TYPE_INTERRUPT ) argsize += 2; +#ifdef __i386__ fprintf( outfile, " { 0x68, %s_CallFrom16_%s, 0x9a, __wine_call_from_16_%s,\n", DLLName, profile, (typelist[i]->type == TYPE_REGISTER @@ -697,6 +697,9 @@ else fprintf( outfile, " 0x%04x, 0x66, 0xcb, 0x9090, \"%s\" },\n", code_selector, profile ); +#else + fprintf( outfile, " { \"%s\" },\n", profile ); +#endif code_offset += sizeof(CALLFROM16); } @@ -727,7 +730,11 @@ assert( type ); fprintf( outfile, " /* %s.%d */ ", DLLName, i ); +#ifdef __i386__ fprintf( outfile, "{ 0x5566, 0x68, %s, 0xe866, %d /* %s_%s_%s */ },\n", +#else + fprintf( outfile, "{ %s, %d, /* %s_%s_%s */ },\n", +#endif odp->link_name, (type-typelist)*sizeof(CALLFROM16) - (code_offset + sizeof(ENTRYPOINT16)), @@ -736,6 +743,7 @@ (odp->type == TYPE_INTERRUPT) ? "intr" : (odp->type == TYPE_PASCAL_16) ? "word" : "long", odp->u.func.arg_types ); + odp->offset = code_offset; code_offset += sizeof(ENTRYPOINT16); break; @@ -772,20 +780,26 @@ /* Output the DLL constructor */ +#ifdef __GNUC__ + fprintf( outfile, + "void __wine_spec_%s_init(void) __attribute__((constructor));\n", + DLLName ); +#elif defined(__i386__) fprintf( outfile, - "#ifndef __GNUC__\n" "static void __asm__dummy_dll_init(void) {\n" - "#endif /* defined(__GNUC__) */\n" "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" " \"\\tcall " PREFIX "__wine_spec_%s_init\\n\"\n" " \"\\t.previous\\n\");\n" - "#ifndef __GNUC__\n" - "}\n" - "#endif /* defined(__GNUC__) */\n\n" + "}\n", DLLName ); +#else +#error You need to define the DLL constructor for your architecture +#endif + + fprintf( outfile, "void __wine_spec_%s_init(void)\n" "{\n" " __wine_register_dll_16( &descriptor );\n" - "}\n", DLLName, DLLName ); + "}\n", DLLName ); } @@ -843,3 +857,4 @@ fclose( infile ); } + diff -ur wine-cvs/tools/winebuild/spec32.c wine-uw/tools/winebuild/spec32.c --- wine-cvs/tools/winebuild/spec32.c Sun Dec 17 18:03:38 2000 +++ wine-uw/tools/winebuild/spec32.c Sun Dec 17 18:11:32 2000 @@ -660,9 +660,16 @@ /* Output the DLL constructor */ - fprintf( outfile, "#ifndef __GNUC__\n" ); +#ifdef __GNUC__ + fprintf( outfile, + "void __wine_spec_%s_init(void) __attribute__((constructor));\n", + DLLName ); + if ( nr_debug ) + fprintf( outfile, + "void __wine_spec_%s_fini(void) __attribute__((destructor));\n", + DLLName ); +#elif defined(__i386__) fprintf( outfile, "static void __asm__dummy_dll_init(void) {\n" ); - fprintf( outfile, "#endif /* defined(__GNUC__) */\n" ); fprintf( outfile, "asm(\"\\t.section\t.init ,\\\"ax\\\"\\n\"\n" ); fprintf( outfile, " \"\\tcall " PREFIX "__wine_spec_%s_init\\n\"\n", DLLName ); fprintf( outfile, " \"\\t.previous\\n\");\n" ); @@ -672,9 +679,10 @@ fprintf( outfile, " \"\\tcall " PREFIX "__wine_spec_%s_fini\\n\"\n", DLLName ); fprintf( outfile, " \"\\t.previous\\n\");\n" ); } - fprintf( outfile, "#ifndef __GNUC__\n" ); fprintf( outfile, "}\n" ); - fprintf( outfile, "#endif /* defined(__GNUC__) */\n\n" ); +#else +#error You need to define the DLL constructor for your architecture +#endif fprintf( outfile, "void __wine_spec_%s_init(void)\n"