From 1047201fd0f402428bb3331638a198413f97f476 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 7 Oct 2016 10:58:35 +1030 Subject: [PATCH] bfd_merge_private_bfd_data tidy 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. --- bfd/ChangeLog | 28 +++++++++++++++++++++ bfd/Makefile.am | 4 +-- bfd/Makefile.in | 4 +-- bfd/bfd-in2.h | 10 ++++---- bfd/bfd.c | 21 ---------------- bfd/cpu-sh.c | 47 ------------------------------------ bfd/doc/Makefile.am | 3 +-- bfd/doc/Makefile.in | 3 +-- bfd/elf32-arc.c | 7 +----- bfd/elf32-cris.c | 12 +++------ bfd/elf32-microblaze.c | 17 +------------ bfd/elf32-mt.c | 2 +- bfd/elf32-sh.c | 48 ++++++++++++++++++++++++++++++++++++ bfd/elf32-xgate.c | 11 --------- bfd/elf32-xgate.h | 1 - bfd/libbfd-in.h | 4 --- bfd/libbfd.c | 26 -------------------- bfd/libbfd.h | 14 +++++------ bfd/linker.c | 55 ++++++++++++++++++++++++++++++++++++++++++ opcodes/ChangeLog | 4 +++ opcodes/sh-opc.h | 1 - 21 files changed, 159 insertions(+), 163 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index a276240abe..d500e3fcea 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,31 @@ +2016-10-07 Alan Modra + + * 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 * coff-h8300.c: Spell fall through comments consistently. diff --git a/bfd/Makefile.am b/bfd/Makefile.am index 53563e1038..e04be5a560 100644 --- a/bfd/Makefile.am +++ b/bfd/Makefile.am @@ -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"... diff --git a/bfd/Makefile.in b/bfd/Makefile.in index 125a6c824c..64658c5081 100644 --- a/bfd/Makefile.in +++ b/bfd/Makefile.in @@ -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 diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 1dc1c74462..35302ea468 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -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); diff --git a/bfd/bfd.c b/bfd/bfd.c index 0526742355..03875d0275 100644 --- 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 <> - on success, <> on error. Possible error returns are: - - o <> - - 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 diff --git a/bfd/cpu-sh.c b/bfd/cpu-sh.c index 9b14173c35..f9208267df 100644 --- a/bfd/cpu-sh.c +++ b/bfd/cpu-sh.c @@ -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; -} diff --git a/bfd/doc/Makefile.am b/bfd/doc/Makefile.am index c44c803033..1ec58569cf 100644 --- a/bfd/doc/Makefile.am +++ b/bfd/doc/Makefile.am @@ -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) diff --git a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in index b992872aa4..1a6d811e01 100644 --- a/bfd/doc/Makefile.in +++ b/bfd/doc/Makefile.in @@ -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) diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index 9fb83b5f28..002674be05 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -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; diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index 1722b75b63..255a9fd6aa 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -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)); } diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c index 778c6f0483..b29ac049ed 100644 --- a/bfd/elf32-microblaze.c +++ b/bfd/elf32-microblaze.c @@ -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; -} - /* 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 diff --git a/bfd/elf32-mt.c b/bfd/elf32-mt.c index f3e7a5bf6a..9f7d3fce81 100644 --- a/bfd/elf32-mt.c +++ b/bfd/elf32-mt.c @@ -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 diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index 7f108fb173..6a027c3ba9 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -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. */ diff --git a/bfd/elf32-xgate.c b/bfd/elf32-xgate.c index d48c658df6..13cdf667b1 100644 --- a/bfd/elf32-xgate.c +++ b/bfd/elf32-xgate.c @@ -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 diff --git a/bfd/elf32-xgate.h b/bfd/elf32-xgate.h index 8ea069a3c6..800286166c 100644 --- a/bfd/elf32-xgate.h +++ b/bfd/elf32-xgate.h @@ -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*); diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index f27adc9205..83ddd8be33 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -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 *); /* Macros to tell if bfds are read or write enabled. diff --git a/bfd/libbfd.c b/bfd/libbfd.c index 4583335204..7a6f3814f5 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -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. */ diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 99ff2d3dad..c6f8ecc2de 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -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 *); /* 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 diff --git a/bfd/linker.c b/bfd/linker.c index 8dff5a04fb..7830b29f50 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -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 <> on success, + <> on error. Possible error returns are: + + o <> - + 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; +} diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 441665914b..22ec46b5df 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,7 @@ +2016-10-07 Alan Modra + + * sh-opc.h (sh_merge_bfd_arch): Delete prototype. + 2016-10-06 Alan Modra * aarch64-opc.c: Spell fall through comments consistently. diff --git a/opcodes/sh-opc.h b/opcodes/sh-opc.h index 13bf5c7420..d64f50ce1b 100644 --- a/opcodes/sh-opc.h +++ b/opcodes/sh-opc.h @@ -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: -- 2.34.1