From: Alan Modra Date: Fri, 7 Oct 2016 00:28:35 +0000 (+1030) Subject: bfd_merge_private_bfd_data tidy X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1047201fd0f402428bb3331638a198413f97f476;p=binutils-gdb.git 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. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index a276240abe2..d500e3fceaf 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 53563e1038e..e04be5a560b 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 125a6c824c9..64658c50811 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 1dc1c74462f..35302ea468c 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 05267423556..03875d02758 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 9b14173c35e..f9208267df5 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 c44c8030334..1ec58569cf1 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 b992872aa48..1a6d811e018 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 9fb83b5f287..002674be05a 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 1722b75b637..255a9fd6aa8 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 778c6f04836..b29ac049edd 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 f3e7a5bf6a8..9f7d3fce816 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 7f108fb173a..6a027c3ba95 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 d48c658df64..13cdf667b16 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 8ea069a3c6b..800286166cb 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 f27adc92052..83ddd8be33c 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 45833352041..7a6f3814f5e 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 99ff2d3dadf..c6f8ecc2dee 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 8dff5a04fbf..7830b29f506 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 441665914b1..22ec46b5df5 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 13bf5c74206..d64f50ce1b7 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: