summaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2007-10-18 09:13:51 +0000
committerAlan Modra <amodra@bigpond.net.au>2007-10-18 09:13:51 +0000
commit07eca6f55f5ca048bad21e36f5a7e6d45682535f (patch)
tree8012f2bc38cfc9222b0c41070cb8de874cd8b42b /bfd
parent3e6c164c7fd3e62dca7e9a5e31e16f8d5f75f182 (diff)
downloadbinutils-redhat-07eca6f55f5ca048bad21e36f5a7e6d45682535f.tar.gz
PR ld/4424
* config.bfd (targ_selvecs): Add bfd_elf64_alpha_vec for alpha/FreeBSD. Add bfd_elf64_sparc_vec for sparc64/FreeBSD. Add bfd_elf32_i386_vec and bfd_efi_app_ia32_vec for i386/FreeBSD. (targ64_selvecs): Set for i386/FreeBSD. * elf-bfd.h (elf_backend_data): Add relocs_compatible. (_bfd_elf_default_relocs_compatible): Declare. (_bfd_elf_relocs_compatible): Declare. * elfxx-target.h (elf_backend_relocs_compatible): Define. (elfNN_bed): Init new relocs_compatible field. * elflink.c (_bfd_elf_default_relocs_compatible): New function. (_bfd_elf_relocs_compatible): New function. (elf_link_add_object_symbols): Call bed->relocs_compatible. * elf32-i386.c (elf_backend_relocs_compatible): Define. * elf64-alpha.c: Likewise. * elf64-sparc.c: Likewise. * elf64-x86-64.c: Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog21
-rw-r--r--bfd/config.bfd7
-rw-r--r--bfd/elf-bfd.h10
-rw-r--r--bfd/elf32-i386.c6
-rw-r--r--bfd/elf64-alpha.c2
-rw-r--r--bfd/elf64-sparc.c2
-rw-r--r--bfd/elf64-x86-64.c1
-rw-r--r--bfd/elflink.c38
-rw-r--r--bfd/elfxx-target.h4
9 files changed, 84 insertions, 7 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index de0deb0be2..aa17c293d0 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,24 @@
+2007-10-18 H.J. Lu <hongjiu.lu@intel.com>
+ Alan Modra <amodra@bigpond.net.au>
+
+ PR ld/4424
+ * config.bfd (targ_selvecs): Add bfd_elf64_alpha_vec for
+ alpha/FreeBSD. Add bfd_elf64_sparc_vec for sparc64/FreeBSD.
+ Add bfd_elf32_i386_vec and bfd_efi_app_ia32_vec for i386/FreeBSD.
+ (targ64_selvecs): Set for i386/FreeBSD.
+ * elf-bfd.h (elf_backend_data): Add relocs_compatible.
+ (_bfd_elf_default_relocs_compatible): Declare.
+ (_bfd_elf_relocs_compatible): Declare.
+ * elfxx-target.h (elf_backend_relocs_compatible): Define.
+ (elfNN_bed): Init new relocs_compatible field.
+ * elflink.c (_bfd_elf_default_relocs_compatible): New function.
+ (_bfd_elf_relocs_compatible): New function.
+ (elf_link_add_object_symbols): Call bed->relocs_compatible.
+ * elf32-i386.c (elf_backend_relocs_compatible): Define.
+ * elf64-alpha.c: Likewise.
+ * elf64-sparc.c: Likewise.
+ * elf64-x86-64.c: Likewise.
+
2007-10-16 Bob Wilson <bob.wilson@acm.org>
* elf32-xtensa.c (relax_section): Check for a reference to a discarded
diff --git a/bfd/config.bfd b/bfd/config.bfd
index 932e4fe47a..899e18ef69 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -140,7 +140,7 @@ case "${targ}" in
#ifdef BFD64
alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
targ_defvec=bfd_elf64_alpha_freebsd_vec
- targ_selvecs=ecoffalpha_little_vec
+ targ_selvecs="bfd_elf64_alpha_vec ecoffalpha_little_vec"
want64=true
# FreeBSD <= 4.0 supports only the old nonstandard way of ABI labelling.
case "${targ}" in
@@ -188,7 +188,7 @@ case "${targ}" in
;;
sparc64-*-freebsd* | sparc64-*-kfreebsd*-gnu)
targ_defvec=bfd_elf64_sparc_freebsd_vec
- targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec"
+ targ_selvecs="bfd_elf64_sparc_vec bfd_elf32_sparc_vec sunos_big_vec"
;;
sparc64-*-netbsd* | sparc64-*-openbsd*)
targ_defvec=bfd_elf64_sparc_vec
@@ -535,7 +535,8 @@ case "${targ}" in
;;
i[3-7]86-*-freebsd* | i[3-7]86-*-kfreebsd*-gnu | i[3-7]86-*-dragonfly*)
targ_defvec=bfd_elf32_i386_freebsd_vec
- targ_selvecs=i386coff_vec
+ targ_selvecs="bfd_elf32_i386_vec bfd_efi_app_ia32_vec i386coff_vec"
+ targ64_selvecs="bfd_elf64_x86_64_freebsd_vec bfd_elf64_x86_64_vec bfd_efi_app_x86_64_vec"
# FreeBSD <= 4.0 supports only the old nonstandard way of ABI labelling.
case "${targ}" in
i[3-7]86-*-freebsd3* | i[3-7]86-*-freebsd4 | i[3-7]86-*-freebsd4.0*)
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index a707cef0cd..f7b020d964 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -700,6 +700,10 @@ struct elf_backend_data
bfd_boolean (*elf_backend_omit_section_dynsym)
(bfd *output_bfd, struct bfd_link_info *info, asection *osec);
+ /* Return TRUE if relocations of targets are compatible to the extent
+ that CHECK_RELOCS will properly process them. PR 4424. */
+ bfd_boolean (*relocs_compatible) (const bfd_target *, const bfd_target *);
+
/* The CHECK_RELOCS function is called by the add_symbols phase of
the ELF backend linker. It is called once for each section with
relocs of an object file, just after the symbols for the object
@@ -1909,6 +1913,12 @@ extern void bfd_elf64_write_relocs
extern bfd_boolean bfd_elf64_slurp_reloc_table
(bfd *, asection *, asymbol **, bfd_boolean);
+extern bfd_boolean _bfd_elf_default_relocs_compatible
+ (const bfd_target *, const bfd_target *);
+
+extern bfd_boolean _bfd_elf_relocs_compatible
+ (const bfd_target *, const bfd_target *);
+
extern struct elf_link_hash_entry *_bfd_elf_archive_symbol_lookup
(bfd *, struct bfd_link_info *, const char *);
extern bfd_boolean bfd_elf_link_add_symbols
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 62c4eb76ba..e2396ce140 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -3996,9 +3996,10 @@ elf_i386_hash_symbol (struct elf_link_hash_entry *h)
#define bfd_elf32_bfd_is_local_label_name elf_i386_is_local_label_name
#define bfd_elf32_bfd_link_hash_table_create elf_i386_link_hash_table_create
#define bfd_elf32_bfd_reloc_type_lookup elf_i386_reloc_type_lookup
-#define bfd_elf32_bfd_reloc_name_lookup elf_i386_reloc_name_lookup
+#define bfd_elf32_bfd_reloc_name_lookup elf_i386_reloc_name_lookup
#define elf_backend_adjust_dynamic_symbol elf_i386_adjust_dynamic_symbol
+#define elf_backend_relocs_compatible _bfd_elf_relocs_compatible
#define elf_backend_check_relocs elf_i386_check_relocs
#define elf_backend_copy_indirect_symbol elf_i386_copy_indirect_symbol
#define elf_backend_create_dynamic_sections elf_i386_create_dynamic_sections
@@ -4084,7 +4085,8 @@ elf_i386_vxworks_link_hash_table_create (bfd *abfd)
}
-#undef elf_backend_post_process_headers
+#undef elf_backend_relocs_compatible
+#undef elf_backend_post_process_headers
#undef bfd_elf32_bfd_link_hash_table_create
#define bfd_elf32_bfd_link_hash_table_create \
elf_i386_vxworks_link_hash_table_create
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index c0702bb870..15a417e348 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -5329,6 +5329,8 @@ static const struct elf_size_info alpha_elf_size_info =
#define elf_backend_add_symbol_hook \
elf64_alpha_add_symbol_hook
+#define elf_backend_relocs_compatible \
+ _bfd_elf_relocs_compatible
#define elf_backend_check_relocs \
elf64_alpha_check_relocs
#define elf_backend_create_dynamic_sections \
diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c
index 459e31202e..a93097f002 100644
--- a/bfd/elf64-sparc.c
+++ b/bfd/elf64-sparc.c
@@ -870,6 +870,8 @@ const struct elf_size_info elf64_sparc_size_info =
#define elf_backend_create_dynamic_sections \
_bfd_sparc_elf_create_dynamic_sections
+#define elf_backend_relocs_compatible \
+ _bfd_elf_relocs_compatible
#define elf_backend_check_relocs \
_bfd_sparc_elf_check_relocs
#define elf_backend_adjust_dynamic_symbol \
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 2953bac29e..62860b8879 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -3826,6 +3826,7 @@ static const struct bfd_elf_special_section
elf64_x86_64_reloc_name_lookup
#define elf_backend_adjust_dynamic_symbol elf64_x86_64_adjust_dynamic_symbol
+#define elf_backend_relocs_compatible _bfd_elf_relocs_compatible
#define elf_backend_check_relocs elf64_x86_64_check_relocs
#define elf_backend_copy_indirect_symbol elf64_x86_64_copy_indirect_symbol
#define elf_backend_create_dynamic_sections elf64_x86_64_create_dynamic_sections
diff --git a/bfd/elflink.c b/bfd/elflink.c
index e2dfcefb09..ba2f54008b 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -3252,6 +3252,40 @@ elf_finalize_dynstr (bfd *output_bfd, struct bfd_link_info *info)
return TRUE;
}
+/* Return TRUE iff relocations for INPUT are compatible with OUTPUT.
+ The default is to only match when the INPUT and OUTPUT are exactly
+ the same target. */
+
+bfd_boolean
+_bfd_elf_default_relocs_compatible (const bfd_target *input,
+ const bfd_target *output)
+{
+ return input == output;
+}
+
+/* Return TRUE iff relocations for INPUT are compatible with OUTPUT.
+ This version is used when different targets for the same architecture
+ are virtually identical. */
+
+bfd_boolean
+_bfd_elf_relocs_compatible (const bfd_target *input,
+ const bfd_target *output)
+{
+ const struct elf_backend_data *obed, *ibed;
+
+ if (input == output)
+ return TRUE;
+
+ ibed = xvec_get_elf_backend_data (input);
+ obed = xvec_get_elf_backend_data (output);
+
+ if (ibed->arch != obed->arch)
+ return FALSE;
+
+ /* If both backends are using this function, deem them compatible. */
+ return ibed->relocs_compatible == obed->relocs_compatible;
+}
+
/* Add symbols from an ELF object file to the linker hash table. */
static bfd_boolean
@@ -4639,8 +4673,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
different format. It probably can't be done. */
if (! dynamic
&& is_elf_hash_table (htab)
- && htab->root.creator == abfd->xvec
- && bed->check_relocs != NULL)
+ && bed->check_relocs != NULL
+ && (*bed->relocs_compatible) (abfd->xvec, htab->root.creator))
{
asection *o;
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index f6b6760107..3cb124939e 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -385,6 +385,9 @@
#ifndef elf_backend_omit_section_dynsym
#define elf_backend_omit_section_dynsym _bfd_elf_link_omit_section_dynsym
#endif
+#ifndef elf_backend_relocs_compatible
+#define elf_backend_relocs_compatible _bfd_elf_default_relocs_compatible
+#endif
#ifndef elf_backend_check_relocs
#define elf_backend_check_relocs 0
#endif
@@ -637,6 +640,7 @@ static struct elf_backend_data elfNN_bed =
elf_backend_link_output_symbol_hook,
elf_backend_create_dynamic_sections,
elf_backend_omit_section_dynsym,
+ elf_backend_relocs_compatible,
elf_backend_check_relocs,
elf_backend_check_directives,
elf_backend_as_needed_cleanup,