+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.
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"...
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
#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) \
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);
*/
-/*
-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
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;
-}
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)
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)
/* 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;
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));
}
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. */
#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
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
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. */
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)
{
#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
#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*);
/* 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.
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. */
/* 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*.
/* 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.
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);
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
{
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;
+}
+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.
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: