/* */
/* */
/* */
-/* (C) 1998-2000 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 1998-2003 Ullrich von Bassewitz */
+/* Römerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
#include "cmdline.h"
#include "libdefs.h"
#include "objdefs.h"
+#include "print.h"
#include "target.h"
#include "version.h"
#include "xmalloc.h"
fprintf (stderr,
"Usage: %s [options] module ...\n"
"Short options:\n"
+ " -C name\t\tUse linker config file\n"
+ " -Ln name\t\tCreate a VICE label file\n"
+ " -Lp\t\t\tMark write protected segments as such (VICE)\n"
+ " -S addr\t\tSet the default start address\n"
+ " -V\t\t\tPrint the linker version\n"
" -h\t\t\tHelp (this text)\n"
" -m name\t\tCreate a map file\n"
" -o name\t\tName the default output file\n"
" -t sys\t\tSet the target system\n"
" -v\t\t\tVerbose mode\n"
" -vm\t\t\tVerbose map file\n"
- " -C name\t\tUse linker config file\n"
- " -Ln name\t\tCreate a VICE label file\n"
- " -Lp\t\t\tMark write protected segments as such (VICE)\n"
- " -S addr\t\tSet the default start address\n"
- " -V\t\t\tPrint the linker version\n"
"\n"
"Long options:\n"
+ " --config name\t\tUse linker config file\n"
+ " --dump-config name\tDump a builtin configuration\n"
" --help\t\tHelp (this text)\n"
" --mapfile name\tCreate a map file\n"
+ " --module-id id\tSpecify a module id\n"
" --start-addr addr\tSet the default start address\n"
" --target sys\t\tSet the target system\n"
" --version\t\tPrint the linker version\n",
-static void OptConfig (const char* Opt, const char* Arg)
+static void OptConfig (const char* Opt attribute ((unused)), const char* Arg)
/* Define the config file */
{
if (CfgAvail ()) {
-static void OptHelp (const char* Opt, const char* Arg)
+static void OptDbgFile (const char* Opt attribute ((unused)), const char* Arg)
+/* Give the name of the debug file */
+{
+ DbgFileName = Arg;
+}
+
+
+
+static void OptDumpConfig (const char* Opt attribute ((unused)), const char* Arg)
+/* Dump a builtin linker configuration */
+{
+ /* Map the given target name to its id */
+ target_t T = FindTarget (Arg);
+ if (T == TGT_UNKNOWN) {
+ Error ("Target system `%s' is unknown", Arg);
+ }
+
+ /* Dump the builtin configuration */
+ DumpBuiltinConfig (stdout, T);
+}
+
+
+
+static void OptHelp (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
/* Print usage information and exit */
{
Usage ();
-static void OptMapFile (const char* Opt, const char* Arg)
+static void OptMapFile (const char* Opt attribute ((unused)), const char* Arg)
/* Give the name of the map file */
{
MapFileName = Arg;
+static void OptModuleId (const char* Opt, const char* Arg)
+/* Specify a module id */
+{
+ unsigned long Id = CvtNumber (Opt, Arg);
+ if (Id > 0xFFFFUL) {
+ Error ("Range error in module id");
+ }
+ ModuleId = (unsigned) Id;
+}
+
+
+
static void OptStartAddr (const char* Opt, const char* Arg)
/* Set the default start address */
{
StartAddr = CvtNumber (Opt, Arg);
+ HaveStartAddr = 1;
}
-static void OptTarget (const char* Opt, const char* Arg)
+static void OptTarget (const char* Opt attribute ((unused)), const char* Arg)
/* Set the target system */
{
const TargetDesc* D;
-static void OptVersion (const char* Opt, const char* Arg)
+static void OptVersion (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
/* Print the assembler version */
{
fprintf (stderr,
- "ld65 V%u.%u.%u - (C) Copyright 1998-2000 Ullrich von Bassewitz\n",
+ "ld65 V%u.%u.%u - (C) Copyright 1998-2002 Ullrich von Bassewitz\n",
VER_MAJOR, VER_MINOR, VER_PATCH);
}
{
/* Program long options */
static const LongOpt OptTab[] = {
- { "--config", 1, OptConfig },
- { "--help", 0, OptHelp },
- { "--mapfile", 1, OptMapFile },
- { "--start-addr", 1, OptStartAddr },
- { "--target", 1, OptTarget },
- { "--version", 0, OptVersion },
+ { "--config", 1, OptConfig },
+ { "--dbgfile", 1, OptDbgFile },
+ { "--dump-config", 1, OptDumpConfig },
+ { "--help", 0, OptHelp },
+ { "--mapfile", 1, OptMapFile },
+ { "--module-id", 1, OptModuleId },
+ { "--start-addr", 1, OptStartAddr },
+ { "--target", 1, OptTarget },
+ { "--version", 0, OptVersion },
};
- int I;
+ unsigned I;
/* Initialize the cmdline module */
- InitCmdLine (argc, argv, "ld65");
+ InitCmdLine (&argc, &argv, "ld65");
/* Evaluate the CC65_LIB environment variable */
LibPath = getenv ("CC65_LIB");
/* Check the parameters */
I = 1;
- while (I < argc) {
+ while (I < ArgCount) {
/* Get the argument */
- const char* Arg = argv [I];
+ const char* Arg = ArgVec[I];
/* Check for an option */
if (Arg [0] == '-') {
case 'v':
switch (Arg [2]) {
case 'm': VerboseMap = 1; break;
- case '\0': ++Verbose; break;
+ case '\0': ++Verbosity; break;
default: UnknownOption (Arg);
}
break;
if (LabelFileName) {
CreateLabelFile ();
}
+ if (DbgFileName) {
+ CreateDbgFile ();
+ }
/* Dump the data for debugging */
- if (Verbose > 1) {
+ if (Verbosity > 1) {
SegDump ();
ConDesDump ();
}