[binutils-gdb] elf: Cache ".interp" section pointer in elf_link_hash_table

H.J. Lu hjl@sourceware.org
Thu Sep 18 11:36:30 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=18bc39c833389e0927f04809741affc66134e79e

commit 18bc39c833389e0927f04809741affc66134e79e
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun Sep 14 14:40:16 2025 -0700

    elf: Cache ".interp" section pointer in elf_link_hash_table
    
    Cache ".interp" section pointer in elf_link_hash_table so that a backend
    can use it to avoid calling bfd_get_linker_section.
    
            * elf-bfd.h (elf_link_hash_table): Add interp.
            * elf-m10300.c (_bfd_mn10300_elf_late_size_sections): Use the
            interp field in elf_link_hash_table.
            * elf32-arc.c (elf_arc_late_size_sections): Likewise.
            * elf32-arm.c (elf32_arm_late_size_sections): Likewise.
            * elf32-bfin.c (elf32_bfinfdpic_late_size_sections): Likewise.
            (bfin_late_size_sections): Likewise.
            * elf32-cr16.c (_bfd_cr16_elf_late_size_sections): Likewise.
            * elf32-cris.c (elf_cris_late_size_sections): Likewise.
            * elf32-csky.c (csky_elf_late_size_sections): Likewise.
            * elf32-frv.c (elf32_frvfdpic_late_size_sections): Likewise.
            * elf32-hppa.c (elf32_hppa_late_size_sections): Likewise.
            * elf32-lm32.c (lm32_elf_late_size_sections): Likewise.
            * elf32-m32r.c (m32r_elf_late_size_sections): Likewise.
            * elf32-m68k.c (elf_m68k_late_size_sections): Likewise.
            * elf32-metag.c (elf_metag_late_size_sections): Likewise.
            * elf32-nds32.c (nds32_elf_late_size_sections): Likewise.
            * elf32-or1k.c (or1k_elf_late_size_sections): Likewise.
            * elf32-ppc.c (ppc_elf_late_size_sections): Likewise.
            * elf32-s390.c (elf_s390_late_size_sections): Likewise.
            * elf32-score.c (s3_bfd_score_elf_late_size_sections): Likewise.
            * elf32-score7.c (s7_bfd_score_elf_late_size_sections): Likewise.
            * elf32-sh.c (sh_elf_late_size_sections): Likewise.
            * elf32-tic6x.c (elf32_tic6x_late_size_sections): Likewise.
            * elf32-tilepro.c (tilepro_elf_late_size_sections): Likewise.
            * elf32-vax.c (elf_vax_late_size_sections): Likewise.
            * elf32-xtensa.c (elf_xtensa_late_size_sections): Likewise.
            * elf64-alpha.c (elf64_alpha_late_size_sections): Likewise.
            * elf64-hppa.c (elf64_hppa_late_size_sections): Likewise.
            * elf64-ppc.c (ppc64_elf_late_size_sections): Likewise.
            * elf64-s390.c (elf_s390_late_size_sections): Likewise.
            * elfnn-aarch64.c (elfNN_aarch64_late_size_sections): Likewise.
            * elfnn-ia64.c (elfNN_ia64_late_size_sections): Likewise.
            * elfnn-kvx.c (elfNN_kvx_late_size_sections): Likewise.
            * elfnn-loongarch.c (loongarch_elf_late_size_sections): Likewise.
            * elfnn-riscv.c (riscv_elf_late_size_sections): Likewise.
            * elfxx-mips.c (_bfd_mips_elf_late_size_sections): Likewise.
            * elfxx-tilegx.c (tilegx_elf_late_size_sections): Likewise.
            * elflink.c (_bfd_elf_link_create_dynamic_sections): Cache the
            pointer to ".interp" section in the interp field in
            elf_link_hash_table.
            (bfd_elf_size_dynamic_sections): Use the interp field in
            elf_link_hash_table.
            * elfxx-sparc.c (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Use the
            interp field in elf_link_hash_table.
            (_bfd_sparc_elf_late_size_sections): Likewise.  Don't set
            interp.
            * elfxx-sparc.h (_bfd_sparc_elf_link_hash_table): Remove interp.
            * elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Check
            htab->elf.interp instead of htab->interp.
            (_bfd_x86_elf_link_setup_gnu_properties): Use htab->elf.interp.
            * elfxx-x86.h (elf_x86_link_hash_table): Remove interp.
    
    Signed-off-by: H.J. Lu <hjl.tools@gmail.com>

Diff:
---
 bfd/elf-bfd.h         | 1 +
 bfd/elf-m10300.c      | 2 +-
 bfd/elf32-arc.c       | 2 +-
 bfd/elf32-arm.c       | 2 +-
 bfd/elf32-bfin.c      | 4 ++--
 bfd/elf32-cr16.c      | 2 +-
 bfd/elf32-cris.c      | 2 +-
 bfd/elf32-csky.c      | 2 +-
 bfd/elf32-frv.c       | 2 +-
 bfd/elf32-hppa.c      | 2 +-
 bfd/elf32-lm32.c      | 2 +-
 bfd/elf32-m32r.c      | 2 +-
 bfd/elf32-m68k.c      | 2 +-
 bfd/elf32-metag.c     | 2 +-
 bfd/elf32-nds32.c     | 2 +-
 bfd/elf32-or1k.c      | 2 +-
 bfd/elf32-ppc.c       | 2 +-
 bfd/elf32-s390.c      | 2 +-
 bfd/elf32-score.c     | 2 +-
 bfd/elf32-score7.c    | 2 +-
 bfd/elf32-sh.c        | 2 +-
 bfd/elf32-tic6x.c     | 2 +-
 bfd/elf32-tilepro.c   | 2 +-
 bfd/elf32-vax.c       | 2 +-
 bfd/elf32-xtensa.c    | 2 +-
 bfd/elf64-alpha.c     | 2 +-
 bfd/elf64-hppa.c      | 2 +-
 bfd/elf64-ppc.c       | 2 +-
 bfd/elf64-s390.c      | 2 +-
 bfd/elflink.c         | 3 ++-
 bfd/elfnn-aarch64.c   | 2 +-
 bfd/elfnn-ia64.c      | 2 +-
 bfd/elfnn-kvx.c       | 2 +-
 bfd/elfnn-loongarch.c | 2 +-
 bfd/elfnn-riscv.c     | 2 +-
 bfd/elfxx-mips.c      | 2 +-
 bfd/elfxx-sparc.c     | 5 ++---
 bfd/elfxx-sparc.h     | 3 ---
 bfd/elfxx-tilegx.c    | 2 +-
 bfd/elfxx-x86.c       | 9 +++------
 bfd/elfxx-x86.h       | 1 -
 41 files changed, 44 insertions(+), 50 deletions(-)

diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index de7cc410a99..51e6ae7bb78 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -774,6 +774,7 @@ struct elf_link_hash_table
   asection *dynsym;
   asection *srelrdyn;
   asection *dynamic;
+  asection *interp;
 };
 
 /* Returns TRUE if the hash table is a struct elf_link_hash_table.  */
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index ba993869e28..b381bb9037c 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -5031,7 +5031,7 @@ _bfd_mn10300_elf_late_size_sections (bfd * output_bfd,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = elf_hash_table (info)->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c
index a78516dc12f..ebfe4dcc26a 100644
--- a/bfd/elf32-arc.c
+++ b/bfd/elf32-arc.c
@@ -2743,7 +2743,7 @@ elf_arc_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
 	 interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = htab->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof (ELF_DYNAMIC_INTERPRETER);
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index df60430b7c3..ae3dc246be0 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -16693,7 +16693,7 @@ elf32_arm_late_size_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = elf_hash_table (info)->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c
index 249c6b52af0..7ed1285f4c2 100644
--- a/bfd/elf32-bfin.c
+++ b/bfd/elf32-bfin.c
@@ -4050,7 +4050,7 @@ elf32_bfinfdpic_late_size_sections (bfd *output_bfd,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = htab->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER;
@@ -5142,7 +5142,7 @@ bfin_late_size_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = elf_hash_table (info)->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c
index fc2e2d48f27..31d1ba41c17 100644
--- a/bfd/elf32-cr16.c
+++ b/bfd/elf32-cr16.c
@@ -2408,7 +2408,7 @@ _bfd_cr16_elf_late_size_sections (bfd * output_bfd,
       if (bfd_link_executable (info) && !info->nointerp)
 	{
 #if 0
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = elf_hash_table (info)->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c
index 285c6c794a2..faaebb9ebee 100644
--- a/bfd/elf32-cris.c
+++ b/bfd/elf32-cris.c
@@ -3527,7 +3527,7 @@ elf_cris_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = htab->root.interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-csky.c b/bfd/elf32-csky.c
index 2a08659f06f..40781a0e1bb 100644
--- a/bfd/elf32-csky.c
+++ b/bfd/elf32-csky.c
@@ -1912,7 +1912,7 @@ csky_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       /* Set the contents of the .interp section to the interpreter.  */
       if (!bfd_link_pic (info) && !info->nointerp)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = htab->elf.interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c
index 0423540cf98..b7183133ad1 100644
--- a/bfd/elf32-frv.c
+++ b/bfd/elf32-frv.c
@@ -5444,7 +5444,7 @@ elf32_frvfdpic_late_size_sections (bfd *output_bfd,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = elf_hash_table (info)->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 80b89fac38b..2f463e12829 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -2063,7 +2063,7 @@ elf32_hppa_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  sec = bfd_get_linker_section (dynobj, ".interp");
+	  sec = htab->etab.interp;
 	  if (sec == NULL)
 	    abort ();
 	  sec->size = sizeof ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c
index b36e92d150a..0ead0df9cf0 100644
--- a/bfd/elf32-lm32.c
+++ b/bfd/elf32-lm32.c
@@ -1926,7 +1926,7 @@ lm32_elf_late_size_sections (bfd *output_bfd,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = htab->root.interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c
index 49cc5fc4240..c51133090b4 100644
--- a/bfd/elf32-m32r.c
+++ b/bfd/elf32-m32r.c
@@ -1983,7 +1983,7 @@ m32r_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = htab->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index 84ad64ac0ec..44ef102ea60 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -3122,7 +3122,7 @@ elf_m68k_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = elf_hash_table (info)->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-metag.c b/bfd/elf32-metag.c
index 0e6cfd885fe..916f3e15c72 100644
--- a/bfd/elf32-metag.c
+++ b/bfd/elf32-metag.c
@@ -2698,7 +2698,7 @@ elf_metag_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = htab->etab.interp;
 	  if (s == NULL)
 	    abort ();
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c
index bcd7c42e300..e22b58c4ea8 100644
--- a/bfd/elf32-nds32.c
+++ b/bfd/elf32-nds32.c
@@ -4326,7 +4326,7 @@ nds32_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = elf_hash_table (info)->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
index b17a872f123..159308fec74 100644
--- a/bfd/elf32-or1k.c
+++ b/bfd/elf32-or1k.c
@@ -3066,7 +3066,7 @@ or1k_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_section_by_name (dynobj, ".interp");
+	  s = htab->root.interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 1ed995bfb00..a3adcf8430e 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -5485,7 +5485,7 @@ ppc_elf_late_size_sections (bfd *output_bfd,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (htab->elf.dynobj, ".interp");
+	  s = elf_hash_table (info)->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index 40fcb53ff3a..56c613dd7d7 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -1793,7 +1793,7 @@ elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = htab->elf.interp;
 	  if (s == NULL)
 	    abort ();
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c
index 57bf04d9366..d91f2dedcf5 100644
--- a/bfd/elf32-score.c
+++ b/bfd/elf32-score.c
@@ -3243,7 +3243,7 @@ s3_bfd_score_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = elf_hash_table (info)->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = strlen (ELF_DYNAMIC_INTERPRETER) + 1;
 	  s->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c
index cbbff13933e..44718f39ccf 100644
--- a/bfd/elf32-score7.c
+++ b/bfd/elf32-score7.c
@@ -3053,7 +3053,7 @@ s7_bfd_score_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = elf_hash_table (info)->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = strlen (ELF_DYNAMIC_INTERPRETER) + 1;
 	  s->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index d3f3a567589..e078e41b675 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -2962,7 +2962,7 @@ sh_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = htab->root.interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c
index cc204c2ca08..a31c381531e 100644
--- a/bfd/elf32-tic6x.c
+++ b/bfd/elf32-tic6x.c
@@ -3171,7 +3171,7 @@ elf32_tic6x_late_size_sections (bfd *output_bfd, struct bfd_link_info *info)
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = htab->elf.interp;
 	  if (s == NULL)
 	    abort ();
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-tilepro.c b/bfd/elf32-tilepro.c
index 3e3a068ac7b..12ff2a9121f 100644
--- a/bfd/elf32-tilepro.c
+++ b/bfd/elf32-tilepro.c
@@ -2199,7 +2199,7 @@ tilepro_elf_late_size_sections (bfd *output_bfd,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = elf_hash_table (info)->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF32_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF32_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c
index 4cb69ad3117..a5ced1f6958 100644
--- a/bfd/elf32-vax.c
+++ b/bfd/elf32-vax.c
@@ -1037,7 +1037,7 @@ elf_vax_late_size_sections (bfd *output_bfd, struct bfd_link_info *info)
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = elf_hash_table (info)->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 6f8a4fa7c21..b21676df36a 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -1588,7 +1588,7 @@ elf_xtensa_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = elf_hash_table (info)->interp;
 	  if (s == NULL)
 	    abort ();
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index 55aebca0ee8..b13c99e4958 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -2809,7 +2809,7 @@ elf64_alpha_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = elf_hash_table (info)->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index 7b80603fdaf..57de68c9b07 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -1555,7 +1555,7 @@ elf64_hppa_late_size_sections (bfd *output_bfd, struct bfd_link_info *info)
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  sec = bfd_get_linker_section (dynobj, ".interp");
+	  sec = hppa_info->root.interp;
 	  BFD_ASSERT (sec != NULL);
 	  sec->size = sizeof ELF_DYNAMIC_INTERPRETER;
 	  sec->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 2cacc9e27a2..fdda9e0bbb3 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -10250,7 +10250,7 @@ ppc64_elf_late_size_sections (bfd *output_bfd,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = htab->elf.interp;
 	  if (s == NULL)
 	    abort ();
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index 6ae62a91112..555395ca5ad 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -1946,7 +1946,7 @@ elf_s390_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = htab->elf.interp;
 	  if (s == NULL)
 	    abort ();
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 53ec792852c..b04b017747f 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -354,6 +354,7 @@ _bfd_elf_link_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
 					      flags | SEC_READONLY);
       if (s == NULL)
 	return false;
+      elf_hash_table (info)->interp = s;
     }
 
   /* Create sections to hold version informations.  These are removed
@@ -7547,7 +7548,7 @@ NOTE: This behaviour is deprecated and will be removed in a future version of th
       asection *dynstr;
       asection *s;
 
-      *sinterpptr = bfd_get_linker_section (dynobj, ".interp");
+      *sinterpptr = elf_hash_table (info)->interp;
       BFD_ASSERT (*sinterpptr != NULL || !bfd_link_executable (info) || info->nointerp);
 
       if (info->symbolic)
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 4517567a554..3c3c2899674 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -9486,7 +9486,7 @@ elfNN_aarch64_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
     {
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = htab->root.interp;
 	  if (s == NULL)
 	    abort ();
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c
index 685a37f4072..528b1dcdcc3 100644
--- a/bfd/elfnn-ia64.c
+++ b/bfd/elfnn-ia64.c
@@ -3007,7 +3007,7 @@ elfNN_ia64_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   if (ia64_info->root.dynamic_sections_created
       && bfd_link_executable (info) && !info->nointerp)
     {
-      sec = bfd_get_linker_section (dynobj, ".interp");
+      sec = ia64_info->root.interp;
       BFD_ASSERT (sec != NULL);
       sec->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER;
       sec->alloced = 1;
diff --git a/bfd/elfnn-kvx.c b/bfd/elfnn-kvx.c
index 0634ad389d5..3b44db57421 100644
--- a/bfd/elfnn-kvx.c
+++ b/bfd/elfnn-kvx.c
@@ -4046,7 +4046,7 @@ elfNN_kvx_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
     {
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = htab->root.interp;
 	  if (s == NULL)
 	    abort ();
 	  s->size = sizeof ELF_DYNAMIC_INTERPRETER;
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index 8beb3d84079..c7b3711de86 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -2384,7 +2384,7 @@ loongarch_elf_late_size_sections (bfd *output_bfd,
       if (bfd_link_executable (info) && !info->nointerp)
 	{
 	  const char *interpreter;
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = htab->elf.interp;
 	  BFD_ASSERT (s != NULL);
 
 	  if (elf_elfheader (output_bfd)->e_ident[EI_CLASS] == ELFCLASS32)
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index aac061fb43d..09cf7076733 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -1711,7 +1711,7 @@ riscv_elf_late_size_sections (bfd *output_bfd, struct bfd_link_info *info)
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = elf_hash_table (info)->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = strlen (ELFNN_DYNAMIC_INTERPRETER) + 1;
 	  s->contents = (unsigned char *) ELFNN_DYNAMIC_INTERPRETER;
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index a171af59bf8..bf3fd7df805 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -10075,7 +10075,7 @@ _bfd_mips_elf_late_size_sections (bfd *output_bfd,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = htab->root.interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size
 	    = strlen (ELF_DYNAMIC_INTERPRETER (output_bfd)) + 1;
diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index f0b379555af..bbaa7829132 100644
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -679,7 +679,7 @@ _bfd_sparc_elf_info_to_howto (bfd *abfd, arelent *cache_ptr,
 #define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, EH)		\
   ((EH)->elf.root.type == bfd_link_hash_undefweak		\
    && bfd_link_executable (INFO)				\
-   && (_bfd_sparc_elf_hash_table (INFO)->interp == NULL		\
+   && (_bfd_sparc_elf_hash_table (INFO)->elf.interp == NULL	\
        || !(INFO)->dynamic_undefined_weak			\
        || (EH)->has_non_got_reloc				\
        || !(EH)->has_got_reloc))
@@ -2408,12 +2408,11 @@ _bfd_sparc_elf_late_size_sections (bfd *output_bfd,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = elf_hash_table (info)->interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = htab->dynamic_interpreter_size;
 	  s->contents = (unsigned char *) htab->dynamic_interpreter;
 	  s->alloced = 1;
-	  htab->interp = s;
 	}
     }
 
diff --git a/bfd/elfxx-sparc.h b/bfd/elfxx-sparc.h
index 633b10e55e9..572c2331112 100644
--- a/bfd/elfxx-sparc.h
+++ b/bfd/elfxx-sparc.h
@@ -46,9 +46,6 @@ struct _bfd_sparc_elf_link_hash_table
 {
   struct elf_link_hash_table elf;
 
-  /* Short-cut to get to dynamic linker sections.  */
-  asection *interp;
-
   union
   {
     bfd_signed_vma refcount;
diff --git a/bfd/elfxx-tilegx.c b/bfd/elfxx-tilegx.c
index 1854e693931..79358e6b204 100644
--- a/bfd/elfxx-tilegx.c
+++ b/bfd/elfxx-tilegx.c
@@ -2448,7 +2448,7 @@ tilegx_elf_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
       /* Set the contents of the .interp section to the interpreter.  */
       if (bfd_link_executable (info) && !info->nointerp)
 	{
-	  s = bfd_get_linker_section (dynobj, ".interp");
+	  s = htab->elf.interp;
 	  BFD_ASSERT (s != NULL);
 	  s->size = strlen (htab->dynamic_interpreter) + 1;
 	  s->contents = (unsigned char *) htab->dynamic_interpreter;
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index 06265ee4e15..0d389968c91 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -3665,7 +3665,7 @@ _bfd_x86_elf_link_symbol_references_local (struct bfd_link_info *info,
       || (h->root.type == bfd_link_hash_undefweak
 	  && (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
 	      || (bfd_link_executable (info)
-		  && htab->interp == NULL)
+		  && htab->elf.interp == NULL)
 	      || info->dynamic_undefined_weak == 0))
       || ((h->def_regular || ELF_COMMON_DEF_P (h))
 	  && info->version_info != NULL
@@ -4702,15 +4702,12 @@ _bfd_x86_elf_link_setup_gnu_properties
     {
       /* Whe creating executable, set the contents of the .interp
 	 section to the interpreter.  */
-      if (bfd_link_executable (info) && !info->nointerp)
+      asection *s = htab->elf.interp;
+      if (s != NULL)
 	{
-	  asection *s = bfd_get_linker_section (dynobj, ".interp");
-	  if (s == NULL)
-	    abort ();
 	  s->size = htab->dynamic_interpreter_size;
 	  s->contents = (unsigned char *) htab->dynamic_interpreter;
 	  s->alloced = 1;
-	  htab->interp = s;
 	}
 
       if (normal_target)
diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h
index 5593203f9ec..1ebc9d2f2e5 100644
--- a/bfd/elfxx-x86.h
+++ b/bfd/elfxx-x86.h
@@ -602,7 +602,6 @@ struct elf_x86_link_hash_table
   struct elf_link_hash_table elf;
 
   /* Short-cuts to get to dynamic linker sections.  */
-  asection *interp;
   asection *plt_eh_frame;
   asection *plt_second;
   asection *plt_second_eh_frame;


More information about the Binutils-cvs mailing list