Hi all
Working on my project, I have found that to break 32-K limit of code I
should use Glib library. But gcc-tools for win32 does not contain all
required programs (perl, grep). These programs can be found on any unix
system, but not on win32 system. There are win32-ports of these tools,
and its can be used for building of glib-libraries. But I have found
that it is easier to write some small programs that will do all required
job.
1. stubgen
Generates c-stub source, eliminates the need of perl for win32.
Command-line arguments the same as for m68k-palmos-coff-stubgen. Just
compile stubgen.c and copy stubgen.exe into your palmdev/bin directory
(m68k-palmos-coff-stubgen script is there) and modify your _makefile_ to
use stubgen.exe instead script (set STUBGEN=stubgen instead
STUBGEN=m68k-palmos-coff-stubgen)
2. nsexportlist
Generates not-sorted export list, eliminates the need of grep and cut
utilities, sort is required still.
Compily and copy nsexportlist.exe into palmdev/bin directory. Modify
m68k-palmos-coff-exportlist script as following
---cut---
#!/bin/sh
m68k-palmos-coff-nm $1 | nsexportlist | sort
---cut---
NOTE! These programs were tested only on my project.
If you are interested to get executables for win32, please send me your
e-mail.
Regards,
Alexander
---cut---
// stubgen.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main( int argc, char* argv[] )
{
char *libname, *creator, *stubfile, *libfile;
FILE *fpStubfile, *fpLibfile;
int id;
char str[ 128 ];
if( argc != 5 )
{
fprintf( stdout, "Usage: stubgen library_name creator_id
stubfile.c libfile.S\n"
"\tExample: stubgen \"Foo Library\" FooL
foostub.c FooLib.S\n"
"\tNote that stubfile.c and libfile.S are
_written_ by this program.\n" );
return 1;
}
libname = argv[ 1 ];
creator = argv[ 2 ];
stubfile = argv[ 3 ];
libfile = argv[ 4 ];
fpStubfile = fopen( stubfile, "wb+" );
if( fpStubfile == NULL )
{
fprintf( stdout, "Cannot write to stubfile \'%s\'!\n", stubfile
);
return 1;
}
fpLibfile = fopen( libfile, "wb+" );
if( fpLibfile == NULL )
{
fprintf( stdout, "Cannot write to libfile \'%s\'!\n", libfile );
return 1;
}
fprintf( fpStubfile,
"#include <Pilot.h>\n"
"\n"
"static struct LibRef *libref = 0;\n"
"\n"
"extern void GLibClose(struct LibRef *);\n"
"\n"
"void GLib_%s(void)\n"
"{\n"
" asm (\"\n",
creator );
fprintf( fpLibfile,
".text\n"
".even\n"
".globl jmptable\n"
"jmptable:\n"
" dc.w 0\n" );
id = 0;
while( gets( str ) != NULL )
{
id++;
fprintf( fpStubfile,
".global %s\n"
"%s: move.l #%d,%%%%d0; braw dispatch\n",
str, str, id );
fprintf( fpLibfile,
" dc.w %s-jmptable\n",
str );
}
fclose( fpLibfile );
fprintf( fpStubfile,
"\n"
"libname:\n"
" .asciz \\\"%s\\\"\n"
" .even\n"
"\n"
"dispatch:\n"
" lea libname(%%%%pc),%%%%a1\n"
" move.l %%%%a1,%%%%d2\n"
" move.l %%%%a4,%%%%d1\n"
" move.l %%%%d1,%%%%d1\n"
" jbeq noglobals\n"
" lea libref(%%%%a4),%%%%a1\n"
"noglobals:\n"
" move.l %%0,%%%%d1\n"
" braw GLibDispatch\n"
" \" : : \"i\" (\'%s\') );\n"
"}\n"
"\n"
"register void *reg_a4 asm(\"%%a4\");\n"
"\n"
"void GLib_%s_clean(Word cmd, Ptr PBP, Word flags)\n"
"{\n"
" if (reg_a4 && libref) {\n"
" GLibClose(libref);\n"
" libref = 0;\n"
" }\n"
"}\n"
"\n"
"asm(\"\n"
".section ehook\n"
".long GLib_%s_clean\n"
"\");\n",
libname, creator, creator, creator );
fclose( fpStubfile );
return 0;
}
---cut---
---cut---
// nsexportlist.c
// Generates not-sorted export list
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main( int argc, char* argv[] )
{
char str[ 128 ];
while( gets( str ) != NULL )
{
if( strstr( str, " T " ) != NULL )
puts( &str[ 11 ] );
}
return 0;
}
---cut---