]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - binutils/emul_aix.c
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / binutils / emul_aix.c
CommitLineData
eb1e0e80 1/* Binutils emulation layer.
250d07de 2 Copyright (C) 2002-2021 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>. */
13485ea2 30/* FIXME: write only variable. */
b34976b6 31static bfd_boolean big_archive = TRUE;
eb1e0e80
NC
32
33/* Whether to include 32 bit objects. */
b34976b6 34static bfd_boolean X32 = TRUE;
eb1e0e80
NC
35
36/* Whether to include 64 bit objects. */
b34976b6
AM
37static bfd_boolean X64 = FALSE;
38
eb1e0e80 39static void
2da42df6 40ar_emul_aix_usage (FILE *fp)
eb1e0e80
NC
41{
42 AR_EMUL_USAGE_PRINT_OPTION_HEADER (fp);
43 /* xgettext:c-format */
44 fprintf (fp, _(" [-g] - 32 bit small archive\n"));
45 fprintf (fp, _(" [-X32] - ignores 64 bit objects\n"));
46 fprintf (fp, _(" [-X64] - ignores 32 bit objects\n"));
47 fprintf (fp, _(" [-X32_64] - accepts 32 and 64 bit objects\n"));
48}
49
b34976b6 50static bfd_boolean
13485ea2 51check_aix (bfd *try_bfd)
eb1e0e80 52{
6d00b590
AM
53 extern const bfd_target rs6000_xcoff_vec;
54 extern const bfd_target rs6000_xcoff64_vec;
55 extern const bfd_target rs6000_xcoff64_aix_vec;
eb1e0e80 56
13485ea2 57 if (bfd_check_format (try_bfd, bfd_object))
eb1e0e80 58 {
6d00b590 59 if (!X32 && try_bfd->xvec == &rs6000_xcoff_vec)
13485ea2 60 return FALSE;
eb1e0e80 61
6d00b590
AM
62 if (!X64 && (try_bfd->xvec == &rs6000_xcoff64_vec
63 || try_bfd->xvec == &rs6000_xcoff64_aix_vec))
13485ea2
AM
64 return FALSE;
65 }
b34976b6 66 return TRUE;
eb1e0e80
NC
67}
68
b34976b6 69static bfd_boolean
f3016d6c 70ar_emul_aix_append (bfd **after_bfd, bfd *new_bfd,
a2478677 71 bfd_boolean verbose, bfd_boolean flatten)
eb1e0e80 72{
13485ea2 73 return do_ar_emul_append (after_bfd, new_bfd, verbose, flatten, check_aix);
eb1e0e80
NC
74}
75
b34976b6 76static bfd_boolean
f3016d6c 77ar_emul_aix_replace (bfd **after_bfd, bfd *new_bfd,
a2478677 78 bfd_boolean verbose)
eb1e0e80 79{
13485ea2
AM
80 if (!check_aix (new_bfd))
81 return FALSE;
82
f3016d6c 83 AR_EMUL_REPLACE_PRINT_VERBOSE (verbose, bfd_get_filename (new_bfd));
13485ea2
AM
84
85 new_bfd->archive_next = *after_bfd;
86 *after_bfd = new_bfd;
87
88 return TRUE;
eb1e0e80
NC
89}
90
b34976b6 91static bfd_boolean
2da42df6 92ar_emul_aix_parse_arg (char *arg)
eb1e0e80 93{
0112cd26 94 if (CONST_STRNEQ (arg, "-X32_64"))
eb1e0e80 95 {
b34976b6
AM
96 big_archive = TRUE;
97 X32 = TRUE;
98 X64 = TRUE;
eb1e0e80 99 }
0112cd26 100 else if (CONST_STRNEQ (arg, "-X32"))
eb1e0e80 101 {
b34976b6
AM
102 big_archive = TRUE;
103 X32 = TRUE;
104 X64 = FALSE;
eb1e0e80 105 }
0112cd26 106 else if (CONST_STRNEQ (arg, "-X64"))
eb1e0e80 107 {
b34976b6
AM
108 big_archive = TRUE;
109 X32 = FALSE;
110 X64 = TRUE;
eb1e0e80 111 }
0112cd26 112 else if (CONST_STRNEQ (arg, "-g"))
eb1e0e80 113 {
b34976b6
AM
114 big_archive = FALSE;
115 X32 = TRUE;
116 X64 = FALSE;
eb1e0e80
NC
117 }
118 else
b34976b6 119 return FALSE;
eb1e0e80 120
b34976b6 121 return TRUE;
eb1e0e80
NC
122}
123
26044998 124struct bin_emulation_xfer_struct bin_aix_emulation =
eb1e0e80
NC
125{
126 ar_emul_aix_usage,
127 ar_emul_aix_append,
128 ar_emul_aix_replace,
eb1e0e80
NC
129 ar_emul_aix_parse_arg,
130};