1 /* Binutils emulation layer.
2 Copyright 2002, 2003, 2005, 2007, 2008, 2010
3 Free Software Foundation, Inc.
4 Written by Tom Rix, Red Hat Inc.
6 This file is part of GNU Binutils.
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
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
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.
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
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
25 extern bin_emulation_xfer_type bin_dummy_emulation
;
28 ar_emul_usage (FILE *fp
)
30 if (bin_dummy_emulation
.ar_usage
)
31 bin_dummy_emulation
.ar_usage (fp
);
35 ar_emul_default_usage (FILE *fp
)
37 AR_EMUL_USAGE_PRINT_OPTION_HEADER (fp
);
38 /* xgettext:c-format */
39 fprintf (fp
, _(" No emulation specific options\n"));
43 ar_emul_append (bfd
**after_bfd
, char *file_name
, const char *target
,
44 bfd_boolean verbose
, bfd_boolean flatten
)
46 if (bin_dummy_emulation
.ar_append
)
47 return bin_dummy_emulation
.ar_append (after_bfd
, file_name
, target
,
54 any_ok (bfd
*new_bfd ATTRIBUTE_UNUSED
)
60 do_ar_emul_append (bfd
**after_bfd
, bfd
*new_bfd
,
61 bfd_boolean verbose
, bfd_boolean flatten
,
62 bfd_boolean (*check
) (bfd
*))
64 /* When flattening, add the members of an archive instead of the
66 if (flatten
&& bfd_check_format (new_bfd
, bfd_archive
))
69 bfd_boolean added
= FALSE
;
71 for (elt
= bfd_openr_next_archived_file (new_bfd
, NULL
);
73 elt
= bfd_openr_next_archived_file (new_bfd
, elt
))
75 if (do_ar_emul_append (after_bfd
, elt
, verbose
, TRUE
, check
))
78 after_bfd
= &((*after_bfd
)->archive_next
);
88 AR_EMUL_APPEND_PRINT_VERBOSE (verbose
, new_bfd
->filename
);
90 new_bfd
->archive_next
= *after_bfd
;
97 ar_emul_default_append (bfd
**after_bfd
, char *file_name
,
98 const char *target
, bfd_boolean verbose
,
103 new_bfd
= bfd_openr (file_name
, target
);
104 AR_EMUL_ELEMENT_CHECK (new_bfd
, file_name
);
105 return do_ar_emul_append (after_bfd
, new_bfd
, verbose
, flatten
, any_ok
);
109 ar_emul_replace (bfd
**after_bfd
, char *file_name
, const char *target
,
112 if (bin_dummy_emulation
.ar_replace
)
113 return bin_dummy_emulation
.ar_replace (after_bfd
, file_name
,
120 ar_emul_default_replace (bfd
**after_bfd
, char *file_name
,
121 const char *target
, bfd_boolean verbose
)
125 new_bfd
= bfd_openr (file_name
, target
);
126 AR_EMUL_ELEMENT_CHECK (new_bfd
, file_name
);
128 AR_EMUL_REPLACE_PRINT_VERBOSE (verbose
, file_name
);
130 new_bfd
->archive_next
= *after_bfd
;
131 *after_bfd
= new_bfd
;
137 ar_emul_parse_arg (char *arg
)
139 if (bin_dummy_emulation
.ar_parse_arg
)
140 return bin_dummy_emulation
.ar_parse_arg (arg
);
146 ar_emul_default_parse_arg (char *arg ATTRIBUTE_UNUSED
)