aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl/aix.em
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2003-02-28 01:32:31 +0000
committerAlan Modra <amodra@gmail.com>2003-02-28 01:32:31 +0000
commit3bcf55573d377355c73846cc0b819c7d878d8e19 (patch)
treebbe9a2d3302487029b4dbb711170df911a326c35 /ld/emultempl/aix.em
parent2c4c2bc0a526e8e0c186cd7cb005e2947cac3b88 (diff)
downloadfsf-binutils-gdb-3bcf55573d377355c73846cc0b819c7d878d8e19.zip
fsf-binutils-gdb-3bcf55573d377355c73846cc0b819c7d878d8e19.tar.gz
fsf-binutils-gdb-3bcf55573d377355c73846cc0b819c7d878d8e19.tar.bz2
* ldemul.c (ldemul_add_options, ldemul_handle_option): New functions.
(ldemul_parse_args): Return bfd_boolean. Formatting. * ldemul.h (ldemul_add_options, ldemul_handle_option): Declare. (ldemul_parse_args): Adjust. (struct ld_emulation_xfer_struct): Add add_options and handle_option. Return bfd_boolean from parse_args. * lexsup.c (parse_args): Malloc shortopts, longopts and really_longopts. Call ldemul_add_options and ldemul_handle_option. * emultempl/aix.em (gld${EMULATION_NAME}_add_options): Split out from gld${EMULATION_NAME}_parse_args. (gld${EMULATION_NAME}_handle_option): Likewise. (ld_${EMULATION_NAME}_emulation): Adjust initializer. * emultempl/armcoff.em: As for aix.em, but remove parse_args. * emultempl/beos.em: Likewise. * emultempl/pe.em: Likewise. * emultempl/ticoff.em: Likewise. * emultempl/elf32.em: Likewise. Don't duplicate long options either. (gld${EMULATION_NAME}_add_sysroot): Prototype. * emultempl/armelf.em (PARSE_AND_LIST_LONGOPTS): Don't duplicate options. * emultempl/hppaelf.em (PARSE_AND_LIST_LONGOPTS): Likewise. * emultempl/ppc32elf.em (PARSE_AND_LIST_LONGOPTS): Likewise. * emultempl/ppc64elf.em (PARSE_AND_LIST_LONGOPTS): Likewise. * emultempl/armelf_oabi.em (ld_${EMULATION_NAME}_emulation): Adjust initializer. * emultempl/generic.em: Likewise. * emultempl/gld960.em: Likewise. * emultempl/gld960c.em: Likewise. * emultempl/linux.em: Likewise. * emultempl/lnk960.em: Likewise. * emultempl/m68kcoff.em: Likewise. * emultempl/mipsecoff.em: Likewise. * emultempl/sunos.em: Likewise. * emultempl/vanilla.em: Likewise. * emultempl/netbsd.em (gldnetbsd_before_parse): Prototype.
Diffstat (limited to 'ld/emultempl/aix.em')
-rw-r--r--ld/emultempl/aix.em80
1 files changed, 46 insertions, 34 deletions
diff --git a/ld/emultempl/aix.em b/ld/emultempl/aix.em
index b0a078a..910f831 100644
--- a/ld/emultempl/aix.em
+++ b/ld/emultempl/aix.em
@@ -9,7 +9,7 @@ cat >e${EMULATION_NAME}.c <<EOF
/* This file is is generated by a shell script. DO NOT EDIT! */
/* AIX emulation code for ${EMULATION_NAME}
- Copyright 1991, 1993, 1995, 1996, 1997, 1998, 2000, 2001, 2002
+ Copyright 1991, 1993, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
Written by Steve Chamberlain <sac@cygnus.com>
AIX support by Ian Lance Taylor <ian@cygnus.com>
@@ -58,8 +58,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
static void gld${EMULATION_NAME}_before_parse
PARAMS ((void));
-static int gld${EMULATION_NAME}_parse_args
+static bfd_boolean gld${EMULATION_NAME}_parse_args
PARAMS ((int, char **));
+static void gld${EMULATION_NAME}_add_options
+ PARAMS ((int, char **, int, struct option **, int, struct option **));
+static bfd_boolean gld${EMULATION_NAME}_handle_option
+ PARAMS ((int));
static void gld${EMULATION_NAME}_after_open
PARAMS ((void));
static char *gld${EMULATION_NAME}_choose_target
@@ -180,20 +184,7 @@ gld${EMULATION_NAME}_before_parse ()
/* Handle AIX specific options. */
-static int
-gld${EMULATION_NAME}_parse_args (argc, argv)
- int argc;
- char **argv;
-{
- int prevoptind = optind;
- int prevopterr = opterr;
- int indx;
- int longind;
- int optc;
- bfd_signed_vma val;
- const char *end;
-
- enum
+enum
{
OPTION_IGNORE = 300,
OPTION_AUTOIMP,
@@ -218,6 +209,17 @@ gld${EMULATION_NAME}_parse_args (argc, argv)
OPTION_NOLIBPATH,
};
+static void
+gld${EMULATION_NAME}_add_options (ns, shortopts, nl, longopts, nrl, really_longopts)
+ int ns;
+ char **shortopts;
+ int nl;
+ struct option **longopts;
+ int nrl ATTRIBUTE_UNUSED;
+ struct option **really_longopts ATTRIBUTE_UNUSED;
+{
+ static const char xtra_short[] = "D:H:KT:z";
+ static const struct option xtra_long[] = {
/* -binitfini has special handling in the linker backend. The native linker
uses the arguemnts to generate a table of init and fini functions for
the executable. The important use for this option is to support aix 4.2+
@@ -227,7 +229,6 @@ gld${EMULATION_NAME}_parse_args (argc, argv)
the first symbol in the loader symbol table is __rtinit. The gnu linker
generates this symbol and makes it the first loader symbol. */
- static const struct option longopts[] = {
{"basis", no_argument, NULL, OPTION_IGNORE},
{"bautoimp", no_argument, NULL, OPTION_AUTOIMP},
{"bcomprld", no_argument, NULL, OPTION_IGNORE},
@@ -288,6 +289,20 @@ gld${EMULATION_NAME}_parse_args (argc, argv)
-bnotypchk, -bnox, -bquiet, -bR, -brename, -breorder, -btypchk,
-bx, -bX, -bxref. */
+ *shortopts = (char *) xrealloc (*shortopts, ns + sizeof (xtra_short));
+ memcpy (*shortopts + ns, &xtra_short, sizeof (xtra_short));
+ *longopts = (struct option *)
+ xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long));
+ memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long));
+}
+
+static bfd_boolean
+gld${EMULATION_NAME}_parse_args (argc, argv)
+ int argc;
+ char **argv;
+{
+ int indx;
+
/* If the current option starts with -b, change the first : to an =.
The AIX linker uses : to separate the option from the argument;
changing it to = lets us treat it as a getopt option. */
@@ -308,22 +323,20 @@ gld${EMULATION_NAME}_parse_args (argc, argv)
}
}
}
+ return FALSE;
+}
-
- /* We add s and u so to the short options list so that -s and -u on
- the command line do not match -static and -unix. */
-
- opterr = 0;
- optc = getopt_long_only (argc, argv, "-D:H:KT:zsu", longopts, &longind);
- opterr = prevopterr;
+static bfd_boolean
+gld${EMULATION_NAME}_handle_option (optc)
+ int optc;
+{
+ bfd_signed_vma val;
+ const char *end;
switch (optc)
{
- case 's':
- case 'u':
default:
- optind = prevoptind;
- return 0;
+ return FALSE;
case 0:
/* Long option which just sets a flag. */
@@ -358,10 +371,7 @@ gld${EMULATION_NAME}_parse_args (argc, argv)
ignore the AIX option, because gcc passes it to the linker. */
val = bfd_scan_vma (optarg, &end, 0);
if (*end != '\0')
- {
- optind = prevoptind;
- return 0;
- }
+ return FALSE;
lang_section_start (".text", exp_intop (val));
break;
@@ -552,7 +562,7 @@ gld${EMULATION_NAME}_parse_args (argc, argv)
}
- return 1;
+ return TRUE;
}
/* This is called when an input file can not be recognized as a BFD
@@ -945,7 +955,7 @@ is_syscall (input, flag)
/* Read an import or export file. For an import file, this is called
by the before_allocation emulation routine. For an export file,
- this is called by the parse_args emulation routine. */
+ this is called by the handle_option emulation routine. */
static void
gld${EMULATION_NAME}_read_file (filename, import)
@@ -1391,6 +1401,8 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = {
0, /* place_orphan */
0, /* set_symbols */
gld${EMULATION_NAME}_parse_args,
+ gld${EMULATION_NAME}_add_options,
+ gld${EMULATION_NAME}_handle_option,
gld${EMULATION_NAME}_unrecognized_file,
NULL, /* list_options */
NULL, /* recognized_file */