From 093505ad6138b9e165876765ecd667c90fc921ae Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 23 Aug 1999 09:13:56 +0000 Subject: [PATCH] Implement --base-file command line switch. --- ld/ChangeLog | 3 ++ ld/emulparams/elf32mcore.sh | 65 +++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/ld/ChangeLog b/ld/ChangeLog index 7eb00ef147..e26eb46e5d 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,5 +1,8 @@ 1999-08-23 Nick Clifton + * emulparams/elf32mcore.sh (PARSE_AND_LIST_ARGS): Define. + Implement --base-file command line switch. + * emultempl/elf32.em: Add ability for individual targets to have their own command line switches by defining PARSE_AND_LIST_ARGS. diff --git a/ld/emulparams/elf32mcore.sh b/ld/emulparams/elf32mcore.sh index bd1fdae04c..f3a67cafae 100644 --- a/ld/emulparams/elf32mcore.sh +++ b/ld/emulparams/elf32mcore.sh @@ -30,3 +30,68 @@ OTHER_RELOCATING_SECTIONS='.stack 0x80000 : { _stack = .; *(.stack) }' TEMPLATE_NAME=elf32 GENERATE_SHLIB_SCRIPT=yes + +# This code gets inserted into the generic elf32.sc linker script +# and allows us to define our own command line switches. +PARSE_AND_LIST_ARGS=' + +#define OPTION_BASE_FILE 300 + +static struct option longopts[] = +{ + {"base-file", required_argument, NULL, OPTION_BASE_FILE}, + {NULL, no_argument, NULL, 0} +}; + +static void +gld_elf32mcore_list_options (file) + FILE * file; +{ + fprintf (file, _(" --base_file Generate a base file for relocatable DLLs\n")); +} + +static int +gld_elf32mcore_parse_args (argc, argv) + int argc; + char ** argv; +{ + int longind; + int optc; + int prevoptind = optind; + int prevopterr = opterr; + int wanterror; + static int lastoptind = -1; + + if (lastoptind != optind) + opterr = 0; + + wanterror = opterr; + lastoptind = optind; + + optc = getopt_long_only (argc, argv, "-", longopts, & longind); + opterr = prevopterr; + + switch (optc) + { + default: + if (wanterror) + xexit (1); + optind = prevoptind; + return 0; + + case OPTION_BASE_FILE: + link_info.base_file = (PTR) fopen (optarg, FOPEN_WB); + if (link_info.base_file == NULL) + { + /* xgettext:c-format */ + fprintf (stderr, _("%s: Cannot open base file %s\n"), + program_name, optarg); + xexit (1); + } + break; + } + + return 1; +} + +'