From 69471c6e2bc4261d2119b331bcb938b33d2d2de5 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 24 Jul 2016 12:47:46 +0100 Subject: [PATCH] fcc: work around ./ problem in SDCC linker and fix bug in fcc extension handler With both of these fixed we now properly handle doing things with a -o ./foo target --- Library/tools/fcc.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Library/tools/fcc.c b/Library/tools/fcc.c index 416d6fa9..8882faba 100644 --- a/Library/tools/fcc.c +++ b/Library/tools/fcc.c @@ -227,7 +227,11 @@ static char *rebuildname(const char *r, const char *i, char *ext) } strcpy(p, r); strcat(p, i); - t = strrchr(p, '.'); + t = strrchr(p, '/'); + if (t) + t = strrchr(t, '.'); + else + t = strrchr(p, '.'); if (t) strcpy(t + 1, ext); else { @@ -346,6 +350,17 @@ static int do_command(void) } return (WEXITSTATUS(status)); } + +/* + * The SDCC tool chain screws up if fed ./foo.o as a target so undo + * any ./ bit + */ +static char *undotslash(char *p) +{ + if (*p == '.' && p[1] == '/') + return p + 2; + return p; +} /* * Stitch together an sdcc command. @@ -432,7 +447,7 @@ static void build_command(void) fprintf(stderr, "no target.\n"); exit(1); } - add_option("-o", target); + add_option("-o", undotslash(target)); if (nostdio) snprintf(buf, sizeof(buf), FCC_DIR "/lib/crt0nostdio%s.rel", platform); else -- 2.34.1