ld65: implement '--allow-multiple-definition' command line parameter

This commit is contained in:
Christian Groessler 2019-04-30 16:20:22 +02:00 committed by Oliver Schmidt
parent c248c14075
commit 5a05acf936
4 changed files with 49 additions and 36 deletions

View file

@ -481,8 +481,8 @@ void InsertExport (Export* E)
Imp->Exp = E; Imp->Exp = E;
Imp = Imp->Next; Imp = Imp->Next;
} }
} else { } else if (AllowMultDef == 0) {
/* Duplicate entry, this is fatal */ /* Duplicate entry, this is fatal unless allowed by the user */
Error ("Duplicate external identifier: '%s'", Error ("Duplicate external identifier: '%s'",
GetString (L->Name)); GetString (L->Name));
} }

View file

@ -53,6 +53,7 @@ unsigned char HaveStartAddr = 0; /* Start address not given */
unsigned long StartAddr = 0x200; /* Start address */ unsigned long StartAddr = 0x200; /* Start address */
unsigned char VerboseMap = 0; /* Verbose map file */ 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* MapFileName = 0; /* Name of the map file */
const char* LabelFileName = 0; /* Name of the label file */ const char* LabelFileName = 0; /* Name of the label file */
const char* DbgFileName = 0; /* Name of the debug file */ const char* DbgFileName = 0; /* Name of the debug file */

View file

@ -53,6 +53,7 @@ extern unsigned char HaveStartAddr; /* True if start address was given */
extern unsigned long StartAddr; /* Start address */ extern unsigned long StartAddr; /* Start address */
extern unsigned char VerboseMap; /* Verbose map file */ 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* MapFileName; /* Name of the map file */
extern const char* LabelFileName; /* Name of the label file */ extern const char* LabelFileName; /* Name of the label file */
extern const char* DbgFileName; /* Name of the debug file */ extern const char* DbgFileName; /* Name of the debug file */

View file

@ -128,23 +128,24 @@ static void Usage (void)
" -vm\t\t\tVerbose map file\n" " -vm\t\t\tVerbose map file\n"
"\n" "\n"
"Long options:\n" "Long options:\n"
" --cfg-path path\tSpecify a config file search path\n" " --allow-multiple-definition\tAllow multiple definitions\n"
" --config name\t\tUse linker config file\n" " --cfg-path path\t\tSpecify a config file search path\n"
" --dbgfile name\tGenerate debug information\n" " --config name\t\t\tUse linker config file\n"
" --define sym=val\tDefine a symbol\n" " --dbgfile name\t\tGenerate debug information\n"
" --end-group\t\tEnd a library group\n" " --define sym=val\t\tDefine a symbol\n"
" --force-import sym\tForce an import of symbol 'sym'\n" " --end-group\t\t\tEnd a library group\n"
" --help\t\tHelp (this text)\n" " --force-import sym\t\tForce an import of symbol 'sym'\n"
" --lib file\t\tLink this library\n" " --help\t\t\tHelp (this text)\n"
" --lib-path path\tSpecify a library search path\n" " --lib file\t\t\tLink this library\n"
" --mapfile name\tCreate a map file\n" " --lib-path path\t\tSpecify a library search path\n"
" --module-id id\tSpecify a module id\n" " --mapfile name\t\tCreate a map file\n"
" --obj file\t\tLink this object file\n" " --module-id id\t\tSpecify a module id\n"
" --obj-path path\tSpecify an object file search path\n" " --obj file\t\t\tLink this object file\n"
" --start-addr addr\tSet the default start address\n" " --obj-path path\t\tSpecify an object file search path\n"
" --start-group\t\tStart a library group\n" " --start-addr addr\t\tSet the default start address\n"
" --target sys\t\tSet the target system\n" " --start-group\t\t\tStart a library group\n"
" --version\t\tPrint the linker version\n", " --target sys\t\t\tSet the target system\n"
" --version\t\t\tPrint the linker version\n",
ProgName); 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)), static void CmdlOptStartGroup (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused))) const char* Arg attribute ((unused)))
/* Remember 'start group' occurrence in input files array */ /* Remember 'start group' occurrence in input files array */
@ -599,6 +609,7 @@ static void ParseCommandLine(void)
{ {
/* Program long options */ /* Program long options */
static const LongOpt OptTab[] = { static const LongOpt OptTab[] = {
{ "--allow-multiple-definition", 0, OptMultDef },
{ "--cfg-path", 1, OptCfgPath }, { "--cfg-path", 1, OptCfgPath },
{ "--config", 1, CmdlOptConfig }, { "--config", 1, CmdlOptConfig },
{ "--dbgfile", 1, OptDbgFile }, { "--dbgfile", 1, OptDbgFile },