Ooops! For the z80 port, crt0.o must be the first file when linking.
authorjesusc <jesusc@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 13 Jul 2003 08:45:03 +0000 (08:45 +0000)
committerjesusc <jesusc@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 13 Jul 2003 08:45:03 +0000 (08:45 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2731 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCmain.c

index 47727422921b15120e4aa49d4d9f55ee2f283140..84310c15d46b8aa9ae540869779e2fbee58a219c 100644 (file)
@@ -1478,13 +1478,9 @@ linkEdit (char **envp)
   for (s = setFirstItem(libFilesSet); s != NULL; s = setNextItem(libFilesSet))
     fprintf (lnkfile, "-l %s\n", s);
 
-  /* put in the object files */
-  if (fullSrcFileName)
-    fprintf (lnkfile, "%s%s\n", dstFileName, port->linker.rel_ext);
-
-  fputStrSet(lnkfile, relFilesSet);
-
-  /*For the z80 and gbz80 ports, try to find where crt0.o is...*/
+  /*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) /*For the z80, gbz80*/
   {
       char crt0path[PATH_MAX];
@@ -1515,6 +1511,12 @@ linkEdit (char **envp)
       if(s==NULL) fprintf (stderr, "Warning: couldn't find crt0.o\n");
   }
 
+  /* put in the object files */
+  if (fullSrcFileName)
+    fprintf (lnkfile, "%s%s\n", dstFileName, port->linker.rel_ext);
+
+  fputStrSet(lnkfile, relFilesSet);
+
   fprintf (lnkfile, "\n-e\n");
   fclose (lnkfile);