Fix the generation of GOT table entries for the SH in the presence of linker garbage collection.
PR ld/17739
* emulparams/shelf.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Define with
ld valye 'yes'.
* emulparams/shelf32.sh: Likewise.
* emulparams/shelf32.sh: Likewise.
* emulparams/shelf_nto.sh: Likewise.
* emulparams/shelf_nto.sh: Likewise.
* emulparams/shelf_vxworks.sh: Likewise.
* emulparams/shelf_vxworks.sh: Likewise.
* emulparams/shlelf32_linux.sh: Likewise.
* emulparams/shlelf32_linux.sh: Likewise.
* emulparams/shlelf_linux.sh: Likewise.
* emulparams/shlelf_linux.sh: Likewise.
* emulparams/shlelf_nto.sh: Likewise.
* emulparams/shlelf_nto.sh: Likewise.
bfd * elf32-sh.c (sh_elf_gc_sweep_hook): Delete.
(elf_backend_sweep_hook): Delete.
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 2affa22..48d41e5 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2016-08-02 Nick Clifton <nickc@redhat.com>
+
+ PR ld/17739
+ * elf32-sh.c (sh_elf_gc_sweep_hook): Delete.
+ (elf_backend_sweep_hook): Delete.
+
2016-08-03 Tristan Gingold <gingold@adacore.com>
* version.m4: Bump version to 2.27.0
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 52a5fd1..5609b55 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -5682,6 +5682,7 @@
return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
}
+#if 0
/* Update the got entry reference counts for the section being removed. */
static bfd_boolean
@@ -5895,6 +5896,7 @@
return TRUE;
}
+#endif
/* Copy the extra info we tack onto an elf_link_hash_entry. */
@@ -7455,7 +7457,7 @@
sh_elf_merge_private_data
#define elf_backend_gc_mark_hook sh_elf_gc_mark_hook
-#define elf_backend_gc_sweep_hook sh_elf_gc_sweep_hook
+//#define elf_backend_gc_sweep_hook sh_elf_gc_sweep_hook
#define elf_backend_check_relocs sh_elf_check_relocs
#define elf_backend_copy_indirect_symbol \
sh_elf_copy_indirect_symbol
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 062e134..d95592a 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,21 @@
+2016-08-02 Nick Clifton <nickc@redhat.com>
+
+ PR ld/17739
+ * emulparams/shelf.sh (CHECK_RELOCS_AFTER_OPEN_INPUT): Define with
+ valye 'yes'.
+ * emulparams/shelf32.sh: Likewise.
+ * emulparams/shelf32.sh: Likewise.
+ * emulparams/shelf_nto.sh: Likewise.
+ * emulparams/shelf_nto.sh: Likewise.
+ * emulparams/shelf_vxworks.sh: Likewise.
+ * emulparams/shelf_vxworks.sh: Likewise.
+ * emulparams/shlelf32_linux.sh: Likewise.
+ * emulparams/shlelf32_linux.sh: Likewise.
+ * emulparams/shlelf_linux.sh: Likewise.
+ * emulparams/shlelf_linux.sh: Likewise.
+ * emulparams/shlelf_nto.sh: Likewise.
+ * emulparams/shlelf_nto.sh: Likewise.
+
2016-08-03 Tristan Gingold <gingold@adacore.com>
* configure: Regenerate.
diff --git a/ld/emulparams/shelf.sh b/ld/emulparams/shelf.sh
index 83680a6..d3f4752 100644
--- a/ld/emulparams/shelf.sh
+++ b/ld/emulparams/shelf.sh
@@ -11,6 +11,9 @@
TEMPLATE_NAME=elf32
GENERATE_SHLIB_SCRIPT=yes
EMBEDDED=yes
+# PR 17739. Delay checking relocs until after all files have
+# been opened and linker garbage collection has taken place.
+CHECK_RELOCS_AFTER_OPEN_INPUT=yes
# These are for compatibility with the COFF toolchain.
ENTRY=start
diff --git a/ld/emulparams/shelf32.sh b/ld/emulparams/shelf32.sh
index 966bd30..bf362c5 100644
--- a/ld/emulparams/shelf32.sh
+++ b/ld/emulparams/shelf32.sh
@@ -11,6 +11,9 @@
TEMPLATE_NAME=elf32
GENERATE_SHLIB_SCRIPT=yes
EMBEDDED=yes
+# PR 17739. Delay checking relocs until after all files have
+# been opened and linker garbage collection has taken place.
+CHECK_RELOCS_AFTER_OPEN_INPUT=yes
DATA_START_SYMBOLS='PROVIDE (___data = .);'
diff --git a/ld/emulparams/shelf_nto.sh b/ld/emulparams/shelf_nto.sh
index c4d71aa..46efd87 100644
--- a/ld/emulparams/shelf_nto.sh
+++ b/ld/emulparams/shelf_nto.sh
@@ -9,3 +9,6 @@
GENERATE_SHLIB_SCRIPT=yes
TEXT_START_SYMBOLS='_btext = .;'
ENTRY=_start
+# PR 17739. Delay checking relocs until after all files have
+# been opened and linker garbage collection has taken place.
+CHECK_RELOCS_AFTER_OPEN_INPUT=yes
diff --git a/ld/emulparams/shelf_vxworks.sh b/ld/emulparams/shelf_vxworks.sh
index 77619cb..759ffac 100644
--- a/ld/emulparams/shelf_vxworks.sh
+++ b/ld/emulparams/shelf_vxworks.sh
@@ -14,6 +14,10 @@
GENERATE_SHLIB_SCRIPT=yes
ENTRY=__start
SYMPREFIX=_
+# PR 17739. Delay checking relocs until after all files have
+# been opened and linker garbage collection has taken place.
+CHECK_RELOCS_AFTER_OPEN_INPUT=yes
+
GOT=".got ${RELOCATING-0} : {
PROVIDE(__GLOBAL_OFFSET_TABLE_ = .);
*(.got.plt) *(.got) }"
diff --git a/ld/emulparams/shlelf32_linux.sh b/ld/emulparams/shlelf32_linux.sh
index 81aea39..0327e57 100644
--- a/ld/emulparams/shlelf32_linux.sh
+++ b/ld/emulparams/shlelf32_linux.sh
@@ -13,7 +13,9 @@
TEMPLATE_NAME=elf32
GENERATE_SHLIB_SCRIPT=yes
GENERATE_PIE_SCRIPT=yes
-
+# PR 17739. Delay checking relocs until after all files have
+# been opened and linker garbage collection has taken place.
+CHECK_RELOCS_AFTER_OPEN_INPUT=yes
DATA_START_SYMBOLS='PROVIDE (___data = .);'
diff --git a/ld/emulparams/shlelf_linux.sh b/ld/emulparams/shlelf_linux.sh
index c14aae2..4e2a581 100644
--- a/ld/emulparams/shlelf_linux.sh
+++ b/ld/emulparams/shlelf_linux.sh
@@ -12,6 +12,9 @@
TEMPLATE_NAME=elf32
GENERATE_SHLIB_SCRIPT=yes
GENERATE_PIE_SCRIPT=yes
+# PR 17739. Delay checking relocs until after all files have
+# been opened and linker garbage collection has taken place.
+CHECK_RELOCS_AFTER_OPEN_INPUT=yes
DATA_START_SYMBOLS='PROVIDE (__data_start = .);';
diff --git a/ld/emulparams/shlelf_nto.sh b/ld/emulparams/shlelf_nto.sh
index 16f6508..f8ffc13 100644
--- a/ld/emulparams/shlelf_nto.sh
+++ b/ld/emulparams/shlelf_nto.sh
@@ -9,3 +9,6 @@
GENERATE_SHLIB_SCRIPT=yes
TEXT_START_SYMBOLS='_btext = .;'
ENTRY=_start
+# PR 17739. Delay checking relocs until after all files have
+# been opened and linker garbage collection has taken place.
+CHECK_RELOCS_AFTER_OPEN_INPUT=yes