1 /* Binutils emulation layer.
2 Copyright 2002, 2003 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 bfd_boolean big_archive
= TRUE
;
31 /* Whether to include 32 bit objects. */
32 static bfd_boolean X32
= TRUE
;
34 /* Whether to include 64 bit objects. */
35 static bfd_boolean X64
= FALSE
;
37 static void ar_emul_aix_usage (FILE *);
38 static bfd_boolean
ar_emul_aix_append (bfd
**, char *, bfd_boolean
);
39 static bfd_boolean
ar_emul_aix5_append (bfd
**, char *, bfd_boolean
);
40 static bfd_boolean
ar_emul_aix_replace (bfd
**, char *, bfd_boolean
);
41 static bfd_boolean
ar_emul_aix5_replace (bfd
**, char *, bfd_boolean
);
42 static bfd_boolean
ar_emul_aix_parse_arg (char *);
43 static bfd_boolean ar_emul_aix_internal
44 (bfd
**, char *, bfd_boolean
, const char *, bfd_boolean
);
47 ar_emul_aix_usage (FILE *fp
)
49 AR_EMUL_USAGE_PRINT_OPTION_HEADER (fp
);
50 /* xgettext:c-format */
51 fprintf (fp
, _(" [-g] - 32 bit small archive\n"));
52 fprintf (fp
, _(" [-X32] - ignores 64 bit objects\n"));
53 fprintf (fp
, _(" [-X64] - ignores 32 bit objects\n"));
54 fprintf (fp
, _(" [-X32_64] - accepts 32 and 64 bit objects\n"));
58 ar_emul_aix_internal (bfd
**after_bfd
, char *file_name
, bfd_boolean verbose
,
59 const char * target_name
, bfd_boolean is_append
)
67 try_bfd
= bfd_openr (file_name
, target_name
);
69 /* Failed or the object is possibly 32 bit. */
70 if (NULL
== try_bfd
|| ! bfd_check_format (try_bfd
, bfd_object
))
71 try_bfd
= bfd_openr (file_name
, "aixcoff-rs6000");
73 AR_EMUL_ELEMENT_CHECK (try_bfd
, file_name
);
75 if (bfd_xcoff_is_xcoff64 (try_bfd
) && (! X64
))
78 if (bfd_xcoff_is_xcoff32 (try_bfd
)
79 && bfd_check_format (try_bfd
, bfd_object
) && (! X32
))
84 AR_EMUL_APPEND_PRINT_VERBOSE (verbose
, file_name
);
88 AR_EMUL_REPLACE_PRINT_VERBOSE (verbose
, file_name
);
92 (*after_bfd
)->next
= temp
;
99 ar_emul_aix_append (bfd
**after_bfd
, char *file_name
, bfd_boolean verbose
)
101 return ar_emul_aix_internal (after_bfd
, file_name
, verbose
,
102 "aixcoff64-rs6000", TRUE
);
106 ar_emul_aix5_append (bfd
**after_bfd
, char *file_name
, bfd_boolean verbose
)
108 return ar_emul_aix_internal (after_bfd
, file_name
, verbose
,
109 "aix5coff64-rs6000", TRUE
);
113 ar_emul_aix_replace (bfd
**after_bfd
, char *file_name
, bfd_boolean verbose
)
115 return ar_emul_aix_internal (after_bfd
, file_name
, verbose
,
116 "aixcoff64-rs6000", FALSE
);
120 ar_emul_aix5_replace (bfd
**after_bfd
, char *file_name
, bfd_boolean verbose
)
122 return ar_emul_aix_internal (after_bfd
, file_name
, verbose
,
123 "aix5coff64-rs6000", FALSE
);
127 ar_emul_aix_parse_arg (char *arg
)
129 if (strncmp (arg
, "-X32_64", 6) == 0)
135 else if (strncmp (arg
, "-X32", 3) == 0)
141 else if (strncmp (arg
, "-X64", 3) == 0)
147 else if (strncmp (arg
, "-g", 2) == 0)
159 struct bin_emulation_xfer_struct bin_aix_emulation
=
164 ar_emul_default_create
,
165 ar_emul_aix_parse_arg
,
168 struct bin_emulation_xfer_struct bin_aix5_emulation
=
172 ar_emul_aix5_replace
,
173 ar_emul_default_create
,
174 ar_emul_aix_parse_arg
,