+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,
*/
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).
*/
* ASCII character
*/
+extern char sdccopt[NINPUT];
+extern char sdccopt_module[NINPUT];
+extern char curr_module[NINPUT];
+
/*
* Character Type Definitions
*/
#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 */
/*
*/
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).
*/
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);
putc('\n', ofp);
}
+ /*
+ * Sdcc compile options
+ */
+ if (strlen(optsdcc)) fprintf(ofp, "O %s\n", optsdcc);
+
/*
* Global references and absolutes.
*/
{ 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 */
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
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);
}
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'.*/
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;
case 'M':
if (pass == 0)
+ {
+ strcpy(curr_module, &ip[1]);
module();
+ }
break;
case 'A':
*/
char stb[NSBTL]; /* Subtitle string buffer
*/
+char optsdcc[NINPUT]; /* sdcc compile options
+ */
char symtbl[] = { "Symbol Table" };
char aretbl[] = { "Area Table" };
#ifdef SDK
# define S_FLOAT 27 /* .df */
#endif
+#define S_OPTSDCC 28 /* .optsdcc */
/*
* The tsym structure is a linked list of temporary
*/
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"
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);
putc('\n', ofp);
}
+ /*
+ * Sdcc compile options
+ */
+ if (strlen(optsdcc)) fprintf(ofp, "O %s\n", optsdcc);
+
/*
* Global references and absolutes.
*/
{ 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 */
* ASCII character
*/
+extern char sdccopt[NINPUT];
+extern char sdccopt_module[NINPUT];
+extern char curr_module[NINPUT];
+
/*
* Character Type Definitions
*/
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
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);
}
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;
case 'M':
if (pass == 0)
+ {
+ strcpy(curr_module, &ip[1]);
module();
+ }
break;
case 'A':
/* 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. */