Linker complaints if linked modules have conflicting options.
authorjesusc <jesusc@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 30 Jul 2003 05:32:48 +0000 (05:32 +0000)
committerjesusc <jesusc@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 30 Jul 2003 05:32:48 +0000 (05:32 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2784 4a8a32a2-be11-0410-ad9d-d568d2c75423

20 files changed:
ChangeLog
as/mcs51/asdata.c
as/mcs51/aslink.h
as/mcs51/asm.h
as/mcs51/asmain.c
as/mcs51/asout.c
as/mcs51/i51pst.c
as/mcs51/lkdata.c
as/mcs51/lklibr.c
as/mcs51/lkmain.c
as/z80/asdata.c
as/z80/asm.h
as/z80/asmain.c
as/z80/asout.c
as/z80/z80pst.c
link/z80/aslink.h
link/z80/lkdata.c
link/z80/lklibr.c
link/z80/lkmain.c
src/SDCCglue.c

index d854ebd692c1c939adbd9e90e90645f33b05d282..dbcda524a7287c028d5ae99f82d37f111d46c70c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2003-07-29  Jesus Calvino-Fraga <jesusc@ece.ubc.ca>
+
+    Linker now complaints if linked modules have conflicting options, for
+    example, one compiled using --model-large and another one compiled with
+    --model-small.  The following files were modified:
+
+    * as\mcs51\asdata.c
+    * as\mcs51\aslink.h
+    * as\mcs51\asm.h
+    * as\mcs51\asmain.c
+    * as\mcs51\asout.c
+    * as\mcs51\i51pst.c
+    * as\mcs51\lkdata.c
+    * as\mcs51\lklibr.c
+    * as\mcs51\lkmain.c
+    * as\z80\asdata.c
+    * as\z80\asm.h
+    * as\z80\asmain.c
+    * as\z80\asout.c
+    * as\z80\z80pst.c
+    * link\z80\aslink.h
+    * link\z80\lkdata.c
+    * link\z80\lklibr.c
+    * link\z80\lkmain.c
+    * src\SDCCglue.c 
+
 2003-07-28  Jesus Calvino-Fraga <jesusc@ece.ubc.ca>
 
     *link/z80/aslink.h, link/z80/lklibr.c, as/mcs51/aslink.h,
index 07c065ce0f765c89c5b4deed983cb7bd4352a9fa..c6ed0b44806f4e82ea85656a8a37fc5da074bc76 100644 (file)
@@ -129,6 +129,8 @@ char        tb[NTITL];      /*      Title string buffer
                         */
 char   stb[NSBTL];     /*      Subtitle string buffer
                         */
+char   optsdcc[NINPUT];        /*      sdcc compile options 
+                        */
 int    flat24Mode;     /*      non-zero if we are using DS390 24 bit 
                         *      flat mode (via .flat24 directive). 
                         */
index fa4f1d1f5558ab01979ef8626394dedb4d99d801..263467a07e5d0c3df7609e366ae13a53c4bf05e9 100644 (file)
@@ -459,6 +459,10 @@ extern     unsigned char   ctype[];        /*      array of character types, one per
                                 *      ASCII character
                                 */
 
+extern char sdccopt[NINPUT];
+extern char sdccopt_module[NINPUT];
+extern char curr_module[NINPUT];
+
 /*
  *     Character Type Definitions
  */
index 0036a063e5b96d690d0b6d0d2612afeca0a8698b..aa33d254b92c19d83b4ca197baade75aa3a861a3 100644 (file)
@@ -327,7 +327,8 @@ struct      sym
 #define        S_ORG           24      /* .org */
 #define        S_MODUL         25      /* .module */
 #define        S_ASCIS         26      /* .ascis */
-#define        S_FLAT24        27      /* .flat24 */
+#define        S_FLAT24        27  /* .flat24 */
+#define        S_OPTSDCC       28  /* .optsdcc */
 
 
 /*
@@ -478,6 +479,8 @@ extern      char    tb[NTITL];      /*      Title string buffer
                                 */
 extern char    stb[NSBTL];     /*      Subtitle string buffer
                                 */
+extern  char   optsdcc[NINPUT];        /*      sdcc compile options 
+                        */
 extern         int     flat24Mode;     /*      non-zero if we are using DS390 24 bit 
                                 *      flat mode (via .flat24 directive). 
                                 */
index eed56eac6c3eca6017d27d696ebb57cee40101b9..05689f925c73e53f4b89050e4283c3f5a8e05e65 100644 (file)
@@ -811,6 +811,20 @@ loop:
                lmode = SLIST;
                break;
 
+    case S_OPTSDCC:
+               p = optsdcc;
+               if ((c = getnb()) != 0) {
+                       do {
+                               if (p < &tb[NINPUT-1])
+                                       *p++ = c;
+                       } while ((c = get()) != 0);
+               }
+               *p = 0;
+               unget(c);
+               lmode = SLIST;
+        /*if (pass == 0) printf("optsdcc=%s\n", optsdcc);*/
+        break;
+
        case S_GLOBL:
                do {
                        getid(id, -1);
index 8c8362f68bf4c680eec212bbe032e9cdfe13c824..363a2c1214c0b65b65c1eb54da8dcc45e859fab0 100644 (file)
@@ -925,6 +925,11 @@ outgsd()
                putc('\n', ofp);
        }
 
+    /*
+     * Sdcc compile options
+     */
+       if (strlen(optsdcc)) fprintf(ofp, "O %s\n", optsdcc);
+
        /*
         * Global references and absolutes.
         */
index 1e10d9547e78a0eca43c8a31c92aa22d8bcf0142..16c40834ceff5ec856ad25907215e01a11d9f42a 100644 (file)
@@ -59,7 +59,8 @@ struct        mne     mne[] = {
        { NULL, ".org",         S_ORG,          0,      0},
        { NULL, ".module",      S_MODUL,        0,      0},
        { NULL, ".ascis",       S_ASCIS,        0,      0},
-        { NULL, ".flat24",     S_FLAT24,       0,      0},
+    { NULL, ".flat24", S_FLAT24,       0,      0},
+    { NULL, ".optsdcc",        S_OPTSDCC,      0,      0},
 
        /* 8051 */
 
index 1d100f8a329b1b306774f274b3fdcf6c56a21f1b..d6a3517539160973f779e6521f2244f90549519a 100644 (file)
@@ -42,6 +42,11 @@ char *rp;            /*      pointer into the LST file
 char   rb[NINPUT];     /*      LST file text line being
                         *      address relocated
                         */
+
+char sdccopt[NINPUT]="";
+char sdccopt_module[NINPUT]="";
+char curr_module[NINPUT]="";
+
 int     dflag;          /*      Debug information output flag
                         */
 int    oflag;          /*      Output file type flag
index d7d9cb249049701b180007462fd179ccc4d31712..8ca450486b0fa8d4d2bc36f259e2e10fd4ac72e7 100644 (file)
@@ -128,16 +128,16 @@ addlib()
 
        if (lbphead == NULL)
     {
-               foundcount+=addfile(NULL,ip);
+               foundcount=addfile(NULL, ip);
        }
     else
     {
            for (lbph=lbphead; lbph; lbph=lbph->next)
         {
-                   foundcount+=addfile(lbph->path,ip);
+                   foundcount+=addfile(lbph->path, ip);
            }
     }
-    if(foundcount==0)
+    if(foundcount == 0)
     {
         printf("?ASlink-Warning-Couldn't find library '%s'\n", ip);
     }
@@ -238,7 +238,7 @@ int addfile(char * path, char * libfil)
 
     if(path==NULL)
     {
-        /*'path' can not be null since it is needed to find the '.o' files associated with
+        /*'path' can not be null since it is needed to find the '.rel' files associated with
         the library.  So, get 'path' from 'str' and then chop it off and recreate 'libfil'.
         That way putting 'path' and 'libfil' together will result into the original filepath
         as contained in 'str'.*/
index 842bcb33f8427e0e7a288c9dd0922cb1800e6e44..548a44fdf53ba6e222c337bba8c1681192fff450 100644 (file)
@@ -465,6 +465,29 @@ link_main()
        if ((c=endline()) == 0) { return; }
        switch (c) {
 
+    case 'O': /*For some important sdcc options*/
+        if (pass == 0)
+        {
+            if(strlen(sdccopt)==0)
+            {
+                strcpy(sdccopt, &ip[1]);
+                strcpy(sdccopt_module, curr_module);
+            }
+            else
+            {
+                if(strcmp(sdccopt, &ip[1])!=0)
+                {
+                                   fprintf(stderr,
+                                   "?ASlink-Warning-Conflicting sdcc options:\n"
+                    "   \"%s\" in module \"%s\" and\n"
+                    "   \"%s\" in module \"%s\".\n",
+                    sdccopt, sdccopt_module, &ip[1], curr_module);
+                                   lkerr++;
+                }
+            }
+        }
+               break;
+
        case 'X':
                radix = 16;
                break;
@@ -494,7 +517,10 @@ link_main()
 
        case 'M':
                if (pass == 0)
+        {
+            strcpy(curr_module, &ip[1]);
                        module();
+        }
                break;
 
        case 'A':
index 189be0b275624d483fe278cb0b9ff070a94bde48..26b621e25fa45f4a71a510c8113b951433bf0cfd 100644 (file)
@@ -121,6 +121,8 @@ char        tb[NTITL];      /*      Title string buffer
                         */
 char   stb[NSBTL];     /*      Subtitle string buffer
                         */
+char   optsdcc[NINPUT];        /*      sdcc compile options 
+                        */
 
 char   symtbl[] = { "Symbol Table" };
 char   aretbl[] = { "Area Table" };
index 57e68e783737d2b3f5829bbb17d724ba82cc8ba1..48e0500fb98e59b24de9e8c92a8adbda7d0e69bc 100644 (file)
@@ -272,6 +272,7 @@ struct      sym
 #ifdef SDK
 # define S_FLOAT        27      /* .df */
 #endif
+#define        S_OPTSDCC       28  /* .optsdcc */
 
 /*
  *     The tsym structure is a linked list of temporary
@@ -413,6 +414,8 @@ extern      char    tb[NTITL];      /*      Title string buffer
                                 */
 extern char    stb[NSBTL];     /*      Subtitle string buffer
                                 */
+extern  char   optsdcc[NINPUT];    /*  sdcc compile options 
+                            */
 extern char    symtbl[];       /*      string "Symbol Table"
                                 */
 extern char    aretbl[];       /*      string "Area Table"
index 976248a392e4c0c61a82f80927dc3587d28d72e3..f916e9efd622af92b0d18a99260f9e3a47702e00 100644 (file)
@@ -850,6 +850,19 @@ loop:
                lmode = SLIST;
                break;
 
+    case S_OPTSDCC:
+               p = optsdcc;
+               if ((c = getnb()) != 0) {
+                       do {
+                               if (p < &tb[NINPUT-1])
+                                       *p++ = c;
+                       } while ((c = get()) != 0);
+               }
+               *p = 0;
+               unget(c);
+               lmode = SLIST;
+        break;
+
        case S_GLOBL:
                do {
                        getid(id, -1);
index 5396de3ec7278d23b0d763d01599413f8e847bf9..c4b3434f917d434a049fa2a5105c2421a270b3c6 100644 (file)
@@ -720,6 +720,11 @@ outgsd()
                putc('\n', ofp);
        }
 
+    /*
+     * Sdcc compile options
+     */
+       if (strlen(optsdcc)) fprintf(ofp, "O %s\n", optsdcc);
+
        /*
         * Global references and absolutes.
         */
index 7e6dc80782c2ecfd9df8399b16b63246843ae4d2..74044865dbe4bcefb01f0f741cad5eebde8eec0d 100644 (file)
@@ -56,6 +56,7 @@ struct        mne     mne[] = {
     { NULL,    ".org",         S_ORG,          0,      0 },
     { NULL,    ".module",      S_MODUL,        0,      0 },
     { NULL,    ".ascis",       S_ASCIS,        0,      0 },
+    { NULL, ".optsdcc",        S_OPTSDCC,      0,      0},
 
        /* z80 / hd64180 */
 
index 0e3cd39c75b059ece026cec8e29c376262abce50..8a2685466bafdcc13f42779f9a3d901cc430dba5 100644 (file)
@@ -452,6 +452,10 @@ extern     char    ctype[];        /*      array of character types, one per
                                 *      ASCII character
                                 */
 
+extern char sdccopt[NINPUT];
+extern char sdccopt_module[NINPUT];
+extern char curr_module[NINPUT];
+
 /*
  *     Character Type Definitions
  */
index b95654177d514bb2d99ebb076497c0ce178d81ef..0442ef7560ad38f86e95bd3b15a04e26a861bcc7 100644 (file)
@@ -38,6 +38,11 @@ char *rp;            /*      pointer into the LST file
 char   rb[NINPUT];     /*      LST file text line being
                         *      address relocated
                         */
+
+char sdccopt[NINPUT]="";
+char sdccopt_module[NINPUT]="";
+char curr_module[NINPUT]="";
+
 int    oflag;          /*      Output file type flag
                         */
 int    mflag;          /*      Map output flag
index eb4cd98da98e8cfee0cee2d915a385b89d520dd2..832af6f56fcf901be7e665dcba0b438190175811 100644 (file)
@@ -177,16 +177,16 @@ addlib()
 
        if (lbphead == NULL)
     {
-               foundcount+=addfile(NULL, ip);
+               foundcount=addfile(NULL, ip);
        }
     else
     {
            for (lbph=lbphead; lbph; lbph=lbph->next)
         {
-                   foundcount+=addfile(lbph->path,ip);
+                   foundcount+=addfile(lbph->path, ip);
            }
     }
-    if(foundcount==0)
+    if(foundcount == 0)
     {
         printf("\n?ASlink-Warning-Couldn't find library '%s'", ip);
     }
index cf1b4745e765d5b121dd20905d6ea75920d489ec..c6cc8b29fcded57a27a26c7237271560c386cdad 100644 (file)
@@ -488,6 +488,29 @@ link()
        if ((c=endline()) == 0) { return; }
        switch (c) {
 
+    case 'O': /*For some important sdcc options*/
+        if (pass == 0)
+        {
+            if(strlen(sdccopt)==0)
+            {
+                strcpy(sdccopt, &ip[1]);
+                strcpy(sdccopt_module, curr_module);
+            }
+            else
+            {
+                if(strcmp(sdccopt, &ip[1])!=0)
+                {
+                                   fprintf(stderr,
+                                   "?ASlink-Warning-Conflicting sdcc options:\n"
+                    "   \"%s\" in module \"%s\" and\n"
+                    "   \"%s\" in module \"%s\".\n",
+                    sdccopt, sdccopt_module, &ip[1], curr_module);
+                                   lkerr++;
+                }
+            }
+        }
+               break;
+
        case 'X':
                radix = 16;
                break;
@@ -517,7 +540,10 @@ link()
 
        case 'M':
                if (pass == 0)
+        {
+            strcpy(curr_module, &ip[1]);
                        module();
+        }
                break;
 
        case 'A':
index bb9425b3ca2cb6de95073d5fa25de428eae41333..69d4b453e676080e279a292ddd686281be35e301 100644 (file)
@@ -1572,6 +1572,33 @@ glue (void)
   /* print module name */
   tfprintf (asmFile, "\t!module\n",
     spacesToUnderscores (moduleBuf, moduleName, sizeof moduleBuf));
+  if(mcs51_like)
+  {
+    fprintf (asmFile, "\t.optsdcc -m%s", port->target);
+
+    switch(options.model)
+    {
+        case MODEL_SMALL:   fprintf (asmFile, " --model-small");   break;
+        case MODEL_COMPACT: fprintf (asmFile, " --model-compact"); break;
+        case MODEL_MEDIUM:  fprintf (asmFile, " --model-medium");  break;
+        case MODEL_LARGE:   fprintf (asmFile, " --model-large");   break;
+        case MODEL_FLAT24:  fprintf (asmFile, " --model-flat24");  break;
+        case MODEL_PAGE0:   fprintf (asmFile, " --model-page0");   break;
+        default: break;
+    }
+    if(options.stackAuto)      fprintf (asmFile, " --stack-auto");
+    if(options.useXstack)      fprintf (asmFile, " --xstack");
+    if(options.intlong_rent)   fprintf (asmFile, " --int-long-rent");
+    if(options.float_rent)     fprintf (asmFile, " --float-rent");
+    if(options.noRegParams)    fprintf (asmFile, " --no-reg-params");
+    if(options.parms_in_bank1) fprintf (asmFile, " --parms-in-bank1");
+    fprintf (asmFile, "\n");
+  }
+  else if(TARGET_IS_Z80 || TARGET_IS_GBZ80 )
+  {
+    fprintf (asmFile, "\t.optsdcc -m%s\n", port->target);
+  }
+
   tfprintf (asmFile, "\t!fileprelude\n");
 
   /* Let the port generate any global directives, etc. */