This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/2] Update _bfd_elf_symbol_refs_local_p/add UNDEFINED_WEAK_RESOLVED_TO_ZERO


On 10/8/17, H.J. Lu <hjl.tools@gmail.com> wrote:
> On 10/8/17, Alan Modra <amodra@gmail.com> wrote:
>> On Fri, Oct 06, 2017 at 05:29:08PM -0700, H.J. Lu wrote:
>>> Update _bfd_elf_symbol_refs_local_p to cache result
>>
>> Caching the result is a really bad idea.  It's not as if the function
>> is anywhere near the top of any profiling result, and to cache return
>> value you need to be sure that the return value won't change between
>> the first call and the last in every target.  That isn't true, as even
>> a cursory examination of the code in _bfd_elf_symbol_refs_local_p
>> should reveal.  forced_local changes in many places!
>
> You are right.  This only works with
>
> CHECK_RELOCS_AFTER_OPEN_INPUT=yes
>
> which should also speedup check_relocs and GC.   It should be set
> for all ELF targets.
>

Here is a patch which does that.


-- 
H.J.
From 3dcdc15a5085ac3ef932a9efa87ba3d94927e767 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sun, 8 Oct 2017 20:54:44 -0700
Subject: [PATCH] ELF: Call check_relocs after opening all inputs

For all ELF targers, call check_relocs after opening all inputs and
garbage collection.  Since the symbol resolution is known, check_relocs
can be simplified.  Also garbage collection doesn't need to undo what
check_relocs has done for symbols which have been garbage collected.
Since ELF targets never see the removed sections, there is no need for
gc_sweep_hook.

ldemul_after_check_relocs is added for powerpc to support  --secure-plt,
--bss-plt and --sdata-got.
---
 bfd/elf32-ppc.c                   | 177 --------------------------------------
 bfd/elflink.c                     |   4 -
 ld/emulparams/elf32_x86_64.sh     |   1 -
 ld/emulparams/elf_i386.sh         |   1 -
 ld/emulparams/elf_i386_be.sh      |   1 -
 ld/emulparams/elf_i386_chaos.sh   |   1 -
 ld/emulparams/elf_i386_ldso.sh    |   1 -
 ld/emulparams/elf_i386_vxworks.sh |   1 -
 ld/emulparams/elf_iamcu.sh        |   1 -
 ld/emulparams/elf_k1om.sh         |   1 -
 ld/emulparams/elf_l1om.sh         |   1 -
 ld/emulparams/elf_x86_64.sh       |   1 -
 ld/emulparams/i386lynx.sh         |   1 -
 ld/emulparams/i386moss.sh         |   1 -
 ld/emulparams/i386nto.sh          |   1 -
 ld/emulparams/i386nw.sh           |   1 -
 ld/emulparams/shelf.sh            |   4 -
 ld/emulparams/shelf32.sh          |   3 -
 ld/emulparams/shelf_nto.sh        |   3 -
 ld/emulparams/shelf_vxworks.sh    |   3 -
 ld/emulparams/shlelf32_linux.sh   |   3 -
 ld/emulparams/shlelf_linux.sh     |   3 -
 ld/emulparams/shlelf_nto.sh       |   3 -
 ld/emultempl/aix.em               |   1 +
 ld/emultempl/armcoff.em           |   1 +
 ld/emultempl/beos.em              |   1 +
 ld/emultempl/elf32.em             |   3 +-
 ld/emultempl/generic.em           |   1 +
 ld/emultempl/gld960.em            |   1 +
 ld/emultempl/gld960c.em           |   1 +
 ld/emultempl/linux.em             |   1 +
 ld/emultempl/lnk960.em            |   1 +
 ld/emultempl/m68kcoff.em          |   1 +
 ld/emultempl/msp430.em            |   1 +
 ld/emultempl/pe.em                |   1 +
 ld/emultempl/pep.em               |   1 +
 ld/emultempl/ppc32elf.em          |   6 +-
 ld/emultempl/sunos.em             |   1 +
 ld/emultempl/ticoff.em            |   1 +
 ld/emultempl/vanilla.em           |   1 +
 ld/ldemul.c                       |  11 +++
 ld/ldemul.h                       |   7 ++
 ld/ldlang.c                       |   2 +
 43 files changed, 40 insertions(+), 221 deletions(-)

diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index bfd7e067b3..61b9359627 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -5135,182 +5135,6 @@ ppc_elf_gc_mark_hook (asection *sec,
 
   return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
-
-/* Update the got, plt and dynamic reloc reference counts for the
-   section being removed.  */
-
-static bfd_boolean
-ppc_elf_gc_sweep_hook (bfd *abfd,
-		       struct bfd_link_info *info,
-		       asection *sec,
-		       const Elf_Internal_Rela *relocs)
-{
-  struct ppc_elf_link_hash_table *htab;
-  Elf_Internal_Shdr *symtab_hdr;
-  struct elf_link_hash_entry **sym_hashes;
-  bfd_signed_vma *local_got_refcounts;
-  const Elf_Internal_Rela *rel, *relend;
-  asection *got2;
-
-  if (bfd_link_relocatable (info))
-    return TRUE;
-
-  if ((sec->flags & SEC_ALLOC) == 0)
-    return TRUE;
-
-  elf_section_data (sec)->local_dynrel = NULL;
-
-  htab = ppc_elf_hash_table (info);
-  symtab_hdr = &elf_symtab_hdr (abfd);
-  sym_hashes = elf_sym_hashes (abfd);
-  local_got_refcounts = elf_local_got_refcounts (abfd);
-  got2 = bfd_get_section_by_name (abfd, ".got2");
-
-  relend = relocs + sec->reloc_count;
-  for (rel = relocs; rel < relend; rel++)
-    {
-      unsigned long r_symndx;
-      enum elf_ppc_reloc_type r_type;
-      struct elf_link_hash_entry *h = NULL;
-
-      r_symndx = ELF32_R_SYM (rel->r_info);
-      if (r_symndx >= symtab_hdr->sh_info)
-	{
-	  struct elf_dyn_relocs **pp, *p;
-	  struct ppc_elf_link_hash_entry *eh;
-
-	  h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-	  while (h->root.type == bfd_link_hash_indirect
-		 || h->root.type == bfd_link_hash_warning)
-	    h = (struct elf_link_hash_entry *) h->root.u.i.link;
-	  eh = (struct ppc_elf_link_hash_entry *) h;
-
-	  for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
-	    if (p->sec == sec)
-	      {
-		/* Everything must go for SEC.  */
-		*pp = p->next;
-		break;
-	      }
-	}
-
-      r_type = ELF32_R_TYPE (rel->r_info);
-      if (!htab->is_vxworks
-	  && h == NULL
-	  && local_got_refcounts != NULL
-	  && (!bfd_link_pic (info)
-	      || is_branch_reloc (r_type)))
-	{
-	  struct plt_entry **local_plt = (struct plt_entry **)
-	    (local_got_refcounts + symtab_hdr->sh_info);
-	  char *local_got_tls_masks = (char *)
-	    (local_plt + symtab_hdr->sh_info);
-	  if ((local_got_tls_masks[r_symndx] & PLT_IFUNC) != 0)
-	    {
-	      struct plt_entry **ifunc = local_plt + r_symndx;
-	      bfd_vma addend = 0;
-	      struct plt_entry *ent;
-
-	      if (r_type == R_PPC_PLTREL24 && bfd_link_pic (info))
-		addend = rel->r_addend;
-	      ent = find_plt_ent (ifunc, got2, addend);
-	      if (ent->plt.refcount > 0)
-		ent->plt.refcount -= 1;
-	      continue;
-	    }
-	}
-
-      switch (r_type)
-	{
-	case R_PPC_GOT_TLSLD16:
-	case R_PPC_GOT_TLSLD16_LO:
-	case R_PPC_GOT_TLSLD16_HI:
-	case R_PPC_GOT_TLSLD16_HA:
-	case R_PPC_GOT_TLSGD16:
-	case R_PPC_GOT_TLSGD16_LO:
-	case R_PPC_GOT_TLSGD16_HI:
-	case R_PPC_GOT_TLSGD16_HA:
-	case R_PPC_GOT_TPREL16:
-	case R_PPC_GOT_TPREL16_LO:
-	case R_PPC_GOT_TPREL16_HI:
-	case R_PPC_GOT_TPREL16_HA:
-	case R_PPC_GOT_DTPREL16:
-	case R_PPC_GOT_DTPREL16_LO:
-	case R_PPC_GOT_DTPREL16_HI:
-	case R_PPC_GOT_DTPREL16_HA:
-	case R_PPC_GOT16:
-	case R_PPC_GOT16_LO:
-	case R_PPC_GOT16_HI:
-	case R_PPC_GOT16_HA:
-	  if (h != NULL)
-	    {
-	      if (h->got.refcount > 0)
-		h->got.refcount--;
-	      if (!bfd_link_pic (info))
-		{
-		  struct plt_entry *ent;
-
-		  ent = find_plt_ent (&h->plt.plist, NULL, 0);
-		  if (ent != NULL && ent->plt.refcount > 0)
-		    ent->plt.refcount -= 1;
-		}
-	    }
-	  else if (local_got_refcounts != NULL)
-	    {
-	      if (local_got_refcounts[r_symndx] > 0)
-		local_got_refcounts[r_symndx]--;
-	    }
-	  break;
-
-	case R_PPC_REL24:
-	case R_PPC_REL14:
-	case R_PPC_REL14_BRTAKEN:
-	case R_PPC_REL14_BRNTAKEN:
-	case R_PPC_REL32:
-	  if (h == NULL || h == htab->elf.hgot)
-	    break;
-	  /* Fall through.  */
-
-	case R_PPC_ADDR32:
-	case R_PPC_ADDR24:
-	case R_PPC_ADDR16:
-	case R_PPC_ADDR16_LO:
-	case R_PPC_ADDR16_HI:
-	case R_PPC_ADDR16_HA:
-	case R_PPC_ADDR14:
-	case R_PPC_ADDR14_BRTAKEN:
-	case R_PPC_ADDR14_BRNTAKEN:
-	case R_PPC_UADDR32:
-	case R_PPC_UADDR16:
-	  if (bfd_link_pic (info))
-	    break;
-	  /* Fall through.  */
-
-	case R_PPC_PLT32:
-	case R_PPC_PLTREL24:
-	case R_PPC_PLTREL32:
-	case R_PPC_PLT16_LO:
-	case R_PPC_PLT16_HI:
-	case R_PPC_PLT16_HA:
-	  if (h != NULL)
-	    {
-	      bfd_vma addend = 0;
-	      struct plt_entry *ent;
-
-	      if (r_type == R_PPC_PLTREL24 && bfd_link_pic (info))
-		addend = rel->r_addend;
-	      ent = find_plt_ent (&h->plt.plist, got2, addend);
-	      if (ent != NULL && ent->plt.refcount > 0)
-		ent->plt.refcount -= 1;
-	    }
-	  break;
-
-	default:
-	  break;
-	}
-    }
-  return TRUE;
-}
 
 /* Set plt output section type, htab->tls_get_addr, and call the
    generic ELF tls_setup function.  */
@@ -11021,7 +10845,6 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
 
 #define elf_backend_object_p			ppc_elf_object_p
 #define elf_backend_gc_mark_hook		ppc_elf_gc_mark_hook
-#define elf_backend_gc_sweep_hook		ppc_elf_gc_sweep_hook
 #define elf_backend_section_from_shdr		ppc_elf_section_from_shdr
 #define elf_backend_relocate_section		ppc_elf_relocate_section
 #define elf_backend_create_dynamic_sections	ppc_elf_create_dynamic_sections
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 1a990582cb..71f1bcfae8 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -5234,10 +5234,6 @@ error_free_dyn:
       && !(*bed->check_directives) (abfd, info))
     return FALSE;
 
-  if (!info->check_relocs_after_open_input
-      && !_bfd_elf_link_check_relocs (abfd, info))
-    return FALSE;
-
   /* If this is a non-traditional link, try to optimize the handling
      of the .stab/.stabstr sections.  */
   if (! dynamic
diff --git a/ld/emulparams/elf32_x86_64.sh b/ld/emulparams/elf32_x86_64.sh
index 06a0f3c6fe..38fb8d2504 100644
--- a/ld/emulparams/elf32_x86_64.sh
+++ b/ld/emulparams/elf32_x86_64.sh
@@ -7,7 +7,6 @@
 SCRIPT_NAME=elf
 ELFSIZE=32
 OUTPUT_FORMAT="elf32-x86-64"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
 NO_REL_RELOCS=yes
 TEXT_START_ADDR=0x400000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/elf_i386.sh b/ld/emulparams/elf_i386.sh
index 6997d40ba1..084497c230 100644
--- a/ld/emulparams/elf_i386.sh
+++ b/ld/emulparams/elf_i386.sh
@@ -5,7 +5,6 @@
 . ${srcdir}/emulparams/cet.sh
 SCRIPT_NAME=elf
 OUTPUT_FORMAT="elf32-i386"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
 NO_RELA_RELOCS=yes
 TEXT_START_ADDR=0x08048000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/elf_i386_be.sh b/ld/emulparams/elf_i386_be.sh
index 4a24b02012..70db443239 100644
--- a/ld/emulparams/elf_i386_be.sh
+++ b/ld/emulparams/elf_i386_be.sh
@@ -3,7 +3,6 @@
 . ${srcdir}/emulparams/call_nop.sh
 SCRIPT_NAME=elf
 OUTPUT_FORMAT="elf32-i386"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
 NO_RELA_RELOCS=yes
 TEXT_START_ADDR=0x80000000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/elf_i386_chaos.sh b/ld/emulparams/elf_i386_chaos.sh
index 5349108174..aa36cb51c2 100644
--- a/ld/emulparams/elf_i386_chaos.sh
+++ b/ld/emulparams/elf_i386_chaos.sh
@@ -4,7 +4,6 @@
 . ${srcdir}/emulparams/call_nop.sh
 SCRIPT_NAME=elf_chaos
 OUTPUT_FORMAT="elf32-i386"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
 TEXT_START_ADDR=0x40000000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
 ARCH=i386
diff --git a/ld/emulparams/elf_i386_ldso.sh b/ld/emulparams/elf_i386_ldso.sh
index dc4eef4889..1328520c57 100644
--- a/ld/emulparams/elf_i386_ldso.sh
+++ b/ld/emulparams/elf_i386_ldso.sh
@@ -4,7 +4,6 @@
 . ${srcdir}/emulparams/call_nop.sh
 SCRIPT_NAME=elf
 OUTPUT_FORMAT="elf32-i386"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
 NO_RELA_RELOCS=yes
 TEXT_START_ADDR=0x08048000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/elf_i386_vxworks.sh b/ld/emulparams/elf_i386_vxworks.sh
index ac1bbeb4e3..aaea8c4874 100644
--- a/ld/emulparams/elf_i386_vxworks.sh
+++ b/ld/emulparams/elf_i386_vxworks.sh
@@ -1,6 +1,5 @@
 SCRIPT_NAME=elf
 OUTPUT_FORMAT="elf32-i386-vxworks"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
 NO_RELA_RELOCS=yes
 TEXT_START_ADDR=0x08048000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/elf_iamcu.sh b/ld/emulparams/elf_iamcu.sh
index 45953e76d3..863027b57b 100644
--- a/ld/emulparams/elf_iamcu.sh
+++ b/ld/emulparams/elf_iamcu.sh
@@ -4,7 +4,6 @@
 . ${srcdir}/emulparams/call_nop.sh
 SCRIPT_NAME=elf
 OUTPUT_FORMAT="elf32-iamcu"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
 NO_RELA_RELOCS=yes
 TEXT_START_ADDR=0x08048000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/elf_k1om.sh b/ld/emulparams/elf_k1om.sh
index 828c10efc9..494efcc6c9 100644
--- a/ld/emulparams/elf_k1om.sh
+++ b/ld/emulparams/elf_k1om.sh
@@ -5,7 +5,6 @@
 SCRIPT_NAME=elf
 ELFSIZE=64
 OUTPUT_FORMAT="elf64-k1om"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
 NO_REL_RELOCS=yes
 TEXT_START_ADDR=0x400000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/elf_l1om.sh b/ld/emulparams/elf_l1om.sh
index 9c59dc07a5..b1158791f4 100644
--- a/ld/emulparams/elf_l1om.sh
+++ b/ld/emulparams/elf_l1om.sh
@@ -5,7 +5,6 @@
 SCRIPT_NAME=elf
 ELFSIZE=64
 OUTPUT_FORMAT="elf64-l1om"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
 NO_REL_RELOCS=yes
 TEXT_START_ADDR=0x400000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/elf_x86_64.sh b/ld/emulparams/elf_x86_64.sh
index ad255266fc..66af30c90c 100644
--- a/ld/emulparams/elf_x86_64.sh
+++ b/ld/emulparams/elf_x86_64.sh
@@ -7,7 +7,6 @@
 SCRIPT_NAME=elf
 ELFSIZE=64
 OUTPUT_FORMAT="elf64-x86-64"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
 NO_REL_RELOCS=yes
 TEXT_START_ADDR=0x400000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/i386lynx.sh b/ld/emulparams/i386lynx.sh
index 12bc7daa6a..93afb3d7f3 100644
--- a/ld/emulparams/i386lynx.sh
+++ b/ld/emulparams/i386lynx.sh
@@ -1,6 +1,5 @@
 SCRIPT_NAME=elf
 OUTPUT_FORMAT="elf32-i386"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
 NO_RELA_RELOCS=yes
 ENTRY=_main
 TEXT_BASE=0x0
diff --git a/ld/emulparams/i386moss.sh b/ld/emulparams/i386moss.sh
index bffef867a7..095d85ab92 100644
--- a/ld/emulparams/i386moss.sh
+++ b/ld/emulparams/i386moss.sh
@@ -1,6 +1,5 @@
 SCRIPT_NAME=elf
 OUTPUT_FORMAT="elf32-i386"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
 NO_RELA_RELOCS=yes
 TEXT_START_ADDR=0x00002000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
diff --git a/ld/emulparams/i386nto.sh b/ld/emulparams/i386nto.sh
index 51284be2bd..626f9c13aa 100644
--- a/ld/emulparams/i386nto.sh
+++ b/ld/emulparams/i386nto.sh
@@ -1,6 +1,5 @@
 SCRIPT_NAME=elf
 OUTPUT_FORMAT="elf32-i386"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
 NO_RELA_RELOCS=yes
 TEXT_START_ADDR=0x08048000
 TEXT_START_SYMBOLS='_btext = .;'
diff --git a/ld/emulparams/i386nw.sh b/ld/emulparams/i386nw.sh
index e6397f6879..e1897bef95 100644
--- a/ld/emulparams/i386nw.sh
+++ b/ld/emulparams/i386nw.sh
@@ -1,6 +1,5 @@
 SCRIPT_NAME=nw
 OUTPUT_FORMAT="elf32-i386"
-CHECK_RELOCS_AFTER_OPEN_INPUT=yes
 TEXT_START_ADDR=0x08000000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
 ARCH=i386
diff --git a/ld/emulparams/shelf.sh b/ld/emulparams/shelf.sh
index 8d79b8d86c..5b34319490 100644
--- a/ld/emulparams/shelf.sh
+++ b/ld/emulparams/shelf.sh
@@ -11,10 +11,6 @@ MACHINE=
 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
 CTOR_START='___ctors = .;'
diff --git a/ld/emulparams/shelf32.sh b/ld/emulparams/shelf32.sh
index 7f4640730d..3fc9a3e518 100644
--- a/ld/emulparams/shelf32.sh
+++ b/ld/emulparams/shelf32.sh
@@ -11,9 +11,6 @@ ALIGNMENT=8
 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 46efd87896..c4d71aa999 100644
--- a/ld/emulparams/shelf_nto.sh
+++ b/ld/emulparams/shelf_nto.sh
@@ -9,6 +9,3 @@ TEMPLATE_NAME=elf32
 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 759ffac288..c45099046e 100644
--- a/ld/emulparams/shelf_vxworks.sh
+++ b/ld/emulparams/shelf_vxworks.sh
@@ -14,9 +14,6 @@ TEMPLATE_NAME=elf32
 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_ = .);
diff --git a/ld/emulparams/shlelf32_linux.sh b/ld/emulparams/shlelf32_linux.sh
index 0327e57ad6..03f6d9a7e4 100644
--- a/ld/emulparams/shlelf32_linux.sh
+++ b/ld/emulparams/shlelf32_linux.sh
@@ -13,9 +13,6 @@ ALIGNMENT=8
 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 4e2a5813f2..c14aae228d 100644
--- a/ld/emulparams/shlelf_linux.sh
+++ b/ld/emulparams/shlelf_linux.sh
@@ -12,9 +12,6 @@ MACHINE=
 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 f8ffc13b36..16f65087eb 100644
--- a/ld/emulparams/shlelf_nto.sh
+++ b/ld/emulparams/shlelf_nto.sh
@@ -9,6 +9,3 @@ TEMPLATE_NAME=elf32
 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/emultempl/aix.em b/ld/emultempl/aix.em
index 02fe282215..cb06fbaa8c 100644
--- a/ld/emultempl/aix.em
+++ b/ld/emultempl/aix.em
@@ -1534,6 +1534,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = {
   hll_default,
   after_parse_default,
   gld${EMULATION_NAME}_after_open,
+  after_check_relocs_default,
   after_allocation_default,
   gld${EMULATION_NAME}_set_output_arch,
   gld${EMULATION_NAME}_choose_target,
diff --git a/ld/emultempl/armcoff.em b/ld/emultempl/armcoff.em
index 93ffb65b1a..1de050dbc0 100644
--- a/ld/emultempl/armcoff.em
+++ b/ld/emultempl/armcoff.em
@@ -260,6 +260,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   hll_default,
   after_parse_default,
   gld${EMULATION_NAME}_after_open,
+  after_check_relocs_default,
   after_allocation_default,
   set_output_arch_default,
   ldemul_default_target,
diff --git a/ld/emultempl/beos.em b/ld/emultempl/beos.em
index 9a67ff8ae2..8ce3ba4227 100644
--- a/ld/emultempl/beos.em
+++ b/ld/emultempl/beos.em
@@ -758,6 +758,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   hll_default,
   after_parse_default,
   gld_${EMULATION_NAME}_after_open,
+  after_check_relocs_default,
   after_allocation_default,
   set_output_arch_default,
   ldemul_default_target,
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 748f56b844..99e4df312b 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -104,7 +104,7 @@ gld${EMULATION_NAME}_before_parse (void)
   config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
   config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
   `if test -n "$CALL_NOP_BYTE" ; then echo link_info.call_nop_byte = $CALL_NOP_BYTE; fi`;
-  link_info.check_relocs_after_open_input = `if test "x${CHECK_RELOCS_AFTER_OPEN_INPUT}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
+  link_info.check_relocs_after_open_input = TRUE;
   link_info.relro = DEFAULT_LD_Z_RELRO;
 }
 
@@ -2803,6 +2803,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   ${LDEMUL_HLL-hll_default},
   ${LDEMUL_AFTER_PARSE-gld${EMULATION_NAME}_after_parse},
   ${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open},
+  ${LDEMUL_AFTER_CHECK_RELOCS-after_check_relocs_default},
   ${LDEMUL_AFTER_ALLOCATION-gld${EMULATION_NAME}_after_allocation},
   ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
   ${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
diff --git a/ld/emultempl/generic.em b/ld/emultempl/generic.em
index 55a19a8168..9a54ba2acb 100644
--- a/ld/emultempl/generic.em
+++ b/ld/emultempl/generic.em
@@ -136,6 +136,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   ${LDEMUL_HLL-hll_default},
   ${LDEMUL_AFTER_PARSE-after_parse_default},
   ${LDEMUL_AFTER_OPEN-after_open_default},
+  ${LDEMUL_AFTER_CHECK_RELOCS-after_check_relocs_default},
   ${LDEMUL_AFTER_ALLOCATION-after_allocation_default},
   ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
   ${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
diff --git a/ld/emultempl/gld960.em b/ld/emultempl/gld960.em
index 683bb819f8..9489462ef1 100644
--- a/ld/emultempl/gld960.em
+++ b/ld/emultempl/gld960.em
@@ -129,6 +129,7 @@ struct ld_emulation_xfer_struct ld_gld960_emulation =
   hll_default,
   after_parse_default,
   after_open_default,
+  after_check_relocs_default,
   after_allocation_default,
   gld960_set_output_arch,
   gld960_choose_target,
diff --git a/ld/emultempl/gld960c.em b/ld/emultempl/gld960c.em
index 7bbb83a8d5..1b4d09abcc 100644
--- a/ld/emultempl/gld960c.em
+++ b/ld/emultempl/gld960c.em
@@ -142,6 +142,7 @@ struct ld_emulation_xfer_struct ld_gld960coff_emulation =
   hll_default,
   after_parse_default,
   after_open_default,
+  after_check_relocs_default,
   after_allocation_default,
   gld960_set_output_arch,
   gld960_choose_target,
diff --git a/ld/emultempl/linux.em b/ld/emultempl/linux.em
index d9cfd24e42..e1efb5bee9 100644
--- a/ld/emultempl/linux.em
+++ b/ld/emultempl/linux.em
@@ -187,6 +187,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   hll_default,
   after_parse_default,
   after_open_default,
+  after_check_relocs_default,
   after_allocation_default,
   set_output_arch_default,
   ldemul_default_target,
diff --git a/ld/emultempl/lnk960.em b/ld/emultempl/lnk960.em
index 9f68f26275..b8b28b9596 100644
--- a/ld/emultempl/lnk960.em
+++ b/ld/emultempl/lnk960.em
@@ -323,6 +323,7 @@ struct ld_emulation_xfer_struct ld_lnk960_emulation =
   lnk960_hll,
   lnk960_after_parse,
   after_open_default,
+  after_check_relocs_default,
   lnk960_after_allocation,
   lnk960_set_output_arch,
   lnk960_choose_target,
diff --git a/ld/emultempl/m68kcoff.em b/ld/emultempl/m68kcoff.em
index 22e1912340..8505b04c2b 100644
--- a/ld/emultempl/m68kcoff.em
+++ b/ld/emultempl/m68kcoff.em
@@ -219,6 +219,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   syslib_default,
   hll_default,
   after_parse_default,
+  after_check_relocs_default,
   gld${EMULATION_NAME}_after_open,
   gld${EMULATION_NAME}_after_allocation,
   set_output_arch_default,
diff --git a/ld/emultempl/msp430.em b/ld/emultempl/msp430.em
index a956a2fb9a..01b5b888c3 100644
--- a/ld/emultempl/msp430.em
+++ b/ld/emultempl/msp430.em
@@ -838,6 +838,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   ${LDEMUL_HLL-hll_default},
   ${LDEMUL_AFTER_PARSE-after_parse_default},
   msp430_elf_after_open,
+  after_check_relocs_default,
   msp430_elf_after_allocation,
   ${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
   ${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index 16d28e234b..100c650949 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -2473,6 +2473,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   hll_default,
   gld_${EMULATION_NAME}_after_parse,
   gld_${EMULATION_NAME}_after_open,
+  after_check_relocs_default,
   after_allocation_default,
   set_output_arch_default,
   ldemul_default_target,
diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em
index 420ffa849e..f24f487901 100644
--- a/ld/emultempl/pep.em
+++ b/ld/emultempl/pep.em
@@ -2247,6 +2247,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   hll_default,
   gld_${EMULATION_NAME}_after_parse,
   gld_${EMULATION_NAME}_after_open,
+  after_check_relocs_default,
   after_allocation_default,
   set_output_arch_default,
   ldemul_default_target,
diff --git a/ld/emultempl/ppc32elf.em b/ld/emultempl/ppc32elf.em
index 1012bc9912..a208b1d3fa 100644
--- a/ld/emultempl/ppc32elf.em
+++ b/ld/emultempl/ppc32elf.em
@@ -57,7 +57,7 @@ EOF
 if test -z "$VXWORKS_BASE_EM_FILE" ; then
   fragment <<EOF
 static void
-ppc_after_open (void)
+ppc_after_check_relocs (void)
 {
   if (is_ppc_elf (link_info.output_bfd))
     {
@@ -108,7 +108,7 @@ ppc_after_open (void)
 	}
     }
 
-  gld${EMULATION_NAME}_after_open ();
+  after_check_relocs_default ();
 }
 
 EOF
@@ -355,7 +355,7 @@ PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}'
 #
 LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=ppc_after_open_output
 if test -z "$VXWORKS_BASE_EM_FILE" ; then
-  LDEMUL_AFTER_OPEN=ppc_after_open
+  LDEMUL_AFTER_CHECK_RELOCS=ppc_after_check_relocs
 fi
 LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation
 LDEMUL_FINISH=ppc_finish
diff --git a/ld/emultempl/sunos.em b/ld/emultempl/sunos.em
index be6375a5dd..4ae16ea2a3 100644
--- a/ld/emultempl/sunos.em
+++ b/ld/emultempl/sunos.em
@@ -1016,6 +1016,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   hll_default,
   after_parse_default,
   gld${EMULATION_NAME}_after_open,
+  after_check_relocs_default,
   after_allocation_default,
   set_output_arch_default,
   ldemul_default_target,
diff --git a/ld/emultempl/ticoff.em b/ld/emultempl/ticoff.em
index 926dbd9f94..d465d23d40 100644
--- a/ld/emultempl/ticoff.em
+++ b/ld/emultempl/ticoff.em
@@ -161,6 +161,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
   hll_default,
   after_parse_default,
   after_open_default,
+  after_check_relocs_default,
   after_allocation_default,
   set_output_arch_default,
   ldemul_default_target,
diff --git a/ld/emultempl/vanilla.em b/ld/emultempl/vanilla.em
index 3d8dc44f06..83837b9bac 100644
--- a/ld/emultempl/vanilla.em
+++ b/ld/emultempl/vanilla.em
@@ -62,6 +62,7 @@ struct ld_emulation_xfer_struct ld_vanilla_emulation =
   hll_default,
   after_parse_default,
   after_open_default,
+  after_check_relocs_default,
   after_allocation_default,
   vanilla_set_output_arch,
   ldemul_default_target,
diff --git a/ld/ldemul.c b/ld/ldemul.c
index cebf012e78..96c4b8bc33 100644
--- a/ld/ldemul.c
+++ b/ld/ldemul.c
@@ -65,6 +65,12 @@ ldemul_after_open (void)
 }
 
 void
+ldemul_after_check_relocs (void)
+{
+  ld_emulation->after_check_relocs ();
+}
+
+void
 ldemul_after_allocation (void)
 {
   ld_emulation->after_allocation ();
@@ -227,6 +233,11 @@ after_open_default (void)
 }
 
 void
+after_check_relocs_default (void)
+{
+}
+
+void
 after_allocation_default (void)
 {
   lang_relax_sections (FALSE);
diff --git a/ld/ldemul.h b/ld/ldemul.h
index 8e9bd2e952..631a038767 100644
--- a/ld/ldemul.h
+++ b/ld/ldemul.h
@@ -34,6 +34,8 @@ extern void ldemul_before_parse
   (void);
 extern void ldemul_after_open
   (void);
+extern void ldemul_after_check_relocs
+  (void);
 extern void ldemul_after_allocation
   (void);
 extern void ldemul_before_allocation
@@ -76,6 +78,8 @@ extern void after_parse_default
   (void);
 extern void after_open_default
   (void);
+extern void after_check_relocs_default
+  (void);
 extern void after_allocation_default
   (void);
 extern void before_allocation_default
@@ -114,6 +118,9 @@ typedef struct ld_emulation_xfer_struct {
   /* Run after opening all input files, and loading the symbols.  */
   void   (*after_open) (void);
 
+  /* Run after checking relocations.  */
+  void   (*after_check_relocs)  (void);
+
   /* Run after allocating output sections.  */
   void   (*after_allocation)  (void);
 
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 7b80bf9dc1..05189d952c 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -7259,6 +7259,8 @@ lang_process (void)
   /* Check relocations.  */
   lang_check_relocs ();
 
+  ldemul_after_check_relocs ();
+
   /* Update wild statements.  */
   update_wild_statements (statement_list.head);
 
-- 
2.13.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]