bfd_merge_private_bfd_data tidy
authorAlan Modra <amodra@gmail.com>
Fri, 7 Oct 2016 00:28:35 +0000 (10:58 +1030)
committerAlan Modra <amodra@gmail.com>
Fri, 7 Oct 2016 00:54:21 +0000 (11:24 +1030)
bfd_merge_private_bfd_data and _bfd_generic_verify_endian_match are
linker functions, so move them to linker.c.

bfd/
* Makefile.am (LIBBFD_H_FILES): Update.
* doc/Makefile.am (LIBBFD_H_DEP): Likewise.
* cpu-sh.c (sh_merge_bfd_arch): Move to..
* elf32-sh.c: ..here, and make static.
* elf32-arc.c (arc_elf_merge_private_bfd_data): Delete extraneous
error.
* elf32-cris.c (cris_elf_merge_private_bfd_data): Don't call
_bfd_generic_verify_endian_match.
* elf32-microblaze.c (microblaze_elf_merge_private_bfd_data): Delete.
(bfd_elf32_bfd_merge_private_bfd_data): Define as
_bfd_generic_verify_endian_match.
* elf32-mt.c (mt_elf_merge_private_bfd_data): Don't test
boolean == FALSE.
* elf32-xgate.c (_bfd_xgate_elf_merge_private_bfd_data): Delete.
(bfd_elf32_bfd_merge_private_bfd_data): Don't define.
* elf32-xgate.h (_bfd_xgate_elf_merge_private_bfd_data): Delete.
* libbfd-in.h (_bfd_generic_verify_endian_match): Delete.
* libbfd.c (_bfd_generic_verify_endian_match): Move to..
* linker.c: ..here, and make internal.
* bfd.c (bfd_merge_private_bfd_data): Move to..
* linker.c: ..here.
* Makefile.in: Regenerate.
* doc/Makefile.in: Regenerate.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
opcodes/
* sh-opc.h (sh_merge_bfd_arch): Delete prototype.

21 files changed:
bfd/ChangeLog
bfd/Makefile.am
bfd/Makefile.in
bfd/bfd-in2.h
bfd/bfd.c
bfd/cpu-sh.c
bfd/doc/Makefile.am
bfd/doc/Makefile.in
bfd/elf32-arc.c
bfd/elf32-cris.c
bfd/elf32-microblaze.c
bfd/elf32-mt.c
bfd/elf32-sh.c
bfd/elf32-xgate.c
bfd/elf32-xgate.h
bfd/libbfd-in.h
bfd/libbfd.c
bfd/libbfd.h
bfd/linker.c
opcodes/ChangeLog
opcodes/sh-opc.h

index a276240abe23aa8d8bba183ad25f0c7e1d4ae822..d500e3fceafa42b4864b5f420b511e3c49c771c7 100644 (file)
@@ -1,3 +1,31 @@
+2016-10-07  Alan Modra  <amodra@gmail.com>
+
+       * Makefile.am (LIBBFD_H_FILES): Update.
+       * doc/Makefile.am (LIBBFD_H_DEP): Likewise.
+       * cpu-sh.c (sh_merge_bfd_arch): Move to..
+       * elf32-sh.c: ..here, and make static.
+       * elf32-arc.c (arc_elf_merge_private_bfd_data): Delete extraneous
+       error.
+       * elf32-cris.c (cris_elf_merge_private_bfd_data): Don't call
+       _bfd_generic_verify_endian_match.
+       * elf32-microblaze.c (microblaze_elf_merge_private_bfd_data): Delete.
+       (bfd_elf32_bfd_merge_private_bfd_data): Define as
+       _bfd_generic_verify_endian_match.
+       * elf32-mt.c (mt_elf_merge_private_bfd_data): Don't test
+       boolean == FALSE.
+       * elf32-xgate.c (_bfd_xgate_elf_merge_private_bfd_data): Delete.
+       (bfd_elf32_bfd_merge_private_bfd_data): Don't define.
+       * elf32-xgate.h (_bfd_xgate_elf_merge_private_bfd_data): Delete.
+       * libbfd-in.h (_bfd_generic_verify_endian_match): Delete.
+       * libbfd.c (_bfd_generic_verify_endian_match): Move to..
+       * linker.c: ..here, and make internal.
+       * bfd.c (bfd_merge_private_bfd_data): Move to..
+       * linker.c: ..here.
+       * Makefile.in: Regenerate.
+       * doc/Makefile.in: Regenerate.
+       * bfd-in2.h: Regenerate.
+       * libbfd.h: Regenerate.
+
 2016-10-06  Alan Modra  <amodra@gmail.com>
 
        * coff-h8300.c: Spell fall through comments consistently.
index 53563e1038e17ad189a5a4fbdb08bf8de26a6b9f..e04be5a560bcf03cfeaaae3f29a9c4b4e202f44e 100644 (file)
@@ -1002,8 +1002,8 @@ BFD_H_FILES = bfd-in.h init.c opncls.c libbfd.c \
        syms.c bfd.c archive.c corefile.c targets.c format.c \
        linker.c simple.c compress.c
 BFD64_H_FILES = archive64.c
-LIBBFD_H_FILES = libbfd-in.h init.c libbfd.c bfdio.c bfdwin.c \
-       cache.c reloc.c archures.c elf.c
+LIBBFD_H_FILES = libbfd-in.h libbfd.c bfdio.c bfdwin.c \
+       cache.c reloc.c archures.c linker.c
 LIBCOFF_H_FILES = libcoff-in.h coffcode.h
 
 # Could really use a "copy-if-change"...
index 125a6c824c933974212238c02a77560996f5e640..64658c50811fcdd1172e76b0a5c9b8fff5ba0b76 100644 (file)
@@ -1176,8 +1176,8 @@ BFD_H_FILES = bfd-in.h init.c opncls.c libbfd.c \
        linker.c simple.c compress.c
 
 BFD64_H_FILES = archive64.c
-LIBBFD_H_FILES = libbfd-in.h init.c libbfd.c bfdio.c bfdwin.c \
-       cache.c reloc.c archures.c elf.c
+LIBBFD_H_FILES = libbfd-in.h libbfd.c bfdio.c bfdwin.c \
+       cache.c reloc.c archures.c linker.c
 
 LIBCOFF_H_FILES = libcoff-in.h coffcode.h
 MOSTLYCLEANFILES = ofiles stamp-ofiles
index 1dc1c74462f8e237e8f6756b55dba540e9985dbe..35302ea468c8bfaa4a114ba1e9c4bdb9e2651e04 100644 (file)
@@ -6975,11 +6975,6 @@ bfd_boolean bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd);
 #define bfd_copy_private_bfd_data(ibfd, obfd) \
      BFD_SEND (obfd, _bfd_copy_private_bfd_data, \
                (ibfd, obfd))
-bfd_boolean bfd_merge_private_bfd_data (bfd *ibfd, bfd *obfd);
-
-#define bfd_merge_private_bfd_data(ibfd, obfd) \
-     BFD_SEND (obfd, _bfd_merge_private_bfd_data, \
-               (ibfd, obfd))
 bfd_boolean bfd_set_private_flags (bfd *abfd, flagword flags);
 
 #define bfd_set_private_flags(abfd, flags) \
@@ -7620,6 +7615,11 @@ bfd_boolean bfd_link_check_relocs
 bfd_boolean _bfd_generic_link_check_relocs
    (bfd *abfd, struct bfd_link_info *info);
 
+bfd_boolean bfd_merge_private_bfd_data (bfd *ibfd, bfd *obfd);
+
+#define bfd_merge_private_bfd_data(ibfd, obfd) \
+     BFD_SEND (obfd, _bfd_merge_private_bfd_data, \
+               (ibfd, obfd))
 /* Extracted from simple.c.  */
 bfd_byte *bfd_simple_get_relocated_section_contents
    (bfd *abfd, asection *sec, bfd_byte *outbuf, asymbol **symbol_table);
index 05267423556ce3ba65eaea99bdefd25817e6321c..03875d027586937d82666564cc73c6e7ce9d40c3 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1406,27 +1406,6 @@ DESCRIPTION
 
 */
 
-/*
-FUNCTION
-       bfd_merge_private_bfd_data
-
-SYNOPSIS
-       bfd_boolean bfd_merge_private_bfd_data (bfd *ibfd, bfd *obfd);
-
-DESCRIPTION
-       Merge private BFD information from the BFD @var{ibfd} to the
-       the output file BFD @var{obfd} when linking.  Return <<TRUE>>
-       on success, <<FALSE>> on error.  Possible error returns are:
-
-       o <<bfd_error_no_memory>> -
-       Not enough memory exists to create private data for @var{obfd}.
-
-.#define bfd_merge_private_bfd_data(ibfd, obfd) \
-.     BFD_SEND (obfd, _bfd_merge_private_bfd_data, \
-.              (ibfd, obfd))
-
-*/
-
 /*
 FUNCTION
        bfd_set_private_flags
index 9b14173c35e8fc83dd30afc507b00123d94593c2..f9208267df5c019b34e1b306f6655dd9c3c223fd 100644 (file)
@@ -496,50 +496,3 @@ sh_get_bfd_mach_from_arch_set (unsigned int arch_set)
 
   return result;
 }
-
-
-/* Merge the architecture type of two BFD files, such that the
-   resultant architecture supports all the features required
-   by the two input BFDs.
-   If the input BFDs are multually incompatible - i.e. one uses
-   DSP while the other uses FPU - or there is no known architecture
-   that fits the requirements then an error is emitted.  */
-
-bfd_boolean
-sh_merge_bfd_arch (bfd *ibfd, bfd *obfd)
-{
-  unsigned int old_arch, new_arch, merged_arch;
-
-  if (! _bfd_generic_verify_endian_match (ibfd, obfd))
-    return FALSE;
-
-  old_arch = sh_get_arch_up_from_bfd_mach (bfd_get_mach (obfd));
-  new_arch = sh_get_arch_up_from_bfd_mach (bfd_get_mach (ibfd));
-
-  merged_arch = SH_MERGE_ARCH_SET (old_arch, new_arch);
-
-  if (!SH_VALID_CO_ARCH_SET (merged_arch))
-    {
-      _bfd_error_handler
-       ("%B: uses %s instructions while previous modules use %s instructions",
-        ibfd,
-        SH_ARCH_SET_HAS_DSP (new_arch) ? "dsp" : "floating point",
-        SH_ARCH_SET_HAS_DSP (new_arch) ? "floating point" : "dsp");
-      bfd_set_error (bfd_error_bad_value);
-      return FALSE;
-    }
-  else if (!SH_VALID_ARCH_SET (merged_arch))
-    {
-      _bfd_error_handler
-       ("internal error: merge of architecture '%s' with architecture '%s' produced unknown architecture\n",
-        bfd_printable_name (obfd),
-        bfd_printable_name (ibfd));
-      bfd_set_error (bfd_error_bad_value);
-      return FALSE;
-    }
-
-  bfd_default_set_arch_mach (obfd, bfd_arch_sh,
-                            sh_get_bfd_mach_from_arch_set (merged_arch));
-
-  return TRUE;
-}
index c44c80303342a0b371aca0d5b5a02f30c96cf27e..1ec58569cf124f25e7119be439d7a089c064bb6c 100644 (file)
@@ -252,14 +252,13 @@ linker.stamp: $(srcdir)/../linker.c $(srcdir)/doc.str $(MKDOC)
 
 LIBBFD_H_DEP = \
        $(srcdir)/../libbfd-in.h        \
-       $(srcdir)/../init.c             \
        $(srcdir)/../libbfd.c           \
        $(srcdir)/../bfdio.c            \
        $(srcdir)/../bfdwin.c           \
        $(srcdir)/../cache.c            \
        $(srcdir)/../reloc.c            \
        $(srcdir)/../archures.c         \
-       $(srcdir)/../elf.c              \
+       $(srcdir)/../linker.c           \
        $(srcdir)/header.sed            \
        $(srcdir)/proto.str             \
        $(MKDOC)
index b992872aa48d39eeece35aba06cf3cc4485b74c9..1a6d811e018807c2cb9838382cefbae6bb6369e7 100644 (file)
@@ -379,14 +379,13 @@ AM_CPPFLAGS = -I.. -I$(srcdir)/.. -I$(srcdir)/../../include \
 
 LIBBFD_H_DEP = \
        $(srcdir)/../libbfd-in.h        \
-       $(srcdir)/../init.c             \
        $(srcdir)/../libbfd.c           \
        $(srcdir)/../bfdio.c            \
        $(srcdir)/../bfdwin.c           \
        $(srcdir)/../cache.c            \
        $(srcdir)/../reloc.c            \
        $(srcdir)/../archures.c         \
-       $(srcdir)/../elf.c              \
+       $(srcdir)/../linker.c           \
        $(srcdir)/header.sed            \
        $(srcdir)/proto.str             \
        $(MKDOC)
index 9fb83b5f2874267c0a2fdbedb42341be4d2dea14..002674be05a8b801f46d614a4372fedb503b7717 100644 (file)
@@ -552,12 +552,7 @@ arc_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
 
    /* Check if we have the same endianess.  */
   if (! _bfd_generic_verify_endian_match (ibfd, obfd))
-    {
-      _bfd_error_handler (_("ERROR: Endian Match failed. Attempting to link "
-                           "%B with binary %s of opposite endian-ness"),
-                         ibfd, bfd_get_filename (obfd));
-      return FALSE;
-    }
+    return FALSE;
 
   /* Collect ELF flags.  */
   in_flags = elf_elfheader (ibfd)->e_flags & EF_ARC_MACH_MSK;
index 1722b75b637f3fdd10222ae146a4647d70caee95..255a9fd6aa8331dc49e4cf73c3e7fbca64aa10b6 100644 (file)
@@ -4233,18 +4233,14 @@ cris_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
 static bfd_boolean
 cris_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
 {
-  /* Call the base function.  */
-  if (!_bfd_elf_copy_private_bfd_data (ibfd, obfd))
-    return FALSE;
-
-  /* If output is big-endian for some obscure reason, stop here.  */
-  if (_bfd_generic_verify_endian_match (ibfd, obfd) == FALSE)
-    return FALSE;
-
   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
     return TRUE;
 
+  /* Call the base function.  */
+  if (!_bfd_elf_copy_private_bfd_data (ibfd, obfd))
+    return FALSE;
+
   /* Do what we really came here for.  */
   return bfd_set_arch_mach (obfd, bfd_arch_cris, bfd_get_mach (ibfd));
 }
index 778c6f048360a761e15644a94dff9a04d3663512..b29ac049eddad66535c5d4e229995c958dd253c2 100644 (file)
@@ -1596,21 +1596,6 @@ microblaze_elf_relocate_section (bfd *output_bfd,
 
   return ret;
 }
-
-/* Merge backend specific data from an object file to the output
-   object file when linking.
-
-   Note: We only use this hook to catch endian mismatches.  */
-static bfd_boolean
-microblaze_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
-{
-  /* Check if we have the same endianess.  */
-  if (! _bfd_generic_verify_endian_match (ibfd, obfd))
-    return FALSE;
-
-  return TRUE;
-}
-
 \f
 /* Calculate fixup value for reference.  */
 
@@ -3500,7 +3485,7 @@ microblaze_elf_add_symbol_hook (bfd *abfd,
 #define bfd_elf32_bfd_is_local_label_name       microblaze_elf_is_local_label_name
 #define elf_backend_relocate_section           microblaze_elf_relocate_section
 #define bfd_elf32_bfd_relax_section             microblaze_elf_relax_section
-#define bfd_elf32_bfd_merge_private_bfd_data    microblaze_elf_merge_private_bfd_data
+#define bfd_elf32_bfd_merge_private_bfd_data    _bfd_generic_verify_endian_match
 #define bfd_elf32_bfd_reloc_name_lookup                microblaze_elf_reloc_name_lookup
 
 #define elf_backend_gc_mark_hook               microblaze_elf_gc_mark_hook
index f3e7a5bf6a812d23c1bf34e4afc6ad6b11eb0c21..9f7d3fce816151dd1e5fefbcd5976eef07a6088d 100644 (file)
@@ -508,7 +508,7 @@ mt_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
   bfd_boolean  ok = TRUE;
 
   /* Check if we have the same endianness.  */
-  if (_bfd_generic_verify_endian_match (ibfd, obfd) == FALSE)
+  if (!_bfd_generic_verify_endian_match (ibfd, obfd))
     return FALSE;
 
   /* If they're not both mt, then merging is meaningless, so just
index 7f108fb173ae9fae98a314ab899dfd383b2bbe82..6a027c3ba95f367a11bb12772e991be6d1b157c4 100644 (file)
@@ -6414,6 +6414,54 @@ sh_find_elf_flags (unsigned int arch_set)
   return sh_elf_get_flags_from_mach (bfd_mach);
 }
 
+/* Merge the architecture type of two BFD files, such that the
+   resultant architecture supports all the features required
+   by the two input BFDs.
+   If the input BFDs are multually incompatible - i.e. one uses
+   DSP while the other uses FPU - or there is no known architecture
+   that fits the requirements then an error is emitted.  */
+
+static bfd_boolean
+sh_merge_bfd_arch (bfd *ibfd, bfd *obfd)
+{
+  unsigned int old_arch, new_arch, merged_arch;
+
+  if (! _bfd_generic_verify_endian_match (ibfd, obfd))
+    return FALSE;
+
+  old_arch = sh_get_arch_up_from_bfd_mach (bfd_get_mach (obfd));
+  new_arch = sh_get_arch_up_from_bfd_mach (bfd_get_mach (ibfd));
+
+  merged_arch = SH_MERGE_ARCH_SET (old_arch, new_arch);
+
+  if (!SH_VALID_CO_ARCH_SET (merged_arch))
+    {
+      _bfd_error_handler
+       ("%B: uses %s instructions while previous modules "
+        "use %s instructions",
+        ibfd,
+        SH_ARCH_SET_HAS_DSP (new_arch) ? "dsp" : "floating point",
+        SH_ARCH_SET_HAS_DSP (new_arch) ? "floating point" : "dsp");
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+  else if (!SH_VALID_ARCH_SET (merged_arch))
+    {
+      _bfd_error_handler
+       ("internal error: merge of architecture '%s' with "
+        "architecture '%s' produced unknown architecture",
+        bfd_printable_name (obfd),
+        bfd_printable_name (ibfd));
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
+  bfd_default_set_arch_mach (obfd, bfd_arch_sh,
+                            sh_get_bfd_mach_from_arch_set (merged_arch));
+
+  return TRUE;
+}
+
 /* This routine initialises the elf flags when required and
    calls sh_merge_bfd_arch() to check dsp/fpu compatibility.  */
 
index d48c658df6400493ddc81022a2b6141b2b0a6ec9..13cdf667b1609ca412c48f5b210af515ff01e2e3 100644 (file)
@@ -654,16 +654,6 @@ _bfd_xgate_elf_set_private_flags (bfd *abfd ATTRIBUTE_UNUSED,
   return TRUE;
 }
 
-/* Merge backend specific data from an object file to the output
-   object file when linking.  */
-
-bfd_boolean
-_bfd_xgate_elf_merge_private_bfd_data (bfd *ibfd ATTRIBUTE_UNUSED,
-                                      bfd *obfd ATTRIBUTE_UNUSED)
-{
-  return TRUE;
-}
-
 bfd_boolean
 _bfd_xgate_elf_print_private_bfd_data (bfd *abfd, void *ptr)
 {
@@ -722,7 +712,6 @@ elf32_xgate_post_process_headers (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_link_in
 #define elf_backend_add_symbol_hook          elf32_xgate_add_symbol_hook
 
 #define bfd_elf32_bfd_link_hash_table_create xgate_elf_bfd_link_hash_table_create
-#define bfd_elf32_bfd_merge_private_bfd_data _bfd_xgate_elf_merge_private_bfd_data
 #define bfd_elf32_bfd_set_private_flags      _bfd_xgate_elf_set_private_flags
 #define bfd_elf32_bfd_print_private_bfd_data _bfd_xgate_elf_print_private_bfd_data
 
index 8ea069a3c6b1da7f1082a2b91bc6c098b3eaf351..800286166cbae62841a8caa377534c37de518f35 100644 (file)
@@ -29,7 +29,6 @@
 #include "elf/xgate.h"
 
 /* Set and control ELF flags in ELF header.  */
-extern bfd_boolean _bfd_xgate_elf_merge_private_bfd_data (bfd*,bfd*);
 extern bfd_boolean _bfd_xgate_elf_set_private_flags (bfd*,flagword);
 extern bfd_boolean _bfd_xgate_elf_print_private_bfd_data (bfd*, void*);
 
index f27adc9205258ca078d680af29b7898f8c4cd561..83ddd8be33cafef4e161a8c26551a5cc7caf7457 100644 (file)
@@ -749,10 +749,6 @@ extern bfd_size_type _bfd_stringtab_add
 /* Write out a string table.  */
 extern bfd_boolean _bfd_stringtab_emit
   (bfd *, struct bfd_strtab_hash *);
-
-/* Check that endianness of input and output file match.  */
-extern bfd_boolean _bfd_generic_verify_endian_match
-  (bfd *, bfd *);
 \f
 /* Macros to tell if bfds are read or write enabled.
 
index 458333520419861a43e676e08f87980baf547b11..7a6f3814f5ef16ef3ccb90a3ca699182739fd025 100644 (file)
@@ -922,32 +922,6 @@ bfd_generic_is_local_label_name (bfd *abfd, const char *name)
   return name[0] == locals_prefix;
 }
 
-/*  Can be used from / for bfd_merge_private_bfd_data to check that
-    endianness matches between input and output file.  Returns
-    TRUE for a match, otherwise returns FALSE and emits an error.  */
-bfd_boolean
-_bfd_generic_verify_endian_match (bfd *ibfd, bfd *obfd)
-{
-  if (ibfd->xvec->byteorder != obfd->xvec->byteorder
-      && ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN
-      && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
-    {
-      const char *msg;
-
-      if (bfd_big_endian (ibfd))
-       msg = _("%B: compiled for a big endian system and target is little endian");
-      else
-       msg = _("%B: compiled for a little endian system and target is big endian");
-
-      _bfd_error_handler (msg, ibfd);
-
-      bfd_set_error (bfd_error_wrong_format);
-      return FALSE;
-    }
-
-  return TRUE;
-}
-
 /* Give a warning at runtime if someone compiles code which calls
    old routines.  */
 
index 99ff2d3dadf4f2b3997530927d59976770b8f344..c6f8ecc2dee99690838dbf9576c823dbcba1866d 100644 (file)
@@ -1,6 +1,6 @@
 /* DO NOT EDIT!  -*- buffer-read-only: t -*-  This file is automatically 
-   generated from "libbfd-in.h", "init.c", "libbfd.c", "bfdio.c", 
-   "bfdwin.c", "cache.c", "reloc.c", "archures.c" and "elf.c".
+   generated from "libbfd-in.h", "libbfd.c", "bfdio.c", "bfdwin.c", 
+   "cache.c", "reloc.c", "archures.c" and "linker.c".
    Run "make headers" in your build bfd/ to regenerate.  */
 
 /* libbfd.h -- Declarations used by bfd library *implementation*.
@@ -754,10 +754,6 @@ extern bfd_size_type _bfd_stringtab_add
 /* Write out a string table.  */
 extern bfd_boolean _bfd_stringtab_emit
   (bfd *, struct bfd_strtab_hash *);
-
-/* Check that endianness of input and output file match.  */
-extern bfd_boolean _bfd_generic_verify_endian_match
-  (bfd *, bfd *);
 \f
 /* Macros to tell if bfds are read or write enabled.
 
@@ -868,7 +864,6 @@ extern bfd_vma read_unsigned_leb128 (bfd *, bfd_byte *, unsigned int *);
 extern bfd_signed_vma read_signed_leb128 (bfd *, bfd_byte *, unsigned int *);
 extern bfd_vma safe_read_leb128 (bfd *, bfd_byte *, unsigned int *,
                                 bfd_boolean, const bfd_byte * const);
-/* Extracted from init.c.  */
 /* Extracted from libbfd.c.  */
 bfd_boolean bfd_write_bigendian_4byte_int (bfd *, unsigned int);
 
@@ -3157,7 +3152,10 @@ void *bfd_arch_default_fill (bfd_size_type count,
     bfd_boolean is_bigendian,
     bfd_boolean code);
 
-/* Extracted from elf.c.  */
+/* Extracted from linker.c.  */
+bfd_boolean _bfd_generic_verify_endian_match
+   (bfd *ibfd, bfd *obfd);
+
 #ifdef __cplusplus
 }
 #endif
index 8dff5a04fbff4b54da527a37c54b37633c8625b3..7830b29f50607d2b71ccfb14b1c8175db39b6dbb 100644 (file)
@@ -3332,3 +3332,58 @@ _bfd_generic_link_check_relocs (bfd *abfd ATTRIBUTE_UNUSED,
 {
   return TRUE;
 }
+
+/*
+FUNCTION
+       bfd_merge_private_bfd_data
+
+SYNOPSIS
+       bfd_boolean bfd_merge_private_bfd_data (bfd *ibfd, bfd *obfd);
+
+DESCRIPTION
+       Merge private BFD information from the BFD @var{ibfd} to the
+       the output file BFD @var{obfd} when linking.  Return <<TRUE>> on success,
+       <<FALSE>> on error.  Possible error returns are:
+
+       o <<bfd_error_no_memory>> -
+       Not enough memory exists to create private data for @var{obfd}.
+
+.#define bfd_merge_private_bfd_data(ibfd, obfd) \
+.     BFD_SEND (obfd, _bfd_merge_private_bfd_data, \
+.              (ibfd, obfd))
+
+*/
+
+/*
+INTERNAL_FUNCTION
+       _bfd_generic_verify_endian_match
+
+SYNOPSIS
+       bfd_boolean _bfd_generic_verify_endian_match
+         (bfd *ibfd, bfd *obfd);
+
+DESCRIPTION
+       Can be used from / for bfd_merge_private_bfd_data to check that
+       endianness matches between input and output file.  Returns
+       TRUE for a match, otherwise returns FALSE and emits an error.
+*/
+
+bfd_boolean
+_bfd_generic_verify_endian_match (bfd *ibfd, bfd *obfd)
+{
+  if (ibfd->xvec->byteorder != obfd->xvec->byteorder
+      && ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN
+      && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
+    {
+      if (bfd_big_endian (ibfd))
+       _bfd_error_handler (_("%B: compiled for a big endian system "
+                             "and target is little endian"), ibfd);
+      else
+       _bfd_error_handler (_("%B: compiled for a little endian system "
+                             "and target is big endian"), ibfd);
+      bfd_set_error (bfd_error_wrong_format);
+      return FALSE;
+    }
+
+  return TRUE;
+}
index 441665914b16b5cf129d1da530a83060c4302b07..22ec46b5df58b26a0e82b08fba1a23c804b3de29 100644 (file)
@@ -1,3 +1,7 @@
+2016-10-07  Alan Modra  <amodra@gmail.com>
+
+       * sh-opc.h (sh_merge_bfd_arch): Delete prototype.
+
 2016-10-06  Alan Modra  <amodra@gmail.com>
 
        * aarch64-opc.c: Spell fall through comments consistently.
index 13bf5c74206104ce8384a230878d431784e65156..d64f50ce1b764783de15c25b9e910599d62d43c8 100644 (file)
@@ -285,7 +285,6 @@ sh_dsp_reg_nums;
 unsigned int sh_get_arch_from_bfd_mach (unsigned long mach);
 unsigned int sh_get_arch_up_from_bfd_mach (unsigned long mach);
 unsigned long sh_get_bfd_mach_from_arch_set (unsigned int arch_set);
-bfd_boolean sh_merge_bfd_arch (bfd *ibfd, bfd *obfd);
 
 /* Below are the 'architecture sets'.
    They describe the following inheritance graph: