From: pavenis AT lanet DOT lv To: djgpp-workers AT delorie DOT com Date: Fri, 15 Jun 2001 15:08:50 +0300 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: [PATCH] Update to stubedit and stubify Message-ID: <3B2A2502.972.C46699@localhost> X-mailer: Pegasus Mail for Win32 (v3.12c) Reply-To: djgpp-workers AT delorie DOT com Here is update for stubedit and stubify. Initial reason for that was wish to be able to specify stack size in gcc command line with option -stack=... . If such option is available we could add it to LDFLAGS when some package would require larger stack size for executables It can be easily done when output file extension .exe is explicitly specified but I didn't find easy way how to do that for gcc foo.c -stack=1024K -o foo To make it more easy I added command line option -x for stubedit which forces it to always use extension .exe. At the same time I saw that both stubify unconditionally uses directory separators "/\\:" which is true for DJGPP but not for cross-tools. Also changed to use malloced buffer for filename instead of local array. After modifying link command spec for gcc-3.0 prerelease (added last line) command line option -stack= works Ok. There should be no problems to do the same also for gcc-2.95.X Andris *link_command: %{!fsyntax-only: %{!c:%{!M:%{!MM:%{!E:%{!S:%(linker) %l %X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r} %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}} %{static:} %{L*} %D %o %{!nostdlib:%{!nodefaultlibs:%G %L %G}} %{!A:%{!nostdlib:%{!nostartfiles:%E}}} -Tdjgpp.djl %{T*}}}}}}} %{!c:%{!M:%{!MM:%{!E:%{!S:stubify %{v} %{o*:%*} %{!o*:a.out} }}}}} %{!c:%{!M:%{!MM:%{!E:%{!S:%{stack=*:stubedit -x %{o*:%*} %{!o*:a.out} minstack=%* }}}}}} *** djgpp/src/stub/stubedit.c~3 Sun Jun 10 02:00:44 2001 --- djgpp/src/stub/stubedit.c Fri Jun 15 15:02:02 2001 *************** *** 6,16 **** --- 6,24 ---- #include #include #include + #include #ifdef __DJGPP__ #include #endif + #undef DIR_SEPARATOR + #if defined(__DJGPP__) || defined(_WIN32) + #define DIR_SEPARATOR "/\\:" + #else + #define DIR_SEPARATOR "/" + #endif + #include "../../include/stubinfo.h" unsigned long size_of_stubinfo = 0; *************** *** 214,221 **** void give_help(void) { size_t i; ! fprintf(stderr, "Usage: stubedit [-v] [-h] filename.exe [field=value . . . ]\n"); fprintf(stderr, "-h = give help -v = view info field=value means set w/o prompt\n"); fprintf(stderr, HFORMAT, "-field-", "-description-"); for (i=0; i < NUM_FIELDS; i++) --- 222,230 ---- void give_help(void) { size_t i; ! fprintf(stderr, "Usage: stubedit [-v] [-h] [-x] filename.exe [field=value . . . ]\n"); fprintf(stderr, "-h = give help -v = view info field=value means set w/o prompt\n"); + fprintf(stderr, "-x = always use extension .exe\n"); fprintf(stderr, HFORMAT, "-field-", "-description-"); for (i=0; i < NUM_FIELDS; i++) *************** *** 226,233 **** --- 235,244 ---- int main(int argc, char **argv) { int view_only = 0; + int auto_complete = 0; size_t i; int need_to_save; + char * arg1; if (argc > 1 && strcmp(argv[1], "-h") == 0) give_help(); *************** *** 239,248 **** argv++; } if (argc < 2) give_help(); ! find_info(argv[1]); if (view_only) { --- 250,289 ---- argv++; } + if (argc > 1 && strcmp(argv[1], "-x") == 0) + { + auto_complete = 1; + argc--; + argv++; + } + if (argc < 2) give_help(); ! arg1 = argv[1]; ! if (auto_complete) ! { ! int len=strlen(arg1); ! if (len>3 && strcasecmp(arg1+len-4,".exe")!=0) ! { ! char *ofname, *ofext=0; ! char * ofilename = (char *) malloc (5+len); ! strcpy(ofilename, arg1); ! for (ofname=ofilename; *ofname; ofname++) ! { ! if (strchr(DIR_SEPARATOR, *ofname)) ! ofext = 0; ! if (*ofname == '.') ! ofext = ofname; ! } ! if (ofext == 0) ! ofext = ofilename + strlen(ofilename); ! strcpy(ofext, ".exe"); ! arg1=ofilename; ! } ! } ! ! find_info(arg1); if (view_only) { *************** *** 291,297 **** } } if (got_any) ! store_info(argv[1]); return 0; } --- 332,338 ---- } } if (got_any) ! store_info(arg1); return 0; } *************** *** 310,316 **** } } if (need_to_save) ! store_info(argv[1]); return 0; } --- 351,357 ---- } } if (need_to_save) ! store_info(arg1); return 0; } *** djgpp/src/stub/stubify.c~3 Tue Dec 14 14:01:36 1999 --- djgpp/src/stub/stubify.c Fri Jun 15 15:01:44 2001 *************** *** 21,26 **** --- 21,33 ---- #define O_BINARY 0 #endif + #undef DIR_SEPARATOR + #if defined(__DJGPP__) || defined(_WIN32) + #define DIR_SEPARATOR "/\\:" + #else + #define DIR_SEPARATOR "/" + #endif + const unsigned char stub_bytes[] = { #include "stub.h" }; *************** *** 257,269 **** } if (argc > 2 && strcmp(argv[1], "-g") == 0) { ! char ofilename[256], *ofname, *ofext=0; int ofile; ! strcpy(ofilename, argv[2]); for (ofname=ofilename; *ofname; ofname++) { ! if (strchr("/\\:", *ofname)) ofext = 0; if (*ofname == '.') ofext = ofname; --- 264,277 ---- } if (argc > 2 && strcmp(argv[1], "-g") == 0) { ! char *ofname, *ofext=0; int ofile; ! char *ofilename = (char *) malloc (5+strlen(argv[2])); ! if (!ofilename) abort(); strcpy(ofilename, argv[2]); for (ofname=ofilename; *ofname; ofname++) { ! if (strchr(DIR_SEPARATOR, *ofname)) ofext = 0; if (*ofname == '.') ofext = ofname;