gdb/
[deliverable/binutils-gdb.git] / binutils / emul_aix.c
CommitLineData
eb1e0e80 1/* Binutils emulation layer.
13485ea2
AM
2 Copyright 2002, 2003, 2005, 2006, 2007, 2008, 2010
3 Free Software Foundation, Inc.
ad94be02 4 Written by Tom Rix, Red Hat Inc.
eb1e0e80
NC
5
6 This file is part of GNU Binutils.
7
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
32866df7 10 the Free Software Foundation; either version 3 of the License, or
eb1e0e80
NC
11 (at your option) any later version.
12
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.
17
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
32866df7
NC
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
eb1e0e80
NC
22
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"
29
30/* Default to <bigaf>. */
13485ea2 31/* FIXME: write only variable. */
b34976b6 32static bfd_boolean big_archive = TRUE;
eb1e0e80
NC
33
34/* Whether to include 32 bit objects. */
b34976b6 35static bfd_boolean X32 = TRUE;
eb1e0e80
NC
36
37/* Whether to include 64 bit objects. */
b34976b6
AM
38static bfd_boolean X64 = FALSE;
39
eb1e0e80 40static void
2da42df6 41ar_emul_aix_usage (FILE *fp)
eb1e0e80
NC
42{
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"));
49}
50
b34976b6 51static bfd_boolean
13485ea2 52check_aix (bfd *try_bfd)
eb1e0e80 53{
13485ea2
AM
54 extern const bfd_target rs6000coff_vec;
55 extern const bfd_target rs6000coff64_vec;
56 extern const bfd_target aix5coff64_vec;
eb1e0e80 57
13485ea2 58 if (bfd_check_format (try_bfd, bfd_object))
eb1e0e80 59 {
13485ea2
AM
60 if (!X32 && try_bfd->xvec == &rs6000coff_vec)
61 return FALSE;
eb1e0e80 62
13485ea2
AM
63 if (!X64 && (try_bfd->xvec == &rs6000coff64_vec
64 || try_bfd->xvec == &aix5coff64_vec))
65 return FALSE;
66 }
b34976b6 67 return TRUE;
eb1e0e80
NC
68}
69
b34976b6 70static bfd_boolean
a2478677
L
71ar_emul_aix_append (bfd **after_bfd, char *file_name, const char *target,
72 bfd_boolean verbose, bfd_boolean flatten)
eb1e0e80 73{
13485ea2 74 bfd *new_bfd;
eb1e0e80 75
13485ea2
AM
76 new_bfd = bfd_openr (file_name, target);
77 AR_EMUL_ELEMENT_CHECK (new_bfd, file_name);
78
79 return do_ar_emul_append (after_bfd, new_bfd, verbose, flatten, check_aix);
eb1e0e80
NC
80}
81
b34976b6 82static bfd_boolean
a2478677
L
83ar_emul_aix_replace (bfd **after_bfd, char *file_name, const char *target,
84 bfd_boolean verbose)
eb1e0e80 85{
13485ea2 86 bfd *new_bfd;
eb1e0e80 87
13485ea2
AM
88 new_bfd = bfd_openr (file_name, target);
89 AR_EMUL_ELEMENT_CHECK (new_bfd, file_name);
90
91 if (!check_aix (new_bfd))
92 return FALSE;
93
94 AR_EMUL_REPLACE_PRINT_VERBOSE (verbose, file_name);
95
96 new_bfd->archive_next = *after_bfd;
97 *after_bfd = new_bfd;
98
99 return TRUE;
eb1e0e80
NC
100}
101
b34976b6 102static bfd_boolean
2da42df6 103ar_emul_aix_parse_arg (char *arg)
eb1e0e80 104{
0112cd26 105 if (CONST_STRNEQ (arg, "-X32_64"))
eb1e0e80 106 {
b34976b6
AM
107 big_archive = TRUE;
108 X32 = TRUE;
109 X64 = TRUE;
eb1e0e80 110 }
0112cd26 111 else if (CONST_STRNEQ (arg, "-X32"))
eb1e0e80 112 {
b34976b6
AM
113 big_archive = TRUE;
114 X32 = TRUE;
115 X64 = FALSE;
eb1e0e80 116 }
0112cd26 117 else if (CONST_STRNEQ (arg, "-X64"))
eb1e0e80 118 {
b34976b6
AM
119 big_archive = TRUE;
120 X32 = FALSE;
121 X64 = TRUE;
eb1e0e80 122 }
0112cd26 123 else if (CONST_STRNEQ (arg, "-g"))
eb1e0e80 124 {
b34976b6
AM
125 big_archive = FALSE;
126 X32 = TRUE;
127 X64 = FALSE;
eb1e0e80
NC
128 }
129 else
b34976b6 130 return FALSE;
eb1e0e80 131
b34976b6 132 return TRUE;
eb1e0e80
NC
133}
134
26044998 135struct bin_emulation_xfer_struct bin_aix_emulation =
eb1e0e80
NC
136{
137 ar_emul_aix_usage,
138 ar_emul_aix_append,
139 ar_emul_aix_replace,
eb1e0e80
NC
140 ar_emul_aix_parse_arg,
141};
This page took 0.441739 seconds and 4 git commands to generate.