1 /* Binutils emulation layer.
2 Copyright (C) 2002 Free Software Foundation, Inc.
3 Written by Tom Rix, Redhat.
5 This file is part of GNU Binutils.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 #include "coff/internal.h"
24 #include "coff/xcoff.h"
28 /* Default to <bigaf>. */
29 static boolean big_archive
= true;
31 /* Whether to include 32 bit objects. */
32 static boolean X32
= true;
34 /* Whether to include 64 bit objects. */
35 static boolean X64
= false;
37 static void ar_emul_aix_usage
PARAMS ((FILE *));
38 static boolean ar_emul_aix_append
PARAMS ((bfd
**, char *, boolean
));
39 static boolean ar_emul_aix5_append
PARAMS ((bfd
**, char *, boolean
));
40 static boolean ar_emul_aix_replace
PARAMS ((bfd
**, char *, boolean
));
41 static boolean ar_emul_aix5_replace
PARAMS ((bfd
**, char *, boolean
));
42 static boolean ar_emul_aix_parse_arg
PARAMS ((char *));
43 static boolean ar_emul_aix_internal
PARAMS ((bfd
**, char *, boolean
,
44 const char *, boolean
));
47 ar_emul_aix_usage (fp
)
50 AR_EMUL_USAGE_PRINT_OPTION_HEADER (fp
);
51 /* xgettext:c-format */
52 fprintf (fp
, _(" [-g] - 32 bit small archive\n"));
53 fprintf (fp
, _(" [-X32] - ignores 64 bit objects\n"));
54 fprintf (fp
, _(" [-X64] - ignores 32 bit objects\n"));
55 fprintf (fp
, _(" [-X32_64] - accepts 32 and 64 bit objects\n"));
59 ar_emul_aix_internal (after_bfd
, file_name
, verbose
, target_name
, is_append
)
63 const char * target_name
;
72 try_bfd
= bfd_openr (file_name
, target_name
);
74 /* Failed or the object is possibly 32 bit. */
75 if (NULL
== try_bfd
|| ! bfd_check_format (try_bfd
, bfd_object
))
76 try_bfd
= bfd_openr (file_name
, "aixcoff-rs6000");
78 AR_EMUL_ELEMENT_CHECK (try_bfd
, file_name
);
80 if (bfd_xcoff_is_xcoff64 (try_bfd
) && (! X64
))
83 if (bfd_xcoff_is_xcoff32 (try_bfd
)
84 && bfd_check_format (try_bfd
, bfd_object
) && (! X32
))
89 AR_EMUL_APPEND_PRINT_VERBOSE (verbose
, file_name
);
93 AR_EMUL_REPLACE_PRINT_VERBOSE (verbose
, file_name
);
97 (*after_bfd
)->next
= temp
;
104 ar_emul_aix_append (after_bfd
, file_name
, verbose
)
109 return ar_emul_aix_internal (after_bfd
, file_name
, verbose
,
110 "aixcoff64-rs6000", true);
114 ar_emul_aix5_append (after_bfd
, file_name
, verbose
)
119 return ar_emul_aix_internal (after_bfd
, file_name
, verbose
,
120 "aix5coff64-rs6000", true);
124 ar_emul_aix_replace (after_bfd
, file_name
, verbose
)
129 return ar_emul_aix_internal (after_bfd
, file_name
, verbose
,
130 "aixcoff64-rs6000", false);
134 ar_emul_aix5_replace (after_bfd
, file_name
, verbose
)
139 return ar_emul_aix_internal (after_bfd
, file_name
, verbose
,
140 "aix5coff64-rs6000", false);
144 ar_emul_aix_create (abfd_out
, archive_file_name
, file_name
)
146 char *archive_file_name
;
147 char *file_name ATTRIBUTE_UNUSED
;
149 char *target
= "aixcoff-rs6000";
151 /* Create an empty archive. */
152 *abfd_out
= bfd_openw (archive_file_name
, target
);
154 if (*abfd_out
== NULL
)
155 bfd_fatal (archive_file_name
);
157 /* set to small or big format. */
163 ar_emul_aix_parse_arg (arg
)
166 if (strncmp (arg
, "-X32_64", 6) == 0)
172 else if (strncmp (arg
, "-X32", 3) == 0)
178 else if (strncmp (arg
, "-X64", 3) == 0)
184 else if (strncmp (arg
, "-g", 2) == 0)
196 struct bin_emulation_xfer_struct bin_aix_emulation
=
201 ar_emul_default_create
,
202 ar_emul_aix_parse_arg
,
205 struct bin_emulation_xfer_struct bin_aix5_emulation
=
209 ar_emul_aix5_replace
,
210 ar_emul_default_create
,
211 ar_emul_aix_parse_arg
,