ld: elfvers tests: support symbol prefixed targets
[deliverable/binutils-gdb.git] / binutils / emul_aix.c
CommitLineData
eb1e0e80 1/* Binutils emulation layer.
aa820537 2 Copyright 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
ad94be02 3 Written by Tom Rix, Red Hat Inc.
eb1e0e80
NC
4
5 This file is part of GNU Binutils.
6
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
32866df7 9 the Free Software Foundation; either version 3 of the License, or
eb1e0e80
NC
10 (at your option) any later version.
11
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.
16
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
32866df7
NC
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 MA 02110-1301, USA. */
eb1e0e80
NC
21
22#include "binemul.h"
23#include "bfdlink.h"
24#include "coff/internal.h"
25#include "coff/xcoff.h"
26#include "libcoff.h"
27#include "libxcoff.h"
28
29/* Default to <bigaf>. */
b34976b6 30static bfd_boolean big_archive = TRUE;
eb1e0e80
NC
31
32/* Whether to include 32 bit objects. */
b34976b6 33static bfd_boolean X32 = TRUE;
eb1e0e80
NC
34
35/* Whether to include 64 bit objects. */
b34976b6
AM
36static bfd_boolean X64 = FALSE;
37
eb1e0e80 38static void
2da42df6 39ar_emul_aix_usage (FILE *fp)
eb1e0e80
NC
40{
41 AR_EMUL_USAGE_PRINT_OPTION_HEADER (fp);
42 /* xgettext:c-format */
43 fprintf (fp, _(" [-g] - 32 bit small archive\n"));
44 fprintf (fp, _(" [-X32] - ignores 64 bit objects\n"));
45 fprintf (fp, _(" [-X64] - ignores 32 bit objects\n"));
46 fprintf (fp, _(" [-X32_64] - accepts 32 and 64 bit objects\n"));
47}
48
b34976b6 49static bfd_boolean
a8da6403
NC
50ar_emul_aix_internal (bfd ** after_bfd,
51 char * file_name,
52 bfd_boolean verbose,
53 const char * target_name,
54 bfd_boolean is_append,
55 bfd_boolean flatten ATTRIBUTE_UNUSED)
eb1e0e80
NC
56{
57 bfd *temp;
58 bfd *try_bfd;
59
60 temp = *after_bfd;
61
62 /* Try 64 bit. */
63 try_bfd = bfd_openr (file_name, target_name);
64
65 /* Failed or the object is possibly 32 bit. */
66 if (NULL == try_bfd || ! bfd_check_format (try_bfd, bfd_object))
67 try_bfd = bfd_openr (file_name, "aixcoff-rs6000");
68
69 AR_EMUL_ELEMENT_CHECK (try_bfd, file_name);
70
71 if (bfd_xcoff_is_xcoff64 (try_bfd) && (! X64))
b34976b6 72 return FALSE;
eb1e0e80 73
26044998 74 if (bfd_xcoff_is_xcoff32 (try_bfd)
eb1e0e80 75 && bfd_check_format (try_bfd, bfd_object) && (! X32))
b34976b6 76 return FALSE;
eb1e0e80
NC
77
78 if (is_append)
79 {
80 AR_EMUL_APPEND_PRINT_VERBOSE (verbose, file_name);
81 }
82 else
83 {
84 AR_EMUL_REPLACE_PRINT_VERBOSE (verbose, file_name);
85 }
86
87 *after_bfd = try_bfd;
c3de112b 88 (*after_bfd)->archive_next = temp;
eb1e0e80 89
b34976b6 90 return TRUE;
eb1e0e80
NC
91}
92
93
b34976b6 94static bfd_boolean
a2478677
L
95ar_emul_aix_append (bfd **after_bfd, char *file_name, const char *target,
96 bfd_boolean verbose, bfd_boolean flatten)
eb1e0e80 97{
a2478677
L
98 if (target)
99 non_fatal (_("target `%s' ignored."), target);
eb1e0e80 100 return ar_emul_aix_internal (after_bfd, file_name, verbose,
a8da6403 101 "aixcoff64-rs6000", TRUE, flatten);
eb1e0e80
NC
102}
103
b34976b6 104static bfd_boolean
a2478677
L
105ar_emul_aix5_append (bfd **after_bfd, char *file_name, const char *target,
106 bfd_boolean verbose, bfd_boolean flatten)
eb1e0e80 107{
a2478677
L
108 if (target)
109 non_fatal (_("target `%s' ignored."), target);
eb1e0e80 110 return ar_emul_aix_internal (after_bfd, file_name, verbose,
a8da6403 111 "aix5coff64-rs6000", TRUE, flatten);
eb1e0e80
NC
112}
113
b34976b6 114static bfd_boolean
a2478677
L
115ar_emul_aix_replace (bfd **after_bfd, char *file_name, const char *target,
116 bfd_boolean verbose)
eb1e0e80 117{
a2478677
L
118 if (target)
119 non_fatal (_("target `%s' ignored."), target);
eb1e0e80 120 return ar_emul_aix_internal (after_bfd, file_name, verbose,
a8da6403 121 "aixcoff64-rs6000", FALSE, FALSE);
eb1e0e80
NC
122}
123
b34976b6 124static bfd_boolean
a2478677
L
125ar_emul_aix5_replace (bfd **after_bfd, char *file_name,
126 const char *target, bfd_boolean verbose)
eb1e0e80 127{
a2478677
L
128 if (target)
129 non_fatal (_("target `%s' ignored."), target);
eb1e0e80 130 return ar_emul_aix_internal (after_bfd, file_name, verbose,
a8da6403 131 "aix5coff64-rs6000", FALSE, FALSE);
eb1e0e80
NC
132}
133
b34976b6 134static bfd_boolean
2da42df6 135ar_emul_aix_parse_arg (char *arg)
eb1e0e80 136{
0112cd26 137 if (CONST_STRNEQ (arg, "-X32_64"))
eb1e0e80 138 {
b34976b6
AM
139 big_archive = TRUE;
140 X32 = TRUE;
141 X64 = TRUE;
eb1e0e80 142 }
0112cd26 143 else if (CONST_STRNEQ (arg, "-X32"))
eb1e0e80 144 {
b34976b6
AM
145 big_archive = TRUE;
146 X32 = TRUE;
147 X64 = FALSE;
eb1e0e80 148 }
0112cd26 149 else if (CONST_STRNEQ (arg, "-X64"))
eb1e0e80 150 {
b34976b6
AM
151 big_archive = TRUE;
152 X32 = FALSE;
153 X64 = TRUE;
eb1e0e80 154 }
0112cd26 155 else if (CONST_STRNEQ (arg, "-g"))
eb1e0e80 156 {
b34976b6
AM
157 big_archive = FALSE;
158 X32 = TRUE;
159 X64 = FALSE;
eb1e0e80
NC
160 }
161 else
b34976b6 162 return FALSE;
eb1e0e80 163
b34976b6 164 return TRUE;
eb1e0e80
NC
165}
166
26044998 167struct bin_emulation_xfer_struct bin_aix_emulation =
eb1e0e80
NC
168{
169 ar_emul_aix_usage,
170 ar_emul_aix_append,
171 ar_emul_aix_replace,
eb1e0e80
NC
172 ar_emul_aix_parse_arg,
173};
174
26044998 175struct bin_emulation_xfer_struct bin_aix5_emulation =
eb1e0e80
NC
176{
177 ar_emul_aix_usage,
178 ar_emul_aix5_append,
179 ar_emul_aix5_replace,
eb1e0e80
NC
180 ar_emul_aix_parse_arg,
181};
This page took 0.34716 seconds and 4 git commands to generate.