gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit bd8486078e1a8bf01ff8649ecbc889cf450e3625 parent 5ce20c7740a76cf378c080ecd919eb464d6a6a22 Author: Toxa <untoxa@mail.ru> Date: Mon, 24 May 2021 00:24:47 +0300 support for linker *.lk files Diffstat:
| M | gbdk-support/lcc/gb.c | 8 | +++++--- |
| M | gbdk-support/lcc/lcc.c | 38 | +++++++++++++++++++++++++++----------- |
2 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/gbdk-support/lcc/gb.c b/gbdk-support/lcc/gb.c @@ -111,7 +111,7 @@ static CLASS classes[] = { "%as% %asdefault% $1 $3 $2", "%bankpack% $1 $2", "%ld% -n -i $1 -k %libdir%%port%/ -l %port%.lib " - "-k %libdir%%plat%/ -l %plat%.lib $3 %libdir%%plat%/crt0.o $2", + "-k %libdir%%plat%/ -l %plat%.lib $3 $2", "%ihxcheck% $2 $1", "%mkbin% -Z $1 $2 $3" }, @@ -124,7 +124,7 @@ static CLASS classes[] = { "%as% %asdefault% $1 $3 $2", "%bankpack% $1 $2", "%ld% -n -- -i $1 -b_CODE=0x8100 -k%libdir%%port%/ -l%port%.lib " - "-k%libdir%%plat%/ -l%plat%.lib $3 %libdir%%plat%/crt0.o $2", + "-k%libdir%%plat%/ -l%plat%.lib $3 $2", "%ihxcheck% $2 $1", "%mkbin% -Z $1 $2 $3" }, @@ -137,7 +137,7 @@ static CLASS classes[] = { "%as% %asdefault% $1 $3 $2", "%bankpack% $1 $2", "%ld% -n -- -i $1 -b_DATA=0x8000 -b_CODE=0x200 -k%libdir%%port%/ -l%port%.lib " - "-k%libdir%%plat%/ -l%plat%.lib $3 %libdir%%plat%/crt0.o $2", + "-k%libdir%%plat%/ -l%plat%.lib $3 $2", "%ihxcheck% $2 $1", "%mkbin% -Z $1 $2 $3" } @@ -251,6 +251,7 @@ char *ihxcheck[256]; char *ld[256]; char *bankpack[256]; char *mkbin[256]; +char *crt0[256]; const char *starts_with(const char *s1, const char *s2) { @@ -330,6 +331,7 @@ void finalise(void) buildArgs(ld, _class->ld); buildArgs(ihxcheck, _class->ihxcheck); buildArgs(mkbin, _class->mkbin); + buildArgs(crt0, "%libdir%%plat%/crt0.o"); } void set_gbdk_dir(char* argv_0) diff --git a/gbdk-support/lcc/lcc.c b/gbdk-support/lcc/lcc.c @@ -60,7 +60,7 @@ static void Fixllist(); static void list_rewrite_exts(List, char *, char *); static void list_duplicate_to_new_exts(List, char *, char *); -extern char *cpp[], *include[], *com[], *as[], *bankpack[], *ld[], *ihxcheck[], *mkbin[], inputs[], *suffixes[]; +extern char *cpp[], *include[], *com[], *as[], *bankpack[], *ld[], *ihxcheck[], *mkbin[], inputs[], *suffixes[], *crt0[]; extern int option(char *); extern void set_gbdk_dir(char*); @@ -71,12 +71,13 @@ static int Eflag; /* -E specified */ static int Sflag; /* -S specified */ static int cflag; /* -c specified */ static int Kflag; /* -K specified */ +static int fflag; /* -Wl-f specified */ static int autobankflag; /* -K specified */ static int verbose; /* incremented for each -v */ static List bankpack_flags; /* bankpack flags */ static List ihxchecklist; /* ihxcheck flags */ static List mkbinlist; /* loader files, flags */ -static List llist[2]; /* [1] = loader files, [0] = flags */ +static List llist[3]; /* [1] = loader files, [0] = flags */ static List alist; /* assembler flags */ List clist; /* compiler flags */ static List plist; /* preprocessor flags */ @@ -228,7 +229,9 @@ int main(int argc, char *argv[]) { // Call linker // (fixlist adds required default linker vars if not added by user) Fixllist(); - compose(ld, llist[0], llist[1], append(ihxFile, 0)); + llist[2] = append(ihxFile, 0); + if (!fflag) llist[2] = append(*crt0, llist[2]); + compose(ld, llist[0], llist[1], llist[2]); if (callsys(av)) errcnt++; @@ -842,15 +845,28 @@ static void opt(char *arg) { if(arg[4] == 'y' && (arg[5] == 't' || arg[5] == 'o' || arg[5] == 'a' || arg[5] == 'p') && (arg[6] != '\0' && arg[6] != ' ')) goto makebinoption; //automatically pass -yo -ya -yt -yp options to makebin (backwards compatibility) { - char *tmp = malloc(256); - sprintf(tmp, "%c%c", arg[3], arg[4]); //sdldgb requires spaces between -k and the path - llist[0] = append(tmp, llist[0]); //splitting the args into 2 works on Win and Linux - if(arg[5]){ - char *tmp2 = malloc(256); - sprintf(tmp2, "%s", &arg[5]); - llist[0] = append(tmp2, llist[0]); + if (arg[4] == 'f') { + char *tmp = malloc(256); + sprintf(tmp, "%c%c", arg[3], arg[4]); // we pass the list as the very last parameter + llist[1] = append(tmp, llist[1]); + if(arg[5]){ + char *tmp2 = malloc(256); + sprintf(tmp2, "%s", &arg[5]); + llist[1] = append(tmp2, llist[1]); + } + fflag++; + } else { + char *tmp = malloc(256); + sprintf(tmp, "%c%c", arg[3], arg[4]); //sdldgb requires spaces between -k and the path + llist[0] = append(tmp, llist[0]); //splitting the args into 2 works on Win and Linux + if(arg[5]){ + char *tmp2 = malloc(256); + sprintf(tmp2, "%s", &arg[5]); + llist[0] = append(tmp2, llist[0]); + } } - }return; + } + return; case 'm': /* Makebin */ makebinoption:{ char *tmp = malloc(256);
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.