From patchwork Mon Sep 17 21:29:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 970842 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sAsJGhFI"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="O2Mack1m"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42DfRv6HcYz9sBv for ; Tue, 18 Sep 2018 07:30:35 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=zk8oLXaxPcF9jVEuzn/4P/T56AS6OfcBrwI9xjvVV68=; b=sAsJGhFIGUcQy/foeL7/+EdKEd RmbwLpqQFVsWhUTl4kXs0e720ef4H0r1FZyWIcb/xw/qYaP9efYtMt2smKvUz42jIKYkQ1ZaEmiSG iVAyn/I35bv5dr7nhWCxz58YLY+D6Gn9lQKpvbaGdulSBOI3WVVsigCxHIpaWLAAcLxIC8fqkUUs1 Z/FT1FjEMHeLnA1oGl9Elkt36asof2R/V6pE+/hKN1F+dX/i7LzohpZQrDSIevvSauxnXdt1vSKbh DBuxKPzd+E4aiVXKJPfmM04o9lfgfeHIHE1J3jitzduNZOZQ6t17ZDX8apGqPTe6aGcIUJdoMMpaD Nsb14f/A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g216H-00039H-Si; Mon, 17 Sep 2018 21:30:33 +0000 Received: from smtprelay.synopsys.com ([198.182.60.111]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2167-0002LD-4E for linux-snps-arc@lists.infradead.org; Mon, 17 Sep 2018 21:30:31 +0000 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id E7BB810C07D2; Mon, 17 Sep 2018 14:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1537219808; bh=YLYtL4+t3NvjNODxmBmsDB3D8m1P+3Hvqp2hkMig94c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O2Mack1mHRrcEaVyzAq5JwF2nCx4h438pIaYAKePm7+qLdQsry7XQa8a4SynhILqx mt4essYePOJSD4Bvj3/1fZ3AyEuvfkG/4aeSxyN2CFFVb2nhSee0dOGs2rpWnj4tc/ Gm73C2mJ5GIxpOCU8RoVHYSRA3pt6VG76SJfsx22jI83pGylAduF/T18I7gVwwPxaa qrhRHNeJBKsws+ruCAFMp2gdEXt2ezWuujpVImi15U2Hyk0+0pfvZgjSKkwABZhljW PwIHEyhnXE/Ohv8AtGdtO4d6zVtYwMTLerOSRbyhL+03BdjB9FU8+4Jxs9fvJhlkPz c3r00PaTddkow== Received: from ru20arcgnu1.internal.synopsys.com (ru20arcgnu1.internal.synopsys.com [10.121.9.48]) by mailhost.synopsys.com (Postfix) with ESMTP id C30A055F5; Mon, 17 Sep 2018 14:30:07 -0700 (PDT) From: Alexey Brodkin To: openembedded-core@lists.openembedded.org Subject: [PATCH 09/10] binutils: Fix Glibc building for ARC Date: Tue, 18 Sep 2018 00:29:42 +0300 Message-Id: <20180917212943.27237-10-abrodkin@synopsys.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180917212943.27237-1-abrodkin@synopsys.com> References: <20180917212943.27237-1-abrodkin@synopsys.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180917_143023_680606_27648228 X-CRM114-Status: GOOD ( 24.01 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.60.111 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-snps-arc@lists.infradead.org, Alexey Brodkin , Khem Raj MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: Alexey Brodkin --- meta/recipes-devtools/binutils/binutils-2.31.inc | 4 + ...location-where-GOT-information-is-collect.patch | 198 +++++++++++++++++++++ ...bustness.-Return-FALSE-in-case-of-NULL-po.patch | 35 ++++ ...lobal-symbol-is-not-an-indirect-or-warnin.patch | 43 +++++ ...tion-was-still-being-generated-when-symbo.patch | 37 ++++ 5 files changed, 317 insertions(+) create mode 100644 meta/recipes-devtools/binutils/binutils/0018-Refactored-location-where-GOT-information-is-collect.patch create mode 100644 meta/recipes-devtools/binutils/binutils/0019-Improved-robustness.-Return-FALSE-in-case-of-NULL-po.patch create mode 100644 meta/recipes-devtools/binutils/binutils/0020-Make-sure-global-symbol-is-not-an-indirect-or-warnin.patch create mode 100644 meta/recipes-devtools/binutils/binutils/0021-PLT-information-was-still-being-generated-when-symbo.patch diff --git a/meta/recipes-devtools/binutils/binutils-2.31.inc b/meta/recipes-devtools/binutils/binutils-2.31.inc index bc951d7..76add0f 100644 --- a/meta/recipes-devtools/binutils/binutils-2.31.inc +++ b/meta/recipes-devtools/binutils/binutils-2.31.inc @@ -37,6 +37,10 @@ SRC_URI = "\ file://0015-sync-with-OE-libtool-changes.patch \ file://0016-add-i386pep-emulation-for-x86_64.patch \ file://0017-improve-check-for-input-file-matching-output-file.patch \ + file://0018-Refactored-location-where-GOT-information-is-collect.patch \ + file://0019-Improved-robustness.-Return-FALSE-in-case-of-NULL-po.patch \ + file://0020-Make-sure-global-symbol-is-not-an-indirect-or-warnin.patch \ + file://0021-PLT-information-was-still-being-generated-when-symbo.patch \ " S = "${WORKDIR}/git" diff --git a/meta/recipes-devtools/binutils/binutils/0018-Refactored-location-where-GOT-information-is-collect.patch b/meta/recipes-devtools/binutils/binutils/0018-Refactored-location-where-GOT-information-is-collect.patch new file mode 100644 index 0000000..306c65f --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0018-Refactored-location-where-GOT-information-is-collect.patch @@ -0,0 +1,198 @@ +From d930affa2d475d1cc6792f1e6d56bef3d6c617db Mon Sep 17 00:00:00 2001 +From: Cupertino Miranda +Date: Fri, 2 Mar 2018 17:16:21 +0100 +Subject: [PATCH] Refactored location where GOT information is collected. + +Change location where GOT information is collected for ARC target, avoiding +posible use conflicts of the previous .got field in the symbols hash_entry. + +bfd/ +2018-03-01 Cupertino Miranda + + * arc-got.h (get_got_entry_list_for_symbol): Changed. + * ef32-arc.c (struct elf_arc_link_hash_entry): Moved and changed. + (elf_arc_link_hash_newfunc): Changed. + (arc_elf_link_hash_table_create): Removed old initializations. + (elf_arc_relocate_section, elf_arc_finish_dynamic_symbol): Changed. + +Signed-off-by: Alexey Brodkin +[Romain: rebase on top of 2.31] +Signed-off-by: Romain Naour +--- + bfd/arc-got.h | 6 +++-- + bfd/elf32-arc.c | 77 +++++++++++++++++++++++++++++++-------------------------- + 2 files changed, 46 insertions(+), 37 deletions(-) + +diff --git a/bfd/arc-got.h b/bfd/arc-got.h +index a86061bcb38..81ce88fe21a 100644 +--- a/bfd/arc-got.h ++++ b/bfd/arc-got.h +@@ -156,9 +156,11 @@ get_got_entry_list_for_symbol (bfd *abfd, + unsigned long r_symndx, + struct elf_link_hash_entry *h) + { +- if (h != NULL) ++ struct elf_arc_link_hash_entry *h1 = ++ ((struct elf_arc_link_hash_entry *) h); ++ if (h1 != NULL) + { +- return &h->got.glist; ++ return &h1->got_ents; + } + else + { +diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c +index a48ef0ca15f..ab84de43815 100644 +--- a/bfd/elf32-arc.c ++++ b/bfd/elf32-arc.c +@@ -160,6 +160,18 @@ struct arc_relocation_data + const char * symbol_name; + }; + ++/* ARC ELF linker hash entry. */ ++struct elf_arc_link_hash_entry ++{ ++ struct elf_link_hash_entry root; ++ ++ /* Track dynamic relocs copied for this symbol. */ ++ struct elf_dyn_relocs *dyn_relocs; ++ ++ struct got_entry *got_ents; ++}; ++ ++ + /* Should be included at this location due to static declarations + defined before this point. */ + #include "arc-got.h" +@@ -281,15 +293,6 @@ struct arc_reloc_map + unsigned char elf_reloc_val; + }; + +-/* ARC ELF linker hash entry. */ +-struct elf_arc_link_hash_entry +-{ +- struct elf_link_hash_entry root; +- +- /* Track dynamic relocs copied for this symbol. */ +- struct elf_dyn_relocs *dyn_relocs; +-}; +- + /* ARC ELF linker hash table. */ + struct elf_arc_link_hash_table + { +@@ -301,28 +304,28 @@ elf_arc_link_hash_newfunc (struct bfd_hash_entry *entry, + struct bfd_hash_table *table, + const char *string) + { ++ struct elf_arc_link_hash_entry * ret = ++ (struct elf_arc_link_hash_entry *) entry; ++ + /* Allocate the structure if it has not already been allocated by a + subclass. */ +- if (entry == NULL) +- { +- entry = (struct bfd_hash_entry *) +- bfd_hash_allocate (table, +- sizeof (struct elf_arc_link_hash_entry)); +- if (entry == NULL) +- return entry; +- } ++ if (ret == NULL) ++ ret = (struct elf_arc_link_hash_entry *) ++ bfd_hash_allocate (table, sizeof (struct elf_arc_link_hash_entry)); ++ if (ret == NULL) ++ return (struct bfd_hash_entry *) ret; + + /* Call the allocation method of the superclass. */ +- entry = _bfd_elf_link_hash_newfunc (entry, table, string); +- if (entry != NULL) ++ ret = ((struct elf_arc_link_hash_entry *) ++ _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret, ++ table, string)); ++ if (ret != NULL) + { +- struct elf_arc_link_hash_entry *eh; +- +- eh = (struct elf_arc_link_hash_entry *) entry; +- eh->dyn_relocs = NULL; ++ ret->dyn_relocs = NULL; ++ ret->got_ents = NULL; + } + +- return entry; ++ return (struct bfd_hash_entry *) ret; + } + + /* Destroy an ARC ELF linker hash table. */ +@@ -352,11 +355,6 @@ arc_elf_link_hash_table_create (bfd *abfd) + return NULL; + } + +- ret->elf.init_got_refcount.refcount = 0; +- ret->elf.init_got_refcount.glist = NULL; +- ret->elf.init_got_offset.offset = 0; +- ret->elf.init_got_offset.glist = NULL; +- + ret->elf.root.hash_table_free = elf_arc_link_hash_table_free; + + return &ret->elf.root; +@@ -1615,10 +1613,14 @@ elf_arc_relocate_section (bfd * output_bfd, + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + { +- struct elf_link_hash_entry *h_old = h; ++ struct elf_arc_link_hash_entry *ah_old = ++ (struct elf_arc_link_hash_entry *) h; + h = (struct elf_link_hash_entry *) h->root.u.i.link; +- if (h->got.glist == 0 && h_old->got.glist != h->got.glist) +- h->got.glist = h_old->got.glist; ++ struct elf_arc_link_hash_entry *ah = ++ (struct elf_arc_link_hash_entry *) h; ++ ++ if (ah->got_ents == 0 && ah_old->got_ents != ah->got_ents) ++ ah->got_ents = ah_old->got_ents; + } + + /* TODO: Need to validate what was the intention. */ +@@ -1636,6 +1638,8 @@ elf_arc_relocate_section (bfd * output_bfd, + + if (is_reloc_for_GOT (howto) && !bfd_link_pic (info)) + { ++ struct elf_arc_link_hash_entry *ah = ++ (struct elf_arc_link_hash_entry *) h; + /* TODO: Change it to use arc_do_relocation with + ARC_32 reloc. Try to use ADD_RELA macro. */ + bfd_vma relocation = +@@ -1645,8 +1649,8 @@ elf_arc_relocate_section (bfd * output_bfd, + + reloc_data.sym_section->output_section->vma) + : 0); + +- BFD_ASSERT (h->got.glist); +- bfd_vma got_offset = h->got.glist->offset; ++ BFD_ASSERT (ah->got_ents); ++ bfd_vma got_offset = ah->got_ents->offset; + bfd_put_32 (output_bfd, relocation, + htab->sgot->contents + got_offset); + } +@@ -1958,6 +1962,7 @@ elf_arc_check_relocs (bfd * abfd, + else /* Global one. */ + h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + ++ + switch (r_type) + { + case R_ARC_32: +@@ -2404,7 +2409,9 @@ elf_arc_finish_dynamic_symbol (bfd * output_bfd, + create respective dynamic relocs. */ + /* TODO: Make function to get list and not access the list directly. */ + /* TODO: Move function to relocate_section create this relocs eagerly. */ +- create_got_dynrelocs_for_got_info (&h->got.glist, ++ struct elf_arc_link_hash_entry *ah = ++ (struct elf_arc_link_hash_entry *) h; ++ create_got_dynrelocs_for_got_info (&ah->got_ents, + output_bfd, + info, + h); +-- +2.14.4 + diff --git a/meta/recipes-devtools/binutils/binutils/0019-Improved-robustness.-Return-FALSE-in-case-of-NULL-po.patch b/meta/recipes-devtools/binutils/binutils/0019-Improved-robustness.-Return-FALSE-in-case-of-NULL-po.patch new file mode 100644 index 0000000..b6e6d20 --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0019-Improved-robustness.-Return-FALSE-in-case-of-NULL-po.patch @@ -0,0 +1,35 @@ +From 955176bd999fe80c5b937ab8786665079e35c387 Mon Sep 17 00:00:00 2001 +From: Cupertino Miranda +Date: Fri, 2 Mar 2018 17:33:48 +0100 +Subject: [PATCH] Improved robustness. Return FALSE in case of NULL pointer. + +bfd/ +2018-03-01 Cupertino Miranda + + * elf32-arc.c (elf_arc_finish_dynamic_symbol) Return FALSE in case + arc_htab is NULL. + +Signed-off-by: Alexey Brodkin +[Romain: rebase on top of 2.31] +Signed-off-by: Romain Naour +--- + bfd/elf32-arc.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c +index ab84de43815..33fc72cff6e 100644 +--- a/bfd/elf32-arc.c ++++ b/bfd/elf32-arc.c +@@ -2420,6 +2420,9 @@ elf_arc_finish_dynamic_symbol (bfd * output_bfd, + { + struct elf_arc_link_hash_table *arc_htab = elf_arc_hash_table (info); + ++ if(arc_htab == NULL) ++ return FALSE; ++ + if (h->dynindx == -1 + || (h->root.type != bfd_link_hash_defined + && h->root.type != bfd_link_hash_defweak) +-- +2.14.4 + diff --git a/meta/recipes-devtools/binutils/binutils/0020-Make-sure-global-symbol-is-not-an-indirect-or-warnin.patch b/meta/recipes-devtools/binutils/binutils/0020-Make-sure-global-symbol-is-not-an-indirect-or-warnin.patch new file mode 100644 index 0000000..c3558fe --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0020-Make-sure-global-symbol-is-not-an-indirect-or-warnin.patch @@ -0,0 +1,43 @@ +From 9d09ce14b4eef2b56f24660fd69a44acd45128b2 Mon Sep 17 00:00:00 2001 +From: Cupertino Miranda +Date: Fri, 2 Mar 2018 17:38:14 +0100 +Subject: [PATCH] Make sure global symbol is not an indirect or warning. + +Problem identified in the context of glibc with latest upstream binutils. +Dynamic symbol space was being reserved but, no actual information for the +symbol was being set. Data for the symbol was kept initialized with -1. +No easy test case was possible to be created. + +bfd/ +2018-03-01 Cupertino Miranda + + * elf32-arc.c (elf_arc_check_relocs): Changed. + +Signed-off-by: Alexey Brodkin +[Romain: rebase on top of 2.31] +Signed-off-by: Romain Naour +--- + bfd/elf32-arc.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c +index 33fc72cff6e..9b72c5b4f4f 100644 +--- a/bfd/elf32-arc.c ++++ b/bfd/elf32-arc.c +@@ -1960,7 +1960,12 @@ elf_arc_check_relocs (bfd * abfd, + if (r_symndx < symtab_hdr->sh_info) /* Is a local symbol. */ + h = NULL; + else /* Global one. */ +- h = sym_hashes[r_symndx - symtab_hdr->sh_info]; ++ { ++ 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; ++ } + + + switch (r_type) +-- +2.14.4 + diff --git a/meta/recipes-devtools/binutils/binutils/0021-PLT-information-was-still-being-generated-when-symbo.patch b/meta/recipes-devtools/binutils/binutils/0021-PLT-information-was-still-being-generated-when-symbo.patch new file mode 100644 index 0000000..60bb522 --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0021-PLT-information-was-still-being-generated-when-symbo.patch @@ -0,0 +1,37 @@ +From e4861c68067cb2166b4c2bb9c052abeb6ad9aaa1 Mon Sep 17 00:00:00 2001 +From: Cupertino Miranda +Date: Fri, 2 Mar 2018 17:44:29 +0100 +Subject: [PATCH] PLT information was still being generated when symbol was + forced_local. + +A change upstream reveiled this issue, triggering an assert when linking glibc. + +bfd/ +2018-03-01 Cupertino Miranda + + * elf32-arc.c (elf_arc_check_relocs): Changed. + +Signed-off-by: Alexey Brodkin +[Romain: rebase on top of 2.31] +Signed-off-by: Romain Naour +--- + bfd/elf32-arc.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c +index 9b72c5b4f4f..b40b463d34d 100644 +--- a/bfd/elf32-arc.c ++++ b/bfd/elf32-arc.c +@@ -2041,7 +2041,8 @@ elf_arc_check_relocs (bfd * abfd, + if (h == NULL) + continue; + else +- h->needs_plt = 1; ++ if(h->forced_local == 0) ++ h->needs_plt = 1; + } + + /* Add info to the symbol got_entry_list. */ +-- +2.14.4 +