From a72202a5621e536311623dae3c675a954114c5c1 Mon Sep 17 00:00:00 2001 From: jesusc Date: Sun, 13 Jul 2003 08:45:03 +0000 Subject: [PATCH] Ooops! For the z80 port, crt0.o must be the first file when linking. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2731 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCmain.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 47727422..84310c15 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -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); -- 2.39.5