From 5a05acf9366e4c1eef73fd4387afc45f6a6cebef Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Tue, 30 Apr 2019 16:20:22 +0200 Subject: [PATCH] ld65: implement '--allow-multiple-definition' command line parameter --- src/ld65/exports.c | 4 +-- src/ld65/global.c | 1 + src/ld65/global.h | 1 + src/ld65/main.c | 79 ++++++++++++++++++++++++++-------------------- 4 files changed, 49 insertions(+), 36 deletions(-) diff --git a/src/ld65/exports.c b/src/ld65/exports.c index 160e0c797..b83d8b496 100644 --- a/src/ld65/exports.c +++ b/src/ld65/exports.c @@ -481,8 +481,8 @@ void InsertExport (Export* E) Imp->Exp = E; Imp = Imp->Next; } - } else { - /* Duplicate entry, this is fatal */ + } else if (AllowMultDef == 0) { + /* Duplicate entry, this is fatal unless allowed by the user */ Error ("Duplicate external identifier: '%s'", GetString (L->Name)); } diff --git a/src/ld65/global.c b/src/ld65/global.c index dc0c8d521..59c3754e6 100644 --- a/src/ld65/global.c +++ b/src/ld65/global.c @@ -53,6 +53,7 @@ unsigned char HaveStartAddr = 0; /* Start address not given */ unsigned long StartAddr = 0x200; /* Start address */ unsigned char VerboseMap = 0; /* Verbose map file */ +unsigned char AllowMultDef = 0; /* Allow multiple definitions */ const char* MapFileName = 0; /* Name of the map file */ const char* LabelFileName = 0; /* Name of the label file */ const char* DbgFileName = 0; /* Name of the debug file */ diff --git a/src/ld65/global.h b/src/ld65/global.h index 4b873f027..6af265f45 100644 --- a/src/ld65/global.h +++ b/src/ld65/global.h @@ -53,6 +53,7 @@ extern unsigned char HaveStartAddr; /* True if start address was given */ extern unsigned long StartAddr; /* Start address */ extern unsigned char VerboseMap; /* Verbose map file */ +extern unsigned char AllowMultDef; /* Allow multiple definitions */ extern const char* MapFileName; /* Name of the map file */ extern const char* LabelFileName; /* Name of the label file */ extern const char* DbgFileName; /* Name of the debug file */ diff --git a/src/ld65/main.c b/src/ld65/main.c index e0dcf9727..94a2101b3 100644 --- a/src/ld65/main.c +++ b/src/ld65/main.c @@ -128,23 +128,24 @@ static void Usage (void) " -vm\t\t\tVerbose map file\n" "\n" "Long options:\n" - " --cfg-path path\tSpecify a config file search path\n" - " --config name\t\tUse linker config file\n" - " --dbgfile name\tGenerate debug information\n" - " --define sym=val\tDefine a symbol\n" - " --end-group\t\tEnd a library group\n" - " --force-import sym\tForce an import of symbol 'sym'\n" - " --help\t\tHelp (this text)\n" - " --lib file\t\tLink this library\n" - " --lib-path path\tSpecify a library search path\n" - " --mapfile name\tCreate a map file\n" - " --module-id id\tSpecify a module id\n" - " --obj file\t\tLink this object file\n" - " --obj-path path\tSpecify an object file search path\n" - " --start-addr addr\tSet the default start address\n" - " --start-group\t\tStart a library group\n" - " --target sys\t\tSet the target system\n" - " --version\t\tPrint the linker version\n", + " --allow-multiple-definition\tAllow multiple definitions\n" + " --cfg-path path\t\tSpecify a config file search path\n" + " --config name\t\t\tUse linker config file\n" + " --dbgfile name\t\tGenerate debug information\n" + " --define sym=val\t\tDefine a symbol\n" + " --end-group\t\t\tEnd a library group\n" + " --force-import sym\t\tForce an import of symbol 'sym'\n" + " --help\t\t\tHelp (this text)\n" + " --lib file\t\t\tLink this library\n" + " --lib-path path\t\tSpecify a library search path\n" + " --mapfile name\t\tCreate a map file\n" + " --module-id id\t\tSpecify a module id\n" + " --obj file\t\t\tLink this object file\n" + " --obj-path path\t\tSpecify an object file search path\n" + " --start-addr addr\t\tSet the default start address\n" + " --start-group\t\t\tStart a library group\n" + " --target sys\t\t\tSet the target system\n" + " --version\t\t\tPrint the linker version\n", ProgName); } @@ -549,6 +550,15 @@ static void OptVersion (const char* Opt attribute ((unused)), +static void OptMultDef (const char* Opt attribute ((unused)), + const char* Arg attribute ((unused))) +/* Print the assembler version */ +{ + AllowMultDef = 1; +} + + + static void CmdlOptStartGroup (const char* Opt attribute ((unused)), const char* Arg attribute ((unused))) /* Remember 'start group' occurrence in input files array */ @@ -599,23 +609,24 @@ static void ParseCommandLine(void) { /* Program long options */ static const LongOpt OptTab[] = { - { "--cfg-path", 1, OptCfgPath }, - { "--config", 1, CmdlOptConfig }, - { "--dbgfile", 1, OptDbgFile }, - { "--define", 1, OptDefine }, - { "--end-group", 0, CmdlOptEndGroup }, - { "--force-import", 1, OptForceImport }, - { "--help", 0, OptHelp }, - { "--lib", 1, OptLib }, - { "--lib-path", 1, OptLibPath }, - { "--mapfile", 1, OptMapFile }, - { "--module-id", 1, OptModuleId }, - { "--obj", 1, OptObj }, - { "--obj-path", 1, OptObjPath }, - { "--start-addr", 1, OptStartAddr }, - { "--start-group", 0, CmdlOptStartGroup }, - { "--target", 1, CmdlOptTarget }, - { "--version", 0, OptVersion }, + { "--allow-multiple-definition", 0, OptMultDef }, + { "--cfg-path", 1, OptCfgPath }, + { "--config", 1, CmdlOptConfig }, + { "--dbgfile", 1, OptDbgFile }, + { "--define", 1, OptDefine }, + { "--end-group", 0, CmdlOptEndGroup }, + { "--force-import", 1, OptForceImport }, + { "--help", 0, OptHelp }, + { "--lib", 1, OptLib }, + { "--lib-path", 1, OptLibPath }, + { "--mapfile", 1, OptMapFile }, + { "--module-id", 1, OptModuleId }, + { "--obj", 1, OptObj }, + { "--obj-path", 1, OptObjPath }, + { "--start-addr", 1, OptStartAddr }, + { "--start-group", 0, CmdlOptStartGroup }, + { "--target", 1, CmdlOptTarget }, + { "--version", 0, OptVersion }, }; unsigned I; -- 2.39.2