aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2002-03-18 12:46:27 +0000
committerNick Clifton <nickc@redhat.com>2002-03-18 12:46:27 +0000
commiteb1e0e807ac769f624181bc44acdcd79d866949d (patch)
treeddd5259b49eb8431b5e2bd8f9f84e6ea7b0e5cc3 /binutils
parenta1c259a138165fa878430144c8658093d6ac2256 (diff)
downloadgdb-eb1e0e807ac769f624181bc44acdcd79d866949d.zip
gdb-eb1e0e807ac769f624181bc44acdcd79d866949d.tar.gz
gdb-eb1e0e807ac769f624181bc44acdcd79d866949d.tar.bz2
Add AIX 64 shared library support and emulation layer for binutils
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog16
-rw-r--r--binutils/Makefile.am19
-rw-r--r--binutils/Makefile.in36
-rw-r--r--binutils/ar.c90
-rw-r--r--binutils/binemul.c165
-rw-r--r--binutils/binemul.h64
-rwxr-xr-xbinutils/configure22
-rw-r--r--binutils/configure.in20
-rw-r--r--binutils/configure.tgt26
-rw-r--r--binutils/doc/Makefile.in4
-rw-r--r--binutils/emul_aix.c212
-rw-r--r--binutils/emul_vanilla.c30
12 files changed, 628 insertions, 76 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index bc6de4b..e2ddf93 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,19 @@
+2002-03-18 Tom Rix <trix@redhat.com>
+
+ * Makefile.am: Add binutils emulation support.
+ * configure.in: Same.
+ * configure.tgt: New file. Same.
+ * ar.c (main): Use ar_emul_parse_arg.
+ (usage): Use ar_emul_usage.
+ (replace_members): Use ar_emul_replace, ar_emul_append.
+ * binemul.c: New file. Define the binutils emulation
+ layer. Define default methods.
+ * binemul.h: New file. Binutils emulation layer header file.
+ * emul_aix.c: New file. AIX binutils emulation.
+ * emul_vanilla.c: New file. Default binutils emulation.
+ * Makefile.in: Regenerate.
+ * configure: Same.
+
2002-03-18 Nick Clifton <nickc@cambridge.redhat.com>
* po/fr.po: Updated version.
diff --git a/binutils/Makefile.am b/binutils/Makefile.am
index 94369cd..6352cb1 100644
--- a/binutils/Makefile.am
+++ b/binutils/Makefile.am
@@ -62,7 +62,7 @@ noinst_PROGRAMS = $(NM_PROG) $(STRIP_PROG) $(DEMANGLER_PROG)
EXTRA_PROGRAMS = $(NLMCONV_PROG) srconv sysdump coffdump $(DLLTOOL_PROG) $(WINDRES_PROG) $(DLLWRAP_PROG)
-# Stuff that goes in tooldir/ if appropriate
+# Stuff that goes in tooldir/ if appropriate.
TOOL_PROGS = nm-new strip-new ar ranlib dlltool
BASEDIR = $(srcdir)/..
@@ -71,10 +71,15 @@ INCDIR = $(BASEDIR)/include
MKDEP = gcc -MM
-INCLUDES = -D_GNU_SOURCE -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR) @HDEFINES@ -I$(srcdir)/../intl -I../intl -DLOCALEDIR="\"$(prefix)/share/locale\""
+INCLUDES = -D_GNU_SOURCE \
+ -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR) \
+ @HDEFINES@ \
+ -I$(srcdir)/../intl -I../intl \
+ -DLOCALEDIR="\"$(prefix)/share/locale\"" \
+ -Dbin_dummy_emulation=$(EMULATION_VECTOR)
HFILES = arsup.h bucomm.h budbg.h coffgrok.h debug.h nlmconv.h dlltool.h \
- windres.h winduni.h
+ windres.h winduni.h binemul.h
GENERATED_HFILES = arparse.h sysroff.h sysinfo.h defparse.h rcparse.h
@@ -84,7 +89,7 @@ CFILES = addr2line.c ar.c arsup.c bucomm.c coffdump.c coffgrok.c debug.c \
objcopy.c objdump.c prdbg.c rdcoff.c rddbg.c size.c srconv.c \
stabs.c strings.c sysdump.c version.c wrstabs.c \
windres.c resrc.c rescoff.c resbin.c winduni.c readelf.c \
- resres.c dllwrap.c rename.c
+ resres.c dllwrap.c rename.c binemul.c emul_$(EMULATION).c
GENERATED_CFILES = \
underscore.c arparse.c arlex.c sysroff.c sysinfo.c syslex.c \
@@ -183,10 +188,12 @@ cplus-dem.o: $(BASEDIR)/libiberty/cplus-dem.c $(INCDIR)/getopt.h Makefile
cxxfilt_SOURCES =
cxxfilt_LDADD = cplus-dem.o underscore.o $(LIBIBERTY) $(INTLLIBS)
-ar_SOURCES = arparse.y arlex.l ar.c not-ranlib.c arsup.c rename.c $(BULIBS)
+ar_SOURCES = arparse.y arlex.l ar.c not-ranlib.c arsup.c rename.c binemul.c \
+ emul_$(EMULATION).c $(BULIBS)
ar_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(INTLLIBS)
-ranlib_SOURCES = ar.c is-ranlib.c arparse.y arlex.l arsup.c rename.c $(BULIBS)
+ranlib_SOURCES = ar.c is-ranlib.c arparse.y arlex.l arsup.c rename.c \
+ binemul.c emul_$(EMULATION).c $(BULIBS)
ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(INTLLIBS)
addr2line_SOURCES = addr2line.c $(BULIBS)
diff --git a/binutils/Makefile.in b/binutils/Makefile.in
index 3bda86e..b5aaeff 100644
--- a/binutils/Makefile.in
+++ b/binutils/Makefile.in
@@ -80,6 +80,8 @@ DATADIRNAME = @DATADIRNAME@
DEMANGLER_NAME = @DEMANGLER_NAME@
DLLTOOL = @DLLTOOL@
DLLTOOL_DEFS = @DLLTOOL_DEFS@
+EMULATION = @EMULATION@
+EMULATION_VECTOR = @EMULATION_VECTOR@
EXEEXT = @EXEEXT@
GCJ = @GCJ@
GCJFLAGS = @GCJFLAGS@
@@ -169,7 +171,7 @@ noinst_PROGRAMS = $(NM_PROG) $(STRIP_PROG) $(DEMANGLER_PROG)
EXTRA_PROGRAMS = $(NLMCONV_PROG) srconv sysdump coffdump $(DLLTOOL_PROG) $(WINDRES_PROG) $(DLLWRAP_PROG)
-# Stuff that goes in tooldir/ if appropriate
+# Stuff that goes in tooldir/ if appropriate.
TOOL_PROGS = nm-new strip-new ar ranlib dlltool
BASEDIR = $(srcdir)/..
@@ -178,10 +180,16 @@ INCDIR = $(BASEDIR)/include
MKDEP = gcc -MM
-INCLUDES = -D_GNU_SOURCE -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR) @HDEFINES@ -I$(srcdir)/../intl -I../intl -DLOCALEDIR="\"$(prefix)/share/locale\""
+INCLUDES = -D_GNU_SOURCE \
+ -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR) \
+ @HDEFINES@ \
+ -I$(srcdir)/../intl -I../intl \
+ -DLOCALEDIR="\"$(prefix)/share/locale\"" \
+ -Dbin_dummy_emulation=$(EMULATION_VECTOR)
+
HFILES = arsup.h bucomm.h budbg.h coffgrok.h debug.h nlmconv.h dlltool.h \
- windres.h winduni.h
+ windres.h winduni.h binemul.h
GENERATED_HFILES = arparse.h sysroff.h sysinfo.h defparse.h rcparse.h
@@ -192,7 +200,7 @@ CFILES = addr2line.c ar.c arsup.c bucomm.c coffdump.c coffgrok.c debug.c \
objcopy.c objdump.c prdbg.c rdcoff.c rddbg.c size.c srconv.c \
stabs.c strings.c sysdump.c version.c wrstabs.c \
windres.c resrc.c rescoff.c resbin.c winduni.c readelf.c \
- resres.c dllwrap.c rename.c
+ resres.c dllwrap.c rename.c binemul.c emul_$(EMULATION).c
GENERATED_CFILES = \
@@ -260,10 +268,14 @@ objdump_LDADD = $(OPCODES) $(BFDLIB) $(LIBIBERTY) $(INTLLIBS)
cxxfilt_SOURCES =
cxxfilt_LDADD = cplus-dem.o underscore.o $(LIBIBERTY) $(INTLLIBS)
-ar_SOURCES = arparse.y arlex.l ar.c not-ranlib.c arsup.c rename.c $(BULIBS)
+ar_SOURCES = arparse.y arlex.l ar.c not-ranlib.c arsup.c rename.c binemul.c \
+ emul_$(EMULATION).c $(BULIBS)
+
ar_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(INTLLIBS)
-ranlib_SOURCES = ar.c is-ranlib.c arparse.y arlex.l arsup.c rename.c $(BULIBS)
+ranlib_SOURCES = ar.c is-ranlib.c arparse.y arlex.l arsup.c rename.c \
+ binemul.c emul_$(EMULATION).c $(BULIBS)
+
ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(INTLLIBS)
addr2line_SOURCES = addr2line.c $(BULIBS)
@@ -360,8 +372,9 @@ objdump_DEPENDENCIES = ../opcodes/libopcodes.la ../bfd/libbfd.la \
../libiberty/libiberty.a
objdump_LDFLAGS =
ar_OBJECTS = arparse.$(OBJEXT) arlex.$(OBJEXT) ar.$(OBJEXT) \
-not-ranlib.$(OBJEXT) arsup.$(OBJEXT) rename.$(OBJEXT) bucomm.$(OBJEXT) \
-version.$(OBJEXT) filemode.$(OBJEXT)
+not-ranlib.$(OBJEXT) arsup.$(OBJEXT) rename.$(OBJEXT) binemul.$(OBJEXT) \
+emul_$(EMULATION).$(OBJEXT) bucomm.$(OBJEXT) version.$(OBJEXT) \
+filemode.$(OBJEXT)
ar_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
ar_LDFLAGS =
strings_OBJECTS = strings.$(OBJEXT) bucomm.$(OBJEXT) version.$(OBJEXT) \
@@ -370,8 +383,9 @@ strings_LDADD = $(LDADD)
strings_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
strings_LDFLAGS =
ranlib_OBJECTS = ar.$(OBJEXT) is-ranlib.$(OBJEXT) arparse.$(OBJEXT) \
-arlex.$(OBJEXT) arsup.$(OBJEXT) rename.$(OBJEXT) bucomm.$(OBJEXT) \
-version.$(OBJEXT) filemode.$(OBJEXT)
+arlex.$(OBJEXT) arsup.$(OBJEXT) rename.$(OBJEXT) binemul.$(OBJEXT) \
+emul_$(EMULATION).$(OBJEXT) bucomm.$(OBJEXT) version.$(OBJEXT) \
+filemode.$(OBJEXT)
ranlib_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a
ranlib_LDFLAGS =
objcopy_OBJECTS = objcopy.$(OBJEXT) not-strip.$(OBJEXT) \
@@ -421,7 +435,7 @@ configure.in deflex.c defparse.c nlmheader.c rclex.c rcparse.c
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-TAR = tar
+TAR = gtar
GZIP_ENV = --best
SOURCES = $(nlmconv_SOURCES) $(srconv_SOURCES) $(sysdump_SOURCES) $(coffdump_SOURCES) $(dlltool_SOURCES) $(windres_SOURCES) $(dllwrap_SOURCES) $(size_SOURCES) $(objdump_SOURCES) $(ar_SOURCES) $(strings_SOURCES) $(ranlib_SOURCES) $(objcopy_SOURCES) $(addr2line_SOURCES) $(readelf_SOURCES) $(nm_new_SOURCES) $(strip_new_SOURCES) $(cxxfilt_SOURCES)
OBJECTS = $(nlmconv_OBJECTS) $(srconv_OBJECTS) $(sysdump_OBJECTS) $(coffdump_OBJECTS) $(dlltool_OBJECTS) $(windres_OBJECTS) $(dllwrap_OBJECTS) $(size_OBJECTS) $(objdump_OBJECTS) $(ar_OBJECTS) $(strings_OBJECTS) $(ranlib_OBJECTS) $(objcopy_OBJECTS) $(addr2line_OBJECTS) $(readelf_OBJECTS) $(nm_new_OBJECTS) $(strip_new_OBJECTS) $(cxxfilt_OBJECTS)
diff --git a/binutils/ar.c b/binutils/ar.c
index 92d9b35..8876330 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -3,29 +3,29 @@
2001, 2002
Free Software Foundation, Inc.
-This file is part of GNU Binutils.
+ This file is part of GNU Binutils.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*
Bugs: should use getopt the way tar does (complete w/optional -) and
should have long options too. GNU ar used to check file against filesystem
in quick_update and replace operations (would check mtime). Doesn't warn
when name truncated. No way to specify pos_end. Error messages should be
- more consistant.
-*/
+ more consistant. */
+
#include "bfd.h"
#include "libiberty.h"
#include "progress.h"
@@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "libbfd.h"
#include "arsup.h"
#include "filenames.h"
+#include "binemul.h"
#include <sys/stat.h>
#ifdef __GO32___
@@ -251,7 +252,7 @@ usage (help)
if (! is_ranlib)
{
/* xgettext:c-format */
- fprintf (s, _("Usage: %s [-X32_64] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file file...\n"),
+ fprintf (s, _("Usage: %s [emulation options] [-]{dmpqrstx}[abcfilNoPsSuvV] [member-name] [count] archive-file file...\n"),
program_name);
/* xgettext:c-format */
fprintf (s, _(" %s -M [<mri-script]\n"), program_name);
@@ -277,7 +278,8 @@ usage (help)
fprintf (s, _(" [S] - do not build a symbol table\n"));
fprintf (s, _(" [v] - be verbose\n"));
fprintf (s, _(" [V] - display the version number\n"));
- fprintf (s, _(" [-X32_64] - (ignored)\n"));
+
+ ar_emul_usage (s);
}
else
{
@@ -383,6 +385,7 @@ main (argc, argv)
int file_count;
char *inarch_filename;
int show_version;
+ int i;
#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
setlocale (LC_MESSAGES, "");
@@ -444,17 +447,12 @@ main (argc, argv)
xatexit (remove_output);
- /* Ignored for (partial) AIX compatibility. On AIX,
- the -X option can be used to ignore certain kinds
- of object files in the archive (the 64-bit objects
- or the 32-bit objects). GNU ar always looks at all
- kinds of objects in an archive. */
- while (argc > 1 && strcmp (argv[1], "-X32_64") == 0)
- {
- argv++;
- argc--;
- }
-
+ for (i = 1; i < argc; i++)
+ if (! ar_emul_parse_arg (argv[i]))
+ break;
+ argv += (i - 1);
+ argc -= (i - 1);
+
if (is_ranlib)
{
boolean touch = false;
@@ -1341,24 +1339,13 @@ replace_members (arch, files_to_move, quick)
after_bfd = get_pos_bfd (&arch->next, pos_after,
current->filename);
- temp = *after_bfd;
-
- *after_bfd = bfd_openr (*files_to_move, NULL);
- if (*after_bfd == (bfd *) NULL)
+ if (ar_emul_replace (after_bfd, *files_to_move,
+ verbose))
{
- bfd_fatal (*files_to_move);
+ /* Snip out this entry from the chain. */
+ *current_ptr = (*current_ptr)->next;
+ changed = true;
}
- (*after_bfd)->next = temp;
-
- /* snip out this entry from the chain */
- *current_ptr = (*current_ptr)->next;
-
- if (verbose)
- {
- printf ("r - %s\n", *files_to_move);
- }
-
- changed = true;
goto next_file;
}
@@ -1367,22 +1354,9 @@ replace_members (arch, files_to_move, quick)
}
/* Add to the end of the archive. */
-
after_bfd = get_pos_bfd (&arch->next, pos_end, NULL);
- temp = *after_bfd;
- *after_bfd = bfd_openr (*files_to_move, NULL);
- if (*after_bfd == (bfd *) NULL)
- {
- bfd_fatal (*files_to_move);
- }
- if (verbose)
- {
- printf ("a - %s\n", *files_to_move);
- }
-
- (*after_bfd)->next = temp;
-
- changed = true;
+ if (ar_emul_append (after_bfd, *files_to_move, verbose))
+ changed = true;
next_file:;
diff --git a/binutils/binemul.c b/binutils/binemul.c
new file mode 100644
index 0000000..2aad20d
--- /dev/null
+++ b/binutils/binemul.c
@@ -0,0 +1,165 @@
+/* Binutils emulation layer.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Written by Tom Rix, Redhat.
+
+ This file is part of GNU Binutils.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "binemul.h"
+
+extern bin_emulation_xfer_type bin_dummy_emulation;
+
+void
+ar_emul_usage (fp)
+ FILE *fp;
+{
+ if (bin_dummy_emulation.ar_usage)
+ bin_dummy_emulation.ar_usage (fp);
+}
+
+void
+ar_emul_default_usage (fp)
+ FILE *fp;
+{
+ AR_EMUL_USAGE_PRINT_OPTION_HEADER (fp);
+ /* xgettext:c-format */
+ fprintf (fp, _(" No emulation specific options\n"));
+}
+
+boolean
+ar_emul_append (after_bfd, file_name, verbose)
+ bfd **after_bfd;
+ char *file_name;
+ boolean verbose;
+{
+ if (bin_dummy_emulation.ar_append)
+ return bin_dummy_emulation.ar_append (after_bfd, file_name, verbose);
+
+ return false;
+}
+
+boolean
+ar_emul_default_append (after_bfd, file_name, verbose)
+ bfd **after_bfd;
+ char *file_name;
+ boolean verbose;
+{
+ bfd *temp;
+
+ temp = *after_bfd;
+ *after_bfd = bfd_openr (file_name, NULL);
+
+ AR_EMUL_ELEMENT_CHECK (*after_bfd, file_name);
+ AR_EMUL_APPEND_PRINT_VERBOSE (verbose, file_name);
+
+ (*after_bfd)->next = temp;
+
+ return true;
+}
+
+boolean
+ar_emul_replace (after_bfd, file_name, verbose)
+ bfd **after_bfd;
+ char *file_name;
+ boolean verbose;
+{
+ if (bin_dummy_emulation.ar_replace)
+ return bin_dummy_emulation.ar_replace (after_bfd, file_name, verbose);
+
+ return false;
+}
+
+boolean
+ar_emul_default_replace (after_bfd, file_name, verbose)
+ bfd **after_bfd;
+ char *file_name;
+ boolean verbose;
+{
+ bfd *temp;
+
+ temp = *after_bfd;
+ *after_bfd = bfd_openr (file_name, NULL);
+
+ AR_EMUL_ELEMENT_CHECK (*after_bfd, file_name);
+ AR_EMUL_REPLACE_PRINT_VERBOSE (verbose, file_name);
+
+ (*after_bfd)->next = temp;
+
+ return true;
+}
+
+boolean
+ar_emul_create (abfd_out, archive_file_name, file_name)
+ bfd **abfd_out;
+ char *archive_file_name;
+ char *file_name;
+{
+ if (bin_dummy_emulation.ar_create)
+ return bin_dummy_emulation.ar_create (abfd_out, archive_file_name,
+ file_name);
+
+ return false;
+}
+
+boolean
+ar_emul_default_create (abfd_out, archive_file_name, file_name)
+ bfd **abfd_out;
+ char *archive_file_name;
+ char *file_name;
+{
+ char *target = NULL;
+
+ /* Try to figure out the target to use for the archive from the
+ first object on the list. */
+ if (file_name != NULL)
+ {
+ bfd *obj;
+
+ obj = bfd_openr (file_name, NULL);
+ if (obj != NULL)
+ {
+ if (bfd_check_format (obj, bfd_object))
+ target = bfd_get_target (obj);
+ (void) bfd_close (obj);
+ }
+ }
+
+ /* Create an empty archive. */
+ *abfd_out = bfd_openw (archive_file_name, target);
+ if (*abfd_out == NULL
+ || ! bfd_set_format (*abfd_out, bfd_archive)
+ || ! bfd_close (*abfd_out))
+ bfd_fatal (archive_file_name);
+
+ return true;
+}
+
+boolean
+ar_emul_parse_arg (arg)
+ char *arg;
+{
+ if (bin_dummy_emulation.ar_parse_arg)
+ return bin_dummy_emulation.ar_parse_arg (arg);
+
+ return false;
+}
+
+boolean
+ar_emul_default_parse_arg (arg)
+ char *arg;
+{
+ return false;
+}
diff --git a/binutils/binemul.h b/binutils/binemul.h
new file mode 100644
index 0000000..412653d
--- /dev/null
+++ b/binutils/binemul.h
@@ -0,0 +1,64 @@
+/* Binutils emulation layer.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Written by Tom Rix, Redhat.
+
+ This file is part of GNU Binutils.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifndef BINEMUL_H
+#define BINEMUL_H
+
+#include "bfd.h"
+#include "bucomm.h"
+
+extern void ar_emul_usage PARAMS ((FILE *));
+extern void ar_emul_default_usage PARAMS ((FILE *));
+extern boolean ar_emul_append PARAMS ((bfd **, char *, boolean));
+extern boolean ar_emul_default_append PARAMS ((bfd **, char *, boolean));
+extern boolean ar_emul_replace PARAMS ((bfd **, char *, boolean));
+extern boolean ar_emul_default_replace PARAMS ((bfd **, char *, boolean));
+extern boolean ar_emul_create PARAMS ((bfd **, char *, char *));
+extern boolean ar_emul_default_create PARAMS ((bfd **, char *, char *));
+extern boolean ar_emul_parse_arg PARAMS ((char *));
+extern boolean ar_emul_default_parse_arg PARAMS ((char *));
+
+/* Macros for common output. */
+
+#define AR_EMUL_USAGE_PRINT_OPTION_HEADER(fp) \
+ /* xgettext:c-format */ \
+ fprintf (fp, _(" emulation options: \n"))
+
+#define AR_EMUL_ELEMENT_CHECK(abfd, file_name) \
+ do { if ((abfd) == (bfd *) NULL) bfd_fatal (file_name); } while (0)
+
+#define AR_EMUL_APPEND_PRINT_VERBOSE(verbose, file_name) \
+ do { if (verbose) printf ("a - %s\n", file_name); } while (0)
+
+#define AR_EMUL_REPLACE_PRINT_VERBOSE(verbose, file_name) \
+ do { if (verbose) printf ("r - %s\n", file_name); } while (0)
+
+typedef struct bin_emulation_xfer_struct
+{
+ /* Print out the extra options. */
+ void (* ar_usage) PARAMS ((FILE *fp));
+ boolean (* ar_append) PARAMS ((bfd **, char *, boolean));
+ boolean (* ar_replace) PARAMS ((bfd **, char *, boolean));
+ boolean (* ar_create) PARAMS ((bfd **, char *, char *));
+ boolean (* ar_parse_arg) PARAMS ((char *));
+}
+bin_emulation_xfer_type;
+
+#endif
diff --git a/binutils/configure b/binutils/configure
index 8d119d1..11cfd4e 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -5596,6 +5596,26 @@ else
fi
+# Emulation
+for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
+do
+ # Canonicalize the secondary target names.
+ result=`$ac_config_sub $targ_alias 2>/dev/null`
+ if test -n "$result"; then
+ targ=$result
+ else
+ targ=$targ_alias
+ fi
+
+ . ${srcdir}/configure.tgt
+
+ EMULATION=$targ_emul
+ EMULATION_VECTOR=$targ_emul_vector
+done
+
+
+
+
trap '' 1 2 15
cat > confcache <<\EOF
# This file is a shell script that caches the results of configure
@@ -5807,6 +5827,8 @@ s%@BUILD_DLLWRAP@%$BUILD_DLLWRAP%g
s%@BUILD_MISC@%$BUILD_MISC%g
s%@OBJDUMP_DEFS@%$OBJDUMP_DEFS%g
s%@UNDERSCORE@%$UNDERSCORE%g
+s%@EMULATION@%$EMULATION%g
+s%@EMULATION_VECTOR@%$EMULATION_VECTOR%g
CEOF
EOF
diff --git a/binutils/configure.in b/binutils/configure.in
index 42381bb..26a88f1 100644
--- a/binutils/configure.in
+++ b/binutils/configure.in
@@ -313,6 +313,26 @@ else
fi
AC_SUBST(UNDERSCORE)
+# Emulation
+for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
+do
+ # Canonicalize the secondary target names.
+ result=`$ac_config_sub $targ_alias 2>/dev/null`
+ if test -n "$result"; then
+ targ=$result
+ else
+ targ=$targ_alias
+ fi
+
+ . ${srcdir}/configure.tgt
+
+ EMULATION=$targ_emul
+ EMULATION_VECTOR=$targ_emul_vector
+done
+
+AC_SUBST(EMULATION)
+AC_SUBST(EMULATION_VECTOR)
+
AC_OUTPUT(Makefile doc/Makefile po/Makefile.in:po/Make-in,
[
case "x$CONFIG_FILES" in
diff --git a/binutils/configure.tgt b/binutils/configure.tgt
new file mode 100644
index 0000000..2d5ce2b
--- /dev/null
+++ b/binutils/configure.tgt
@@ -0,0 +1,26 @@
+# This is the binutils target specific file. This is invoked by the
+# autoconf generated configure script. Putting it in a separate shell
+# file lets us skip running autoconf when modifying target specific
+# information.
+
+# This file switches on the shell variable ${targ}, and sets the
+# following shell variables:
+# targ_emul name of emulation to use
+# targ_emul_vector name of vector to use
+
+case "${targ}" in
+ powerpc-*-aix5* | rs6000-*-aix5*)
+ targ_emul=aix
+ targ_emul_vector=bin_aix5_emulation
+ ;;
+
+ powerpc-*-aix4.3* | rs6000-*-aix4.3*)
+ targ_emul=aix
+ targ_emul_vector=bin_aix_emulation
+ ;;
+
+ *)
+ targ_emul=vanilla
+ targ_emul_vector=bin_vanilla_emulation
+ ;;
+esac
diff --git a/binutils/doc/Makefile.in b/binutils/doc/Makefile.in
index 5ac149f..294d739 100644
--- a/binutils/doc/Makefile.in
+++ b/binutils/doc/Makefile.in
@@ -81,6 +81,8 @@ DATADIRNAME = @DATADIRNAME@
DEMANGLER_NAME = @DEMANGLER_NAME@
DLLTOOL = @DLLTOOL@
DLLTOOL_DEFS = @DLLTOOL_DEFS@
+EMULATION = @EMULATION@
+EMULATION_VECTOR = @EMULATION_VECTOR@
EXEEXT = @EXEEXT@
EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@
GCJ = @GCJ@
@@ -175,7 +177,7 @@ DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-TAR = tar
+TAR = gtar
GZIP_ENV = --best
all: all-redirect
.SUFFIXES:
diff --git a/binutils/emul_aix.c b/binutils/emul_aix.c
new file mode 100644
index 0000000..fe3551e
--- /dev/null
+++ b/binutils/emul_aix.c
@@ -0,0 +1,212 @@
+/* Binutils emulation layer.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Written by Tom Rix, Redhat.
+
+ This file is part of GNU Binutils.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "binemul.h"
+#include "bfdlink.h"
+#include "coff/internal.h"
+#include "coff/xcoff.h"
+#include "libcoff.h"
+#include "libxcoff.h"
+
+/* Default to <bigaf>. */
+static boolean big_archive = true;
+
+/* Whether to include 32 bit objects. */
+static boolean X32 = true;
+
+/* Whether to include 64 bit objects. */
+static boolean X64 = false;
+
+static void ar_emul_aix_usage PARAMS ((FILE *));
+static boolean ar_emul_aix_append PARAMS ((bfd **, char *, boolean));
+static boolean ar_emul_aix5_append PARAMS ((bfd **, char *, boolean));
+static boolean ar_emul_aix_replace PARAMS ((bfd **, char *, boolean));
+static boolean ar_emul_aix5_replace PARAMS ((bfd **, char *, boolean));
+static boolean ar_emul_aix_parse_arg PARAMS ((char *));
+static boolean ar_emul_aix_internal PARAMS ((bfd **, char *, boolean,
+ const char *, boolean));
+
+static void
+ar_emul_aix_usage (fp)
+ FILE *fp;
+{
+ AR_EMUL_USAGE_PRINT_OPTION_HEADER (fp);
+ /* xgettext:c-format */
+ fprintf (fp, _(" [-g] - 32 bit small archive\n"));
+ fprintf (fp, _(" [-X32] - ignores 64 bit objects\n"));
+ fprintf (fp, _(" [-X64] - ignores 32 bit objects\n"));
+ fprintf (fp, _(" [-X32_64] - accepts 32 and 64 bit objects\n"));
+}
+
+static boolean
+ar_emul_aix_internal (after_bfd, file_name, verbose, target_name, is_append)
+ bfd **after_bfd;
+ char *file_name;
+ boolean verbose;
+ const char * target_name;
+ boolean is_append;
+{
+ bfd *temp;
+ bfd *try_bfd;
+
+ temp = *after_bfd;
+
+ /* Try 64 bit. */
+ try_bfd = bfd_openr (file_name, target_name);
+
+ /* Failed or the object is possibly 32 bit. */
+ if (NULL == try_bfd || ! bfd_check_format (try_bfd, bfd_object))
+ try_bfd = bfd_openr (file_name, "aixcoff-rs6000");
+
+ AR_EMUL_ELEMENT_CHECK (try_bfd, file_name);
+
+ if (bfd_xcoff_is_xcoff64 (try_bfd) && (! X64))
+ return false;
+
+ if (bfd_xcoff_is_xcoff32 (try_bfd)
+ && bfd_check_format (try_bfd, bfd_object) && (! X32))
+ return false;
+
+ if (is_append)
+ {
+ AR_EMUL_APPEND_PRINT_VERBOSE (verbose, file_name);
+ }
+ else
+ {
+ AR_EMUL_REPLACE_PRINT_VERBOSE (verbose, file_name);
+ }
+
+ *after_bfd = try_bfd;
+ (*after_bfd)->next = temp;
+
+ return true;
+}
+
+
+static boolean
+ar_emul_aix_append (after_bfd, file_name, verbose)
+ bfd **after_bfd;
+ char *file_name;
+ boolean verbose;
+{
+ return ar_emul_aix_internal (after_bfd, file_name, verbose,
+ "aixcoff64-rs6000", true);
+}
+
+static boolean
+ar_emul_aix5_append (after_bfd, file_name, verbose)
+ bfd **after_bfd;
+ char *file_name;
+ boolean verbose;
+{
+ return ar_emul_aix_internal (after_bfd, file_name, verbose,
+ "aix5coff64-rs6000", true);
+}
+
+static boolean
+ar_emul_aix_replace (after_bfd, file_name, verbose)
+ bfd **after_bfd;
+ char *file_name;
+ boolean verbose;
+{
+ return ar_emul_aix_internal (after_bfd, file_name, verbose,
+ "aixcoff64-rs6000", false);
+}
+
+static boolean
+ar_emul_aix5_replace (after_bfd, file_name, verbose)
+ bfd **after_bfd;
+ char *file_name;
+ boolean verbose;
+{
+ return ar_emul_aix_internal (after_bfd, file_name, verbose,
+ "aix5coff64-rs6000", false);
+}
+
+boolean
+ar_emul_aix_create (abfd_out, archive_file_name, file_name)
+ bfd **abfd_out;
+ char *archive_file_name;
+ char *file_name ATTRIBUTE_UNUSED;
+{
+ char *target = "aixcoff-rs6000";
+
+ /* Create an empty archive. */
+ *abfd_out = bfd_openw (archive_file_name, target);
+
+ if (*abfd_out == NULL)
+ bfd_fatal (archive_file_name);
+
+ /* set to small or big format. */
+ /* not done. */
+ return true;
+}
+
+static boolean
+ar_emul_aix_parse_arg (arg)
+ char *arg;
+{
+ if (strncmp (arg, "-X32_64", 6) == 0)
+ {
+ big_archive = true;
+ X32 = true;
+ X64 = true;
+ }
+ else if (strncmp (arg, "-X32", 3) == 0)
+ {
+ big_archive = true;
+ X32 = true;
+ X64 = false;
+ }
+ else if (strncmp (arg, "-X64", 3) == 0)
+ {
+ big_archive = true;
+ X32 = false;
+ X64 = true;
+ }
+ else if (strncmp (arg, "-g", 2) == 0)
+ {
+ big_archive = false;
+ X32 = true;
+ X64 = false;
+ }
+ else
+ return false;
+
+ return true;
+}
+
+struct bin_emulation_xfer_struct bin_aix_emulation =
+{
+ ar_emul_aix_usage,
+ ar_emul_aix_append,
+ ar_emul_aix_replace,
+ ar_emul_default_create,
+ ar_emul_aix_parse_arg,
+};
+
+struct bin_emulation_xfer_struct bin_aix5_emulation =
+{
+ ar_emul_aix_usage,
+ ar_emul_aix5_append,
+ ar_emul_aix5_replace,
+ ar_emul_default_create,
+ ar_emul_aix_parse_arg,
+};
diff --git a/binutils/emul_vanilla.c b/binutils/emul_vanilla.c
new file mode 100644
index 0000000..170db5b
--- /dev/null
+++ b/binutils/emul_vanilla.c
@@ -0,0 +1,30 @@
+/* Binutils emulation layer.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Written by Tom Rix, Redhat.
+
+ This file is part of GNU Binutils.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "binemul.h"
+
+struct bin_emulation_xfer_struct bin_vanilla_emulation =
+{
+ ar_emul_default_usage,
+ ar_emul_default_append,
+ ar_emul_default_replace,
+ ar_emul_default_create,
+ ar_emul_default_parse_arg,
+};