Generate 16-bit spec files as assembly code too.

oldstable
Alexandre Julliard 2005-09-21 14:23:54 +00:00
parent 331e09c22c
commit 5cb97d833a
11 changed files with 585 additions and 757 deletions

View File

@ -59,6 +59,7 @@ EXTRACFLAGS = @EXTRACFLAGS@
ALLCFLAGS = $(INCLUDES) $(DEFS) $(DLLFLAGS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS) $(MODCFLAGS)
ALLLINTFLAGS = $(INCLUDES) $(DEFS) $(LINTFLAGS)
IDLFLAGS = $(INCLUDES) $(DEFS) $(EXTRAIDLFLAGS)
WINEBUILDFLAGS = $(DLLFLAGS) --as-cmd "$(AS)"
MKINSTALLDIRS= $(TOPSRCDIR)/tools/mkinstalldirs -m 755
WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi/winapi_check
WINEWRAPPER = $(TOPSRCDIR)/tools/winewrapper
@ -107,7 +108,7 @@ prog_manext = 1
api_manext = 3w
conf_manext = 5
CLEAN_FILES = *.o *.a *.so *.ln *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
*.flc *.spec.c *.dbg.c *.tab.c *.tab.h @LEX_OUTPUT_ROOT@.c core
*.flc *.dbg.c *.tab.c *.tab.h @LEX_OUTPUT_ROOT@.c core
OBJS = $(C_SRCS:.c=.o) $(EXTRA_OBJS)
@ -116,7 +117,7 @@ LINTS = $(C_SRCS:.c=.ln)
# Implicit rules
.SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .idl .tlb .h .ok .sfd .ttf
.SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.o .idl .tlb .h .ok .sfd .ttf
.c.o:
$(CC) -c $(ALLCFLAGS) -o $@ $<
@ -133,8 +134,8 @@ LINTS = $(C_SRCS:.c=.ln)
.res.res.o:
$(WINDRES) -i $< -o $@
.spec.spec.c:
$(WINEBUILD) $(DEFS) --dll -o $@ --main-module $(MODULE) --export $<
.spec.spec.o:
$(WINEBUILD) $(WINEBUILDFLAGS) --dll -o $@ --main-module $(MODULE) --export $<
.idl.h:
$(WIDL) $(IDLFLAGS) -h -H $@ $<

View File

@ -136,10 +136,10 @@ $(TESTSUBDIRS:%=%/__crosstest__): tools include
# Misc rules
TAGS etags:
find $(TOPSRCDIR) -name '*.[ch]' -a -not -name '*.spec.c' -a -not -name '*.dbg.c' -print | etags -
find $(TOPSRCDIR) -name '*.[ch]' -a -not -name '*.dbg.c' -print | etags -
tags ctags:
find $(TOPSRCDIR) -name '*.[ch]' -a -not -name '*.spec.c' -a -not -name '*.dbg.c' -print | ctags --c-types=+px -L -
find $(TOPSRCDIR) -name '*.[ch]' -a -not -name '*.dbg.c' -print | ctags --c-types=+px -L -
manpages htmlpages sgmlpages:
cd documentation && $(MAKE) $@

View File

@ -67,7 +67,7 @@ lib$(BASEMODULE).a: $(SPEC_DEF) $(IMPLIB_OBJS)
$(WIN16_FILES:%=__checklink16__%): checklink16
checklink16:: $(MAINSPEC).o $(OBJS) $(MODULE).dbg.o dummy
$(CC) -o checklink -Wl,-rpath,$(TOPOBJDIR)/libs $(TOPSRCDIR)/dlls/checklink.c $(MAINSPEC).o $(OBJS) $(MODULE).dbg.o -L$(DLLDIR) $(ALL_LIBS) -lwinecrt0 -lm && $(RM) checklink $(MAINSPEC).s $(MAINSPEC).o
$(CC) -o checklink -Wl,-rpath,$(TOPOBJDIR)/libs $(TOPSRCDIR)/dlls/checklink.c $(MAINSPEC).o $(OBJS) $(MODULE).dbg.o -L$(DLLDIR) $(ALL_LIBS) -lwinecrt0 -lm && $(RM) checklink $(MAINSPEC).o
checklink:: $(WIN16_FILES:%=__checklink16__%)
@ -77,10 +77,10 @@ check test:: $(SUBDIRS:%=%/__test__)
crosstest:: $(SUBDIRS:%=%/__crosstest__)
# Rule to explicitly generate the .spec.c for debugging
# Rule to explicitly generate the .spec.s for debugging
$(MAINSPEC).s: $(MAINSPEC) $(ALL_OBJS)
$(WINEBUILD) $(DEFS) $(DLLFLAGS) --dll -o $@ --export $(SRCDIR)/$(MAINSPEC) $(SUBSYSTEM:%=--subsystem %) $(ALL_OBJS) $(DLL_LDPATH) $(ALL_IMPORTS:%=-l%) $(DELAYIMPORTS:%=-d%) $(DLLDIR)/libwinecrt0.a
$(MAINSPEC).s $(MAINSPEC).o: $(MAINSPEC) $(ALL_OBJS)
$(WINEBUILD) $(WINEBUILDFLAGS) --dll -o $@ --export $(SRCDIR)/$(MAINSPEC) $(SUBSYSTEM:%=--subsystem %) $(ALL_OBJS) $(DLL_LDPATH) $(ALL_IMPORTS:%=-l%) $(DELAYIMPORTS:%=-d%) $(DLLDIR)/libwinecrt0.a
# Rules for auto documentation
@ -137,6 +137,6 @@ uninstall::
clean::
$(RM) $(SPEC_DEF)
$(SPEC_DEF) $(SPEC_SRCS16:.spec=.spec.c): $(WINEBUILD)
$(SPEC_DEF) $(SPEC_SRCS16:.spec=.spec.o): $(WINEBUILD)
# End of global dll rules

View File

@ -71,8 +71,8 @@ EXTRASUBDIRS = \
# Special rules for 16-bit resource and spec files
gdi.exe.spec.c: gdi.exe.spec version16.res
$(WINEBUILD) $(DEFS) $(DLLFLAGS) --dll -o $@ --heap 65520 --main-module $(MODULE) --res version16.res --export $(SRCDIR)/gdi.exe.spec
gdi.exe.spec.o: gdi.exe.spec version16.res
$(WINEBUILD) $(WINEBUILDFLAGS) --dll -o $@ --heap 65520 --main-module $(MODULE) --res version16.res --export $(SRCDIR)/gdi.exe.spec
version16.res: version16.rc
$(LDPATH) $(RC16) $(RC16FLAGS) -fo$@ $(SRCDIR)/version16.rc

View File

@ -84,8 +84,6 @@ C_SRCS16 = \
toolhelp16.c \
win87em.c
ASM_SRCS = relay16asm.s
RC_SRCS = kernel.rc
RC_SRCS16 = \
@ -94,7 +92,7 @@ RC_SRCS16 = \
MC_SRCS = \
messages/winerr_enu.mc
EXTRA_OBJS = $(ASM_SRCS:.s=.o)
EXTRA_OBJS = relay16asm.o
SUBDIRS = tests
EXTRASUBDIRS = messages nls
@ -102,18 +100,15 @@ EXTRASUBDIRS = messages nls
kernel.res: $(MC_SRCS:.mc=.mc.rc)
relay16asm.s: $(WINEBUILD)
$(WINEBUILD) $(DEFS) $(DLLFLAGS) -o $@ --relay16
relay16asm.o: $(WINEBUILD)
$(WINEBUILD) $(WINEBUILDFLAGS) -o $@ --relay16
# Special rules for 16-bit resource and spec files
krnl386.exe.spec.c: krnl386.exe.spec version16.res
$(WINEBUILD) $(DEFS) $(DLLFLAGS) --dll -o $@ --dll-name kernel --main-module $(MODULE) --res version16.res --export $(SRCDIR)/krnl386.exe.spec
krnl386.exe.spec.o: krnl386.exe.spec version16.res
$(WINEBUILD) $(WINEBUILDFLAGS) --dll -o $@ --dll-name kernel --main-module $(MODULE) --res version16.res --export $(SRCDIR)/krnl386.exe.spec
version16.res: version16.rc
$(LDPATH) $(RC16) $(RC16FLAGS) -fo$@ $(SRCDIR)/version16.rc
clean::
$(RM) $(ASM_SRCS)
### Dependencies:

View File

@ -49,18 +49,13 @@ C_SRCS = \
virtual.c \
wcstring.c
ASM_SRCS = relay32.s
EXTRA_OBJS = $(ASM_SRCS:.s=.o)
EXTRA_OBJS = relay32.o
SUBDIRS = tests
@MAKE_DLL_RULES@
relay32.s: $(WINEBUILD)
$(WINEBUILD) $(DEFS) $(DLLFLAGS) -o $@ --relay32
clean::
$(RM) $(ASM_SRCS)
relay32.o: $(WINEBUILD)
$(WINEBUILD) $(WINEBUILDFLAGS) -o $@ --relay32
### Dependencies:

View File

@ -81,8 +81,8 @@ SUBDIRS = tests
version16.res: version16.rc
$(LDPATH) $(RC16) $(RC16FLAGS) -fo$@ $(SRCDIR)/version16.rc
shell.spec.c: shell.spec version16.res
$(WINEBUILD) $(DEFS) $(DLLFLAGS) --dll -o $@ --main-module $(MODULE) --res version16.res --export $(SRCDIR)/shell.spec
shell.spec.o: shell.spec version16.res
$(WINEBUILD) $(WINEBUILDFLAGS) --dll -o $@ --main-module $(MODULE) --res version16.res --export $(SRCDIR)/shell.spec
authors.c: $(TOPSRCDIR)/AUTHORS
(LC_ALL=C; export LC_ALL; echo 'const char * const SHELL_Authors[] = {' && \

View File

@ -152,14 +152,14 @@ EXTRASUBDIRS = resources
# Special rules for 16-bit resource and spec files
user.exe.spec.c: user.exe.spec resources/version16.res
$(WINEBUILD) $(DEFS) $(DLLFLAGS) --dll -o $@ --heap 65520 --main-module $(MODULE) --res resources/version16.res --export $(SRCDIR)/user.exe.spec
user.exe.spec.o: user.exe.spec resources/version16.res
$(WINEBUILD) $(WINEBUILDFLAGS) --dll -o $@ --heap 65520 --main-module $(MODULE) --res resources/version16.res --export $(SRCDIR)/user.exe.spec
display.drv.spec.c: display.drv.spec resources/display.res
$(WINEBUILD) $(DEFS) $(DLLFLAGS) --dll -o $@ --main-module $(MODULE) --res resources/display.res --export $(SRCDIR)/display.drv.spec
display.drv.spec.o: display.drv.spec resources/display.res
$(WINEBUILD) $(WINEBUILDFLAGS) --dll -o $@ --main-module $(MODULE) --res resources/display.res --export $(SRCDIR)/display.drv.spec
mouse.drv.spec.c: mouse.drv.spec resources/mouse.res
$(WINEBUILD) $(DEFS) $(DLLFLAGS) --dll -o $@ --main-module $(MODULE) --res resources/mouse.res --export $(SRCDIR)/mouse.drv.spec
mouse.drv.spec.o: mouse.drv.spec resources/mouse.res
$(WINEBUILD) $(WINEBUILDFLAGS) --dll -o $@ --main-module $(MODULE) --res resources/mouse.res --export $(SRCDIR)/mouse.drv.spec
resources/display.res: resources/display.rc
$(LDPATH) $(RC16) $(RC16FLAGS) -fo$@ $(SRCDIR)/resources/display.rc

View File

@ -70,7 +70,6 @@ typedef struct
{
ORD_TYPE type;
int ordinal;
int offset;
int lineno;
int flags;
char *name; /* public name of this function */
@ -206,13 +205,8 @@ extern void output_imports( FILE *outfile, DLLSPEC *spec );
extern int load_res32_file( const char *name, DLLSPEC *spec );
extern void output_resources( FILE *outfile, DLLSPEC *spec );
extern void load_res16_file( const char *name, DLLSPEC *spec );
extern unsigned int get_res16_data_size( DLLSPEC *spec, unsigned int res_offset,
unsigned int alignment );
extern unsigned int output_res16_data( unsigned char **ret_buf, DLLSPEC *spec,
unsigned int res_offset, unsigned int alignment );
extern unsigned int get_res16_directory_size( DLLSPEC *spec );
extern unsigned int output_res16_directory( unsigned char **ret_buf, DLLSPEC *spec,
unsigned int res_offset, unsigned int alignment );
extern void output_res16_data( FILE *outfile, DLLSPEC *spec );
extern void output_res16_directory( FILE *outfile, DLLSPEC *spec, const char *header_name );
extern void output_dll_init( FILE *outfile, const char *constructor, const char *destructor );
extern void BuildRelays16( FILE *outfile );

View File

@ -241,189 +241,93 @@ static void free_resource_tree( struct res_tree *tree )
free( tree );
}
inline static void put_byte( unsigned char **buffer, unsigned char val )
{
*(*buffer)++ = val;
}
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 */
static void output_string( unsigned char **buffer, const char *str )
static void output_string( FILE *outfile, const char *str )
{
int len = strlen(str);
put_byte( buffer, len );
while (len--) put_byte( buffer, *str++ );
}
/* get the resource data total size */
unsigned int get_res16_data_size( DLLSPEC *spec, unsigned int res_offset, unsigned int alignment )
{
const struct resource *res;
unsigned int i, total;
unsigned int align_mask = (1 << alignment) - 1;
if (!spec->nb_resources) return 0;
/* add padding at the beginning if needed so that resources are properly aligned */
total = ((res_offset + align_mask) & ~align_mask) - res_offset;
for (i = 0, res = spec->resources; i < spec->nb_resources; i++, res++)
total += (res->data_size + align_mask) & ~align_mask;
return total;
unsigned int i, len = strlen(str);
fprintf( outfile, "\t.byte 0x%02x", len );
for (i = 0; i < len; i++) fprintf( outfile, ",0x%02x", (unsigned char)str[i] );
fprintf( outfile, " /* %s */\n", str );
}
/* output the resource data */
unsigned int output_res16_data( unsigned char **ret_buf, DLLSPEC *spec,
unsigned int res_offset, unsigned int alignment )
void output_res16_data( FILE *outfile, DLLSPEC *spec )
{
const struct resource *res;
unsigned char *p;
unsigned int i, total, padding;
unsigned int align_mask = (1 << alignment) - 1;
unsigned int i;
if (!spec->nb_resources) return 0;
if (!spec->nb_resources) return;
/* add padding at the beginning if needed so that resources are properly aligned */
padding = ((res_offset + align_mask) & ~align_mask) - res_offset;
for (i = total = 0, res = spec->resources; i < spec->nb_resources; i++, res++)
total += (res->data_size + align_mask) & ~align_mask;
*ret_buf = p = xmalloc( total + padding );
memset( p, 0, padding );
p += padding;
for (i = 0, res = spec->resources; i < spec->nb_resources; i++, res++)
{
unsigned int size = (res->data_size + align_mask) & ~align_mask;
memcpy( p, res->data, res->data_size );
memset( p + res->data_size, 0, size - res->data_size );
p += size;
fprintf( outfile, ".L__wine_spec_resource_%u:\n", i );
dump_bytes( outfile, res->data, res->data_size );
fprintf( outfile, ".L__wine_spec_resource_%u_end:\n", i );
}
return total;
}
/* get the resource definitions total size */
unsigned int get_res16_directory_size( DLLSPEC *spec )
{
unsigned int i, j, total_size;
struct res_tree *tree;
const struct res_type *type;
const struct resource *res;
tree = build_resource_tree( spec );
total_size = 4; /* alignment + terminator */
total_size += tree->nb_types * 8; /* typeinfo structures */
total_size += spec->nb_resources * 12; /* nameinfo structures */
for (i = 0, type = tree->types; i < tree->nb_types; i++, type++)
{
if (type->type->str) total_size += strlen(type->type->str) + 1;
for (j = 0, res = type->res; j < type->nb_names; j++, res++)
if (res->name.str) total_size += strlen(res->name.str) + 1;
}
total_size++; /* final terminator */
if (total_size & 1) total_size++;
return total_size;
}
/* output the resource definitions */
unsigned int output_res16_directory( unsigned char **ret_buf, DLLSPEC *spec,
unsigned int res_offset, unsigned int alignment )
void output_res16_directory( FILE *outfile, DLLSPEC *spec, const char *header_name )
{
int offset;
unsigned int i, j, total_size;
unsigned int align_mask = (1 << alignment) - 1;
unsigned int i, j;
struct res_tree *tree;
const struct res_type *type;
const struct resource *res;
unsigned char *buffer;
tree = build_resource_tree( spec );
/* make sure data offset is properly aligned */
res_offset = (res_offset + align_mask) & ~align_mask;
/* first compute total size */
offset = 4; /* alignment + terminator */
offset += tree->nb_types * 8; /* typeinfo structures */
offset += spec->nb_resources * 12; /* nameinfo structures */
total_size = offset;
for (i = 0, type = tree->types; i < tree->nb_types; i++, type++)
{
if (type->type->str) total_size += strlen(type->type->str) + 1;
for (j = 0, res = type->res; j < type->nb_names; j++, res++)
if (res->name.str) total_size += strlen(res->name.str) + 1;
}
total_size++; /* final terminator */
if (total_size & 1) total_size++;
*ret_buf = buffer = xmalloc( total_size );
put_word( &buffer, alignment );
fprintf( outfile, "\n.L__wine_spec_ne_rsrctab:\n" );
fprintf( outfile, "\t%s 0\n", get_asm_short_keyword() ); /* alignment */
/* type and name structures */
for (i = 0, type = tree->types; i < tree->nb_types; i++, type++)
{
if (type->type->str)
{
put_word( &buffer, offset );
offset += strlen(type->type->str) + 1;
}
fprintf( outfile, "\t%s .L__wine_spec_restype_%u-.L__wine_spec_ne_rsrctab\n",
get_asm_short_keyword(), i );
else
put_word( &buffer, type->type->id | 0x8000 );
fprintf( outfile, "\t%s 0x%04x\n", get_asm_short_keyword(), type->type->id | 0x8000 );
put_word( &buffer, type->nb_names );
put_word( &buffer, 0 );
put_word( &buffer, 0 );
fprintf( outfile, "\t%s %u,0,0\n", get_asm_short_keyword(), type->nb_names );
for (j = 0, res = type->res; j < type->nb_names; j++, res++)
{
put_word( &buffer, res_offset >> alignment );
put_word( &buffer, (res->data_size + align_mask) >> alignment );
put_word( &buffer, res->memopt );
fprintf( outfile, "\t%s .L__wine_spec_resource_%u-%s\n",
get_asm_short_keyword(), res - spec->resources, header_name );
fprintf( outfile, "\t%s .L__wine_spec_resource_%u_end-.L__wine_spec_resource_%u\n",
get_asm_short_keyword(), res - spec->resources, res - spec->resources );
fprintf( outfile, "\t%s 0x%04x\n", get_asm_short_keyword(), res->memopt );
if (res->name.str)
{
put_word( &buffer, offset );
offset += strlen(res->name.str) + 1;
}
fprintf( outfile, "\t%s .L__wine_spec_resname_%u_%u-.L__wine_spec_ne_rsrctab\n",
get_asm_short_keyword(), i, j );
else
put_word( &buffer, res->name.id | 0x8000 );
put_word( &buffer, 0 );
put_word( &buffer, 0 );
res_offset += (res->data_size + align_mask) & ~align_mask;
fprintf( outfile, "\t%s 0x%04x\n", get_asm_short_keyword(), res->name.id | 0x8000 );
fprintf( outfile, "\t%s 0,0\n", get_asm_short_keyword() );
}
}
put_word( &buffer, 0 ); /* terminator */
fprintf( outfile, "\t%s 0\n", get_asm_short_keyword() ); /* terminator */
/* name strings */
for (i = 0, type = tree->types; i < tree->nb_types; i++, type++)
{
if (type->type->str) output_string( &buffer, type->type->str );
if (type->type->str)
{
fprintf( outfile, ".L__wine_spec_restype_%u:\n", i );
output_string( outfile, type->type->str );
}
for (j = 0, res = type->res; j < type->nb_names; j++, res++)
{
if (res->name.str) output_string( &buffer, res->name.str );
if (res->name.str)
{
fprintf( outfile, ".L__wine_spec_resname_%u_%u:\n", i, j );
output_string( outfile, res->name.str );
}
}
}
put_byte( &buffer, 0 ); /* names terminator */
if ((buffer - *ret_buf) & 1) put_byte( &buffer, 0 ); /* align on word boundary */
assert( buffer - *ret_buf == total_size );
fprintf( outfile, "\t.byte 0\n" ); /* names terminator */
free_resource_tree( tree );
return total_size;
}

File diff suppressed because it is too large Load Diff