* po/eo.po: New Esperanto translation.
[binutils.git] / binutils / emul_aix.c
blob2f6a3e4df5dd63441c84a35616b6fbd46db6d9ca
1 /* Binutils emulation layer.
2 Copyright 2002, 2003, 2005, 2006, 2007, 2008, 2010
3 Free Software Foundation, Inc.
4 Written by Tom Rix, Red Hat Inc.
6 This file is part of GNU Binutils.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
23 #include "binemul.h"
24 #include "bfdlink.h"
25 #include "coff/internal.h"
26 #include "coff/xcoff.h"
27 #include "libcoff.h"
28 #include "libxcoff.h"
30 /* Default to <bigaf>. */
31 /* FIXME: write only variable. */
32 static bfd_boolean big_archive = TRUE;
34 /* Whether to include 32 bit objects. */
35 static bfd_boolean X32 = TRUE;
37 /* Whether to include 64 bit objects. */
38 static bfd_boolean X64 = FALSE;
40 static void
41 ar_emul_aix_usage (FILE *fp)
43 AR_EMUL_USAGE_PRINT_OPTION_HEADER (fp);
44 /* xgettext:c-format */
45 fprintf (fp, _(" [-g] - 32 bit small archive\n"));
46 fprintf (fp, _(" [-X32] - ignores 64 bit objects\n"));
47 fprintf (fp, _(" [-X64] - ignores 32 bit objects\n"));
48 fprintf (fp, _(" [-X32_64] - accepts 32 and 64 bit objects\n"));
51 static bfd_boolean
52 check_aix (bfd *try_bfd)
54 extern const bfd_target rs6000coff_vec;
55 extern const bfd_target rs6000coff64_vec;
56 extern const bfd_target aix5coff64_vec;
58 if (bfd_check_format (try_bfd, bfd_object))
60 if (!X32 && try_bfd->xvec == &rs6000coff_vec)
61 return FALSE;
63 if (!X64 && (try_bfd->xvec == &rs6000coff64_vec
64 || try_bfd->xvec == &aix5coff64_vec))
65 return FALSE;
67 return TRUE;
70 static bfd_boolean
71 ar_emul_aix_append (bfd **after_bfd, char *file_name, const char *target,
72 bfd_boolean verbose, bfd_boolean flatten)
74 bfd *new_bfd;
76 new_bfd = bfd_openr (file_name, target);
77 AR_EMUL_ELEMENT_CHECK (new_bfd, file_name);
79 return do_ar_emul_append (after_bfd, new_bfd, verbose, flatten, check_aix);
82 static bfd_boolean
83 ar_emul_aix_replace (bfd **after_bfd, char *file_name, const char *target,
84 bfd_boolean verbose)
86 bfd *new_bfd;
88 new_bfd = bfd_openr (file_name, target);
89 AR_EMUL_ELEMENT_CHECK (new_bfd, file_name);
91 if (!check_aix (new_bfd))
92 return FALSE;
94 AR_EMUL_REPLACE_PRINT_VERBOSE (verbose, file_name);
96 new_bfd->archive_next = *after_bfd;
97 *after_bfd = new_bfd;
99 return TRUE;
102 static bfd_boolean
103 ar_emul_aix_parse_arg (char *arg)
105 if (CONST_STRNEQ (arg, "-X32_64"))
107 big_archive = TRUE;
108 X32 = TRUE;
109 X64 = TRUE;
111 else if (CONST_STRNEQ (arg, "-X32"))
113 big_archive = TRUE;
114 X32 = TRUE;
115 X64 = FALSE;
117 else if (CONST_STRNEQ (arg, "-X64"))
119 big_archive = TRUE;
120 X32 = FALSE;
121 X64 = TRUE;
123 else if (CONST_STRNEQ (arg, "-g"))
125 big_archive = FALSE;
126 X32 = TRUE;
127 X64 = FALSE;
129 else
130 return FALSE;
132 return TRUE;
135 struct bin_emulation_xfer_struct bin_aix_emulation =
137 ar_emul_aix_usage,
138 ar_emul_aix_append,
139 ar_emul_aix_replace,
140 ar_emul_aix_parse_arg,