From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by sourceware.org (Postfix) with ESMTPS id D4FB0389364B for ; Tue, 2 Jun 2020 12:34:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D4FB0389364B Received: by mail-pf1-x443.google.com with SMTP id b16so226583pfi.13 for ; Tue, 02 Jun 2020 05:34:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=VxvFUMgUYvaDjdPxeEocb9NMrwxUCTeyQmevnLNzA+I=; b=X0apZqGfIs50/51ZhaC34Xt/LHf08+qnxLTbBePOaKX1H7rWydzBeggNfE70Clk5Ni 40glVcEguSB5UPb8euRwwrcBs+9XdWoFSppGbQTPfRkH6WMLMYMOgK3/EzNO6Z8UJPc0 NqHh8N/Jl3DzgDpjTG/0MdXNxPHiZQhOqFv2j+jqRtfMpon8SRN/T0Va5xETK20eFDU+ cxYiQ3XmKL5IeqmxhXGTJE+68YtU4OGAoTR1DvJq2p4W7mgpceiY+mzN+3yovzRWRl1d NJcfVNK3FJ5b5TyyB+UkbrMuvQxyTFTdOQRc28ofPJuSeKvFPMZWutYYXhBuTUsZnT21 dlcQ== X-Gm-Message-State: AOAM531PhEI/hMe4d1skVh8QAeeF2IaZ+DZ6GBaoSzHf+sw0w+xFM8CZ aJObz8fxH6kxroqhRgXr1m6RGdZn X-Google-Smtp-Source: ABdhPJxiHo2h9k5vmIGAbOdiaj0YCQzL5ChJagLJ0oPfhmnNhMgR8ozRQkHuihVQOwAWeS8sHNyuIA== X-Received: by 2002:aa7:99d0:: with SMTP id v16mr11775488pfi.98.1591101270216; Tue, 02 Jun 2020 05:34:30 -0700 (PDT) Received: from gnu-cfl-2.localdomain (c-69-181-90-243.hsd1.ca.comcast.net. [69.181.90.243]) by smtp.gmail.com with ESMTPSA id g18sm2185048pgn.47.2020.06.02.05.34.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 05:34:29 -0700 (PDT) Received: from gnu-cfl-2.localdomain (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id DA2821A0237 for ; Tue, 2 Jun 2020 05:34:28 -0700 (PDT) From: "H.J. Lu" To: binutils@sourceware.org Subject: [PATCH] ELF: Copy dyn_relocs in _bfd_elf_link_hash_copy_indirect Date: Tue, 2 Jun 2020 05:34:28 -0700 Message-Id: <20200602123428.283943-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Jun 2020 12:34:34 -0000 Copy dyn_relocs in _bfd_elf_link_hash_copy_indirect instead of in each target backend. I will check it in if there are no objections. H.J. --- PR ld/26067 * elf32-arm.c (elf32_arm_copy_indirect_symbol): Don't copy dyn_relocs. * elf32-csky.c (csky_elf_copy_indirect_symbol): Likewise. * elf32-hppa.c (elf32_hppa_copy_indirect_symbol): Likewise. * elf32-metag.c (elf_metag_copy_indirect_symbol): Likewise. * elf32-microblaze.c (microblaze_elf_copy_indirect_symbol): Likewise. * elf32-nds32.c (nds32_elf_copy_indirect_symbol): Likewise. * elf32-nios2.c (nios2_elf32_copy_indirect_symbol): Likewise. * elf32-or1k.c (or1k_elf_copy_indirect_symbol): Likewise. * elf32-s390.c (elf_s390_copy_indirect_symbol): Likewise. * elf32-sh.c (sh_elf_copy_indirect_symbol): Likewise. * elf32-tilepro.c (tilepro_elf_copy_indirect_symbol): Likewise. * elf64-s390.c (elf_s390_copy_indirect_symbol): Likewise. * elfnn-aarch64.c (elfNN_aarch64_copy_indirect_symbol): Likewise. * elfnn-riscv.c (riscv_elf_copy_indirect_symbol): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_copy_indirect_symbol): Likewise. * elfxx-tilegx.c (tilegx_elf_copy_indirect_symbol): Likewise. * elfxx-x86.c (_bfd_x86_elf_copy_indirect_symbol): Likewise. * elf32-lm32.c (lm32_elf_copy_indirect_symbol): Removed. (elf_backend_copy_indirect_symbol): Likewise. * elf32-m32r.c (m32r_elf_copy_indirect_symbol): Removed. (elf_backend_copy_indirect_symbol): Likewise. * elflink.c (_bfd_elf_link_hash_copy_indirect): Copy dyn_relocs. --- bfd/elf32-arm.c | 31 ------------------------------- bfd/elf32-csky.c | 29 ----------------------------- bfd/elf32-hppa.c | 36 ------------------------------------ bfd/elf32-lm32.c | 42 ------------------------------------------ bfd/elf32-m32r.c | 42 ------------------------------------------ bfd/elf32-metag.c | 35 ----------------------------------- bfd/elf32-microblaze.c | 34 ---------------------------------- bfd/elf32-nds32.c | 34 ---------------------------------- bfd/elf32-nios2.c | 31 ------------------------------- bfd/elf32-or1k.c | 31 ------------------------------- bfd/elf32-s390.c | 31 ------------------------------- bfd/elf32-sh.c | 30 ------------------------------ bfd/elf32-tilepro.c | 31 ------------------------------- bfd/elf64-s390.c | 31 ------------------------------- bfd/elflink.c | 31 +++++++++++++++++++++++++++++++ bfd/elfnn-aarch64.c | 31 ------------------------------- bfd/elfnn-riscv.c | 31 ------------------------------- bfd/elfxx-sparc.c | 31 ------------------------------- bfd/elfxx-tilegx.c | 31 ------------------------------- bfd/elfxx-x86.c | 31 ------------------------------- 20 files changed, 31 insertions(+), 623 deletions(-) diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 69d3ba16ee..fc67ca5207 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -4028,37 +4028,6 @@ elf32_arm_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct elf32_arm_link_hash_entry *) dir; eind = (struct elf32_arm_link_hash_entry *) ind; - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL; ) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } - if (ind->root.type == bfd_link_hash_indirect) { /* Copy over PLT info. */ diff --git a/bfd/elf32-csky.c b/bfd/elf32-csky.c index 52708702a6..03e83d53a5 100644 --- a/bfd/elf32-csky.c +++ b/bfd/elf32-csky.c @@ -2447,35 +2447,6 @@ csky_elf_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct csky_elf_link_hash_entry *) dir; eind = (struct csky_elf_link_hash_entry *) ind; - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL; ) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } if (ind->root.type == bfd_link_hash_indirect && dir->got.refcount <= 0) { diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 15100431c8..106b5c8315 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -1040,42 +1040,6 @@ elf32_hppa_copy_indirect_symbol (struct bfd_link_info *info, hh_dir = hppa_elf_hash_entry (eh_dir); hh_ind = hppa_elf_hash_entry (eh_ind); - if (eh_ind->dyn_relocs != NULL - && eh_ind->root.type == bfd_link_hash_indirect) - { - if (eh_dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **hdh_pp; - struct elf_dyn_relocs *hdh_p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (hdh_pp = &eh_ind->dyn_relocs; (hdh_p = *hdh_pp) != NULL; ) - { - struct elf_dyn_relocs *hdh_q; - - for (hdh_q = eh_dir->dyn_relocs; - hdh_q != NULL; - hdh_q = hdh_q->next) - if (hdh_q->sec == hdh_p->sec) - { -#if RELATIVE_DYNRELOCS - hdh_q->pc_count += hdh_p->pc_count; -#endif - hdh_q->count += hdh_p->count; - *hdh_pp = hdh_p->next; - break; - } - if (hdh_q == NULL) - hdh_pp = &hdh_p->next; - } - *hdh_pp = eh_dir->dyn_relocs; - } - - eh_dir->dyn_relocs = eh_ind->dyn_relocs; - eh_ind->dyn_relocs = NULL; - } - if (eh_ind->root.type == bfd_link_hash_indirect) { hh_dir->plabel |= hh_ind->plabel; diff --git a/bfd/elf32-lm32.c b/bfd/elf32-lm32.c index 9e958617f8..5d09f2d350 100644 --- a/bfd/elf32-lm32.c +++ b/bfd/elf32-lm32.c @@ -2390,47 +2390,6 @@ lm32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) return TRUE; } -/* Copy the extra info we tack onto an elf_link_hash_entry. */ - -static void -lm32_elf_copy_indirect_symbol (struct bfd_link_info *info, - struct elf_link_hash_entry *dir, - struct elf_link_hash_entry *ind) -{ - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL;) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } - - _bfd_elf_link_hash_copy_indirect (info, dir, ind); -} - static bfd_boolean lm32_elf_always_size_sections (bfd *output_bfd, struct bfd_link_info *info) { @@ -2518,7 +2477,6 @@ lm32_elf_fdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd) #define bfd_elf32_bfd_link_hash_table_create lm32_elf_link_hash_table_create #define elf_backend_check_relocs lm32_elf_check_relocs #define elf_backend_reloc_type_class lm32_elf_reloc_type_class -#define elf_backend_copy_indirect_symbol lm32_elf_copy_indirect_symbol #define elf_backend_size_dynamic_sections lm32_elf_size_dynamic_sections #define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all #define elf_backend_create_dynamic_sections lm32_elf_create_dynamic_sections diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index f719a532d4..afe0ee899c 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -1658,47 +1658,6 @@ m32r_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) return TRUE; } -/* Copy the extra info we tack onto an elf_link_hash_entry. */ - -static void -m32r_elf_copy_indirect_symbol (struct bfd_link_info *info, - struct elf_link_hash_entry *dir, - struct elf_link_hash_entry *ind) -{ - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL;) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } - - _bfd_elf_link_hash_copy_indirect (info, dir, ind); -} - /* Adjust a symbol defined by a dynamic object and referenced by a regular object. The current definition is in some section of the @@ -3811,7 +3770,6 @@ m32r_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED, #define elf_backend_adjust_dynamic_symbol m32r_elf_adjust_dynamic_symbol #define elf_backend_finish_dynamic_symbol m32r_elf_finish_dynamic_symbol #define elf_backend_reloc_type_class m32r_elf_reloc_type_class -#define elf_backend_copy_indirect_symbol m32r_elf_copy_indirect_symbol #define elf_backend_can_gc_sections 1 /*#if !USE_REL diff --git a/bfd/elf32-metag.c b/bfd/elf32-metag.c index b2cb918d4c..d5e9a9d034 100644 --- a/bfd/elf32-metag.c +++ b/bfd/elf32-metag.c @@ -2390,41 +2390,6 @@ elf_metag_copy_indirect_symbol (struct bfd_link_info *info, hh_dir = metag_elf_hash_entry (eh_dir); hh_ind = metag_elf_hash_entry (eh_ind); - if (eh_ind->dyn_relocs != NULL) - { - if (eh_dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **hdh_pp; - struct elf_dyn_relocs *hdh_p; - - if (eh_ind->root.type == bfd_link_hash_indirect) - abort (); - - /* Add reloc counts against the weak sym to the strong sym - list. Merge any entries against the same section. */ - for (hdh_pp = &eh_ind->dyn_relocs; (hdh_p = *hdh_pp) != NULL; ) - { - struct elf_dyn_relocs *hdh_q; - - for (hdh_q = eh_dir->dyn_relocs; hdh_q != NULL; - hdh_q = hdh_q->next) - if (hdh_q->sec == hdh_p->sec) - { - hdh_q->pc_count += hdh_p->pc_count; - hdh_q->count += hdh_p->count; - *hdh_pp = hdh_p->next; - break; - } - if (hdh_q == NULL) - hdh_pp = &hdh_p->next; - } - *hdh_pp = eh_dir->dyn_relocs; - } - - eh_dir->dyn_relocs = eh_ind->dyn_relocs; - eh_ind->dyn_relocs = NULL; - } - if (eh_ind->root.type == bfd_link_hash_indirect && eh_dir->got.refcount <= 0) { diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c index 92c5e7c303..caf0f2edca 100644 --- a/bfd/elf32-microblaze.c +++ b/bfd/elf32-microblaze.c @@ -2575,40 +2575,6 @@ microblaze_elf_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct elf32_mb_link_hash_entry *) dir; eind = (struct elf32_mb_link_hash_entry *) ind; - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - if (ind->root.type == bfd_link_hash_indirect) - abort (); - - /* Add reloc counts against the weak sym to the strong sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL; ) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } - edir->tls_mask |= eind->tls_mask; _bfd_elf_link_hash_copy_indirect (info, dir, ind); diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c index ad5225fcd7..4f7ea76469 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -3874,40 +3874,6 @@ nds32_elf_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct elf_nds32_link_hash_entry *) dir; eind = (struct elf_nds32_link_hash_entry *) ind; - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - if (ind->root.type == bfd_link_hash_indirect) - abort (); - - /* Add reloc counts against the weak sym to the strong sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL;) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } - if (ind->root.type == bfd_link_hash_indirect) { if (dir->got.refcount <= 0) diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c index 6b4b092e2d..aabec1d6d6 100644 --- a/bfd/elf32-nios2.c +++ b/bfd/elf32-nios2.c @@ -4637,37 +4637,6 @@ nios2_elf32_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct elf32_nios2_link_hash_entry *) dir; eind = (struct elf32_nios2_link_hash_entry *) ind; - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL; ) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } - if (ind->root.type == bfd_link_hash_indirect && dir->got.refcount <= 0) { diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c index 01556266c1..b141b45886 100644 --- a/bfd/elf32-or1k.c +++ b/bfd/elf32-or1k.c @@ -3177,37 +3177,6 @@ or1k_elf_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct elf_or1k_link_hash_entry *) dir; eind = (struct elf_or1k_link_hash_entry *) ind; - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL;) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } - if (ind->root.type == bfd_link_hash_indirect) { if (dir->got.refcount <= 0) diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index c0db4f9bc8..42f230d9b1 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -828,37 +828,6 @@ elf_s390_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct elf_s390_link_hash_entry *) dir; eind = (struct elf_s390_link_hash_entry *) ind; - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL; ) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } - if (ind->root.type == bfd_link_hash_indirect && dir->got.refcount <= 0) { diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index 29cdb3b569..0428829757 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -5303,36 +5303,6 @@ sh_elf_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct elf_sh_link_hash_entry *) dir; eind = (struct elf_sh_link_hash_entry *) ind; - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL; ) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } edir->gotplt_refcount = eind->gotplt_refcount; eind->gotplt_refcount = 0; edir->funcdesc.refcount += eind->funcdesc.refcount; diff --git a/bfd/elf32-tilepro.c b/bfd/elf32-tilepro.c index cb6cda8117..9707a9e18e 100644 --- a/bfd/elf32-tilepro.c +++ b/bfd/elf32-tilepro.c @@ -1292,37 +1292,6 @@ tilepro_elf_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct tilepro_elf_link_hash_entry *) dir; eind = (struct tilepro_elf_link_hash_entry *) ind; - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL; ) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } - if (ind->root.type == bfd_link_hash_indirect && dir->got.refcount <= 0) { diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 07ec4709bb..197e9bc68c 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -747,37 +747,6 @@ elf_s390_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct elf_s390_link_hash_entry *) dir; eind = (struct elf_s390_link_hash_entry *) ind; - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL; ) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } - if (ind->root.type == bfd_link_hash_indirect && dir->got.refcount <= 0) { diff --git a/bfd/elflink.c b/bfd/elflink.c index 0d659c2025..a2b40ccb04 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -7650,6 +7650,37 @@ _bfd_elf_link_hash_copy_indirect (struct bfd_link_info *info, { struct elf_link_hash_table *htab; + if (ind->dyn_relocs != NULL) + { + if (dir->dyn_relocs != NULL) + { + struct elf_dyn_relocs **pp; + struct elf_dyn_relocs *p; + + /* Add reloc counts against the indirect sym to the direct sym + list. Merge any entries against the same section. */ + for (pp = &ind->dyn_relocs; (p = *pp) != NULL; ) + { + struct elf_dyn_relocs *q; + + for (q = dir->dyn_relocs; q != NULL; q = q->next) + if (q->sec == p->sec) + { + q->pc_count += p->pc_count; + q->count += p->count; + *pp = p->next; + break; + } + if (q == NULL) + pp = &p->next; + } + *pp = dir->dyn_relocs; + } + + dir->dyn_relocs = ind->dyn_relocs; + ind->dyn_relocs = NULL; + } + /* Copy down any references that we may have already seen to the symbol which just became indirect. */ diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index f521786c8c..71634ffba7 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -2851,37 +2851,6 @@ elfNN_aarch64_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct elf_aarch64_link_hash_entry *) dir; eind = (struct elf_aarch64_link_hash_entry *) ind; - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL;) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } - if (ind->root.type == bfd_link_hash_indirect) { /* Copy over PLT info. */ diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index 1b530d83df..3c972e20ab 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -415,37 +415,6 @@ riscv_elf_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct riscv_elf_link_hash_entry *) dir; eind = (struct riscv_elf_link_hash_entry *) ind; - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL; ) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } - if (ind->root.type == bfd_link_hash_indirect && dir->got.refcount <= 0) { diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c index 633ac59bcc..e4700e3106 100644 --- a/bfd/elfxx-sparc.c +++ b/bfd/elfxx-sparc.c @@ -1285,37 +1285,6 @@ _bfd_sparc_elf_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct _bfd_sparc_elf_link_hash_entry *) dir; eind = (struct _bfd_sparc_elf_link_hash_entry *) ind; - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL; ) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } - if (ind->root.type == bfd_link_hash_indirect && dir->got.refcount <= 0) { edir->tls_type = eind->tls_type; diff --git a/bfd/elfxx-tilegx.c b/bfd/elfxx-tilegx.c index 75b4621276..07288a13e8 100644 --- a/bfd/elfxx-tilegx.c +++ b/bfd/elfxx-tilegx.c @@ -1501,37 +1501,6 @@ tilegx_elf_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct tilegx_elf_link_hash_entry *) dir; eind = (struct tilegx_elf_link_hash_entry *) ind; - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL; ) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } - if (ind->root.type == bfd_link_hash_indirect && dir->got.refcount <= 0) { diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index c89559914e..b8c616f4d8 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -1766,37 +1766,6 @@ _bfd_x86_elf_copy_indirect_symbol (struct bfd_link_info *info, edir = (struct elf_x86_link_hash_entry *) dir; eind = (struct elf_x86_link_hash_entry *) ind; - if (ind->dyn_relocs != NULL) - { - if (dir->dyn_relocs != NULL) - { - struct elf_dyn_relocs **pp; - struct elf_dyn_relocs *p; - - /* Add reloc counts against the indirect sym to the direct sym - list. Merge any entries against the same section. */ - for (pp = &ind->dyn_relocs; (p = *pp) != NULL; ) - { - struct elf_dyn_relocs *q; - - for (q = dir->dyn_relocs; q != NULL; q = q->next) - if (q->sec == p->sec) - { - q->pc_count += p->pc_count; - q->count += p->count; - *pp = p->next; - break; - } - if (q == NULL) - pp = &p->next; - } - *pp = dir->dyn_relocs; - } - - dir->dyn_relocs = ind->dyn_relocs; - ind->dyn_relocs = NULL; - } - if (ind->root.type == bfd_link_hash_indirect && dir->got.refcount <= 0) { -- 2.26.2