X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCmain.c;h=754b8034802d816d3b6c28bf8514718d976a35dd;hb=24db07e65dc37c465c586f173fcf7d591d5bd7bc;hp=7d9ae8442bcd1128016086df1d42aec6a2e6e179;hpb=2fa210072055dd1d0dccd08192a6a6039d3ef8b9;p=fw%2Fsdcc diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 7d9ae844..754b8034 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -22,6 +22,7 @@ what you give them. Help stamp out software-hoarding! -------------------------------------------------------------------------*/ +#include #include "common.h" #include #include "newalloc.h" @@ -34,8 +35,6 @@ #if NATIVE_WIN32 #include -#else -#include "spawn.h" #endif #if !defined(__BORLANDC__) && !defined(_MSC_VER) @@ -124,6 +123,8 @@ char DefaultExePath[128]; #define OPTION_SHORT_IS_8BITS "--short-is-8bits" #define OPTION_TINI_LIBID "--tini-libid" #define OPTION_NO_XINIT_OPT "--no-xinit-opt" +#define OPTION_XRAM_SIZE "--xram-size" +#define OPTION_CODE_SIZE "--code-size" static const OPTION optionsTable[] = { @@ -166,9 +167,11 @@ optionsTable[] = { { 0, "--dumptree", &options.dump_tree, "dump front-end AST before generating iCode" }, { 0, OPTION_DUMP_ALL, NULL, "Dump the internal structure at all stages" }, { 0, OPTION_XRAM_LOC, NULL, " External Ram start location" }, + { 0, OPTION_XRAM_SIZE, NULL, " External Ram size" }, { 0, OPTION_IRAM_SIZE, NULL, " Internal Ram size" }, { 0, OPTION_XSTACK_LOC, NULL, " External Ram start location" }, { 0, OPTION_CODE_LOC, NULL, " Code Segment Location" }, + { 0, OPTION_CODE_SIZE, NULL, " Code Segment size" }, { 0, OPTION_STACK_LOC, NULL, " Stack pointer initial value" }, { 0, OPTION_DATA_LOC, NULL, " Direct data start location" }, { 0, OPTION_IDATA_LOC, NULL, NULL }, @@ -242,7 +245,7 @@ static const char *_baseValues[] = { NULL }; -static const char *_preCmd = "{cpp} -nostdinc -Wall -lang-c++ -DSDCC=1 {cppextraopts} {fullsrcfilename} {cppoutfilename}"; +static const char *_preCmd = "{cpp} -nostdinc -Wall -std=c99 -DSDCC=1 {cppextraopts} {fullsrcfilename} {cppoutfilename}"; PORT *port; @@ -383,16 +386,18 @@ printVersionInfo () " (" __DATE__ ")" #ifdef __CYGWIN__ " (CYGWIN)\n" +#elif defined __MINGW32__ + " (MINGW32) \n" #else -#ifdef __DJGPP__ +# ifdef __DJGPP__ " (DJGPP) \n" -#else -#if defined(_MSC_VER) +# else +# if defined(_MSC_VER) " (WIN32) \n" -#else +# else " (UNIX) \n" -#endif -#endif +# endif +# endif #endif ,VersionString @@ -903,6 +908,19 @@ parseCmdLine (int argc, char **argv) continue; } + if (strcmp (argv[i], OPTION_XRAM_SIZE) == 0) + { + options.xram_size = getIntArg(OPTION_IRAM_SIZE, argv, &i, argc); + options.xram_size_set = TRUE; + continue; + } + + if (strcmp (argv[i], OPTION_CODE_SIZE) == 0) + { + options.code_size = getIntArg(OPTION_IRAM_SIZE, argv, &i, argc); + continue; + } + if (strcmp (argv[i], OPTION_DATA_LOC) == 0) { options.data_loc = getIntArg(OPTION_DATA_LOC, argv, &i, argc); @@ -1211,6 +1229,14 @@ linkEdit (char **envp) if (options.iram_size) fprintf (lnkfile, "-a 0x%04x\n", options.iram_size); + /* if xram size specified */ + if (options.xram_size_set) + fprintf (lnkfile, "-v 0x%04x\n", options.xram_size); + + /* if code size specified */ + if (options.code_size) + fprintf (lnkfile, "-w 0x%04x\n", options.code_size); + if (options.debug) fprintf (lnkfile, "-z\n"); @@ -1240,8 +1266,8 @@ linkEdit (char **envp) WRITE_SEG_LOC (BIT_NAME, 0); /* JCF: stack start */ - if(options.stack_loc) { - WRITE_SEG_LOC ("SSEG", options.stack_loc & 0xff); + if ( (options.stack_loc) && (options.stack_loc<0x100) ) { + WRITE_SEG_LOC ("SSEG", options.stack_loc); } /* add the extra linker options */ @@ -1710,6 +1736,33 @@ initValues (void) } +static void +sig_handler (int signal) +{ + char *sig_string; + + switch (signal) + { + case SIGABRT: + sig_string = "SIGABRT"; + break; + case SIGTERM: + sig_string = "SIGTERM"; + break; + case SIGINT: + sig_string = "SIGINT"; + break; + case SIGSEGV: + sig_string = "SIGSEGV"; + break; + default: + sig_string = "Unknown?"; + break; + } + fprintf (stderr, "Catched signal %d: %s\n", signal, sig_string); + exit (1); +} + /* * main routine * initialises and calls the parser @@ -1731,7 +1784,14 @@ main (int argc, char **argv, char **envp) /* install atexit handler */ atexit(rm_tmpfiles); - /* Before parsing the command line options, do a + /* install signal handler; + it's only purpuse is to call exit() to remove temp files */ + signal (SIGABRT, sig_handler); + signal (SIGTERM, sig_handler); + signal (SIGINT , sig_handler); + signal (SIGSEGV, sig_handler); + + /* Before parsing the command line options, do a * search for the port and processor and initialize * them if they're found. (We can't gurantee that these * will be the first options specified).