+ /* bit segment start */
+ WRITE_SEG_LOC (BIT_NAME, 0);
+
+ /* stack start */
+ if ( (options.stack_loc) && (options.stack_loc<0x100) )
+ {
+ WRITE_SEG_LOC ("SSEG", options.stack_loc);
+ }
+ }
+ else /*For the z80, gbz80*/
+ {
+ WRITE_SEG_LOC ("_CODE", options.code_loc);
+ WRITE_SEG_LOC ("_DATA", options.data_loc);
+ }
+
+ /* If the port has any special linker area declarations, get 'em */
+ if (port->extraAreas.genExtraAreaLinkOptions)
+ {
+ port->extraAreas.genExtraAreaLinkOptions(lnkfile);
+ }
+
+ /* add the extra linker options */
+ fputStrSet(lnkfile, linkOptionsSet);
+
+ /* command line defined library paths if specified */
+ for (s = setFirstItem(libPathsSet); s != NULL; s = setNextItem(libPathsSet))
+ fprintf (lnkfile, "-k %s\n", s);
+
+ /* standard library path */
+ if (!options.nostdlib)
+ {
+ if (!(TARGET_IS_Z80 || TARGET_IS_GBZ80 || TARGET_IS_HC08)) /*Not for the z80, gbz80*/
+ {
+ switch (options.model)
+ {
+ case MODEL_SMALL:
+ c = "small";
+ break;
+ case MODEL_LARGE:
+ c = "large";
+ break;
+ case MODEL_FLAT24:
+ /* c = "flat24"; */
+ if (TARGET_IS_DS390)
+ {
+ c = "ds390";
+ }
+ else if (TARGET_IS_DS400)
+ {
+ c = "ds400";
+ }
+ else
+ {
+ fprintf(stderr,
+ "Add support for your FLAT24 target in %s @ line %d\n",
+ __FILE__, __LINE__);
+ exit(-1);
+ }
+ break;
+ case MODEL_PAGE0:
+ c = "xa51";
+ break;
+ default:
+ werror (W_UNKNOWN_MODEL, __FILE__, __LINE__);
+ c = "unknown";
+ break;
+ }
+ }
+ else /*for the z80, gbz80*/
+ {
+ if (TARGET_IS_HC08)
+ c = "hc08";
+ else if (TARGET_IS_Z80)
+ c = "z80";
+ else
+ c = "gbz80";
+ }
+ for (s = setFirstItem(libDirsSet); s != NULL; s = setNextItem(libDirsSet))
+ mfprintf (lnkfile, getRuntimeVariables(), "-k %s{sep}%s\n", s, c);
+ }
+
+ /* command line defined library files if specified */
+ for (s = setFirstItem(libFilesSet); s != NULL; s = setNextItem(libFilesSet))
+ fprintf (lnkfile, "-l %s\n", s);
+
+ /* standard library files */
+ if (!options.nostdlib)
+ {
+#if !OPT_DISABLE_DS390
+ if (options.model == MODEL_FLAT24)
+ {
+ if (TARGET_IS_DS390)
+ {
+ fprintf (lnkfile, "-l %s\n", STD_DS390_LIB);
+ }
+ else if (TARGET_IS_DS400)
+ {
+ fprintf (lnkfile, "-l %s\n", STD_DS400_LIB);
+ }
+ else
+ {
+ fprintf(stderr,
+ "Add support for your FLAT24 target in %s @ line %d\n",
+ __FILE__, __LINE__);
+ exit(-1);
+ }
+ }
+#endif
+
+#if !OPT_DISABLE_XA51
+#ifdef STD_XA51_LIB
+ if (options.model == MODEL_PAGE0)
+ {
+ fprintf (lnkfile, "-l %s\n", STD_XA51_LIB);
+ }
+#endif
+#endif
+ if (TARGET_IS_MCS51)
+ {
+ fprintf (lnkfile, "-l mcs51\n");
+ }
+ if (!(TARGET_IS_Z80 || TARGET_IS_GBZ80
+ || TARGET_IS_HC08)) /*Not for the z80, gbz80*/
+ { /*Why the z80 port is not using the standard libraries?*/
+ fprintf (lnkfile, "-l %s\n", STD_LIB);
+ fprintf (lnkfile, "-l %s\n", STD_INT_LIB);
+ fprintf (lnkfile, "-l %s\n", STD_LONG_LIB);
+ fprintf (lnkfile, "-l %s\n", STD_FP_LIB);
+ }
+ else if (TARGET_IS_HC08)
+ {
+ fprintf (lnkfile, "-l hc08\n");
+ }
+ else if (TARGET_IS_Z80)
+ {
+ fprintf (lnkfile, "-l z80\n");
+ }
+ else if (TARGET_IS_GBZ80)
+ {
+ fprintf (lnkfile, "-l gbz80\n");
+ }
+ }
+
+ /*For the z80 and gbz80 ports, try to find where crt0.o is...
+ It is very important for this file to be first on the linking proccess
+ so the areas are set in the correct order, expecially _GSINIT*/
+ if ((TARGET_IS_Z80 || TARGET_IS_GBZ80) &&
+ !options.no_std_crt0 && !options.nostdlib) /*For the z80, gbz80*/
+ {
+ char crt0path[PATH_MAX];
+ FILE * crt0fp;
+ for (s = setFirstItem(libDirsSet); s != NULL; s = setNextItem(libDirsSet))
+ {
+ sprintf (crt0path, "%s%s%s%scrt0.o",
+ s, DIR_SEPARATOR_STRING, c, DIR_SEPARATOR_STRING);