From patchwork Thu Sep 20 20:42:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 972717 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="fqbsZXkb"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="E9Kb8UHQ"; 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 42GTG02L9Hz9sDB for ; Fri, 21 Sep 2018 06:43:20 +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=G4HCCWagTqlSja7nVBrUa2lzXSkDBI8UUqRRDycNe7A=; b=fqbsZXkb40qrjMxc3JrsjMso/+ Pcz2v7du6AmuEwK+Ifxn1f1RLc0ccClJFlpfU7Lff7jHkt7Gg5OPk5xhnBO+ptMI954Ukgx9QIztt kNCs1PCGLrfynVm4dbIyRPrB2XBVqfyWj+CENEBPy/kh9Oxn6P/+ZOMcBQLXGDDu7DpnEGWIrDHJk Lc+bNVov1wjd1q2ZlMFfuvjqCxKz5548ycjFsDsHqXtXG9JZfAAf/7BUIJGxCtBw/q05rzczksONi XQMnTtl3e6aIYwEVw4BB328BoLKjUlOjtbTX9+moxQPxrg++mSQrX9DN6th3PCxcUb27HHCqqPf3w hVEOWQQA==; 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 1g35nB-0003r8-Lq; Thu, 20 Sep 2018 20:43:17 +0000 Received: from smtprelay.synopsys.com ([198.182.47.9]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g35n3-0003ll-4q for linux-snps-arc@lists.infradead.org; Thu, 20 Sep 2018 20:43:15 +0000 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id 6216624E0FA5; Thu, 20 Sep 2018 13:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1537476177; bh=zYf9/Cc0wFuNKJr42tI9loC8bdOjPSOXGf5Y+tupLiY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E9Kb8UHQ5hS3iNm8VztyKmv8biUYKUKzvh3CP7Q61CPsJA9Nix6W8b6KoxkUKL0f2 kwK9rHfOgBA5qC4IFFY2APimhR4jweTVTwnZ3iT1vjGUMaR6e8XAhGjVsuHxv4Lm2t LFRW07I+xaLvf4EqFc5ZNA30kCIkPcM5wTuUG9tsD57u6fmNeqB4dp28jkzC4MucdY TTd/u1A6gPukTRtQPf2lc8eoM6yX1oZBF0QEO/1zwYjgfPE8pC4lgFS04pihQ01mVe qPPJrERpFyTYLVW3NIa+iLtvzCSlmQ2YDYJ2ezC95pOkRcrzr06AbgKmG4+p2DkEhe wWk1LbrKSmF/g== Received: from ru20arcgnu1.internal.synopsys.com (ru20arcgnu1.internal.synopsys.com [10.121.9.48]) by mailhost.synopsys.com (Postfix) with ESMTP id 30B693B59; Thu, 20 Sep 2018 13:42:56 -0700 (PDT) From: Alexey Brodkin To: openembedded-core@lists.openembedded.org Subject: [PATCH v2 8/9] binutils: Fix Glibc building for ARC Date: Thu, 20 Sep 2018 23:42:31 +0300 Message-Id: <20180920204232.10583-9-abrodkin@synopsys.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180920204232.10583-1-abrodkin@synopsys.com> References: <20180920204232.10583-1-abrodkin@synopsys.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180920_134309_325839_BA25DEB8 X-CRM114-Status: GOOD ( 24.78 ) 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.47.9 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 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 -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 --- Changes v1 -> v2: * Added upstream status meta/recipes-devtools/binutils/binutils-2.31.inc | 4 + ...location-where-GOT-information-is-collect.patch | 201 +++++++++++++++++++++ ...bustness.-Return-FALSE-in-case-of-NULL-po.patch | 38 ++++ ...lobal-symbol-is-not-an-indirect-or-warnin.patch | 46 +++++ ...tion-was-still-being-generated-when-symbo.patch | 40 ++++ 5 files changed, 329 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 bc951d73e4..76add0fe4b 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 0000000000..d41339a9a6 --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0018-Refactored-location-where-GOT-information-is-collect.patch @@ -0,0 +1,201 @@ +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: Cupertino Miranda +Signed-off-by: Alexey Brodkin +[Romain: rebase on top of 2.31] +Signed-off-by: Romain Naour + +Upstream-Status: Pending +--- + 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 0000000000..6a58ee06ac --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0019-Improved-robustness.-Return-FALSE-in-case-of-NULL-po.patch @@ -0,0 +1,38 @@ +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: Cupertino Miranda +Signed-off-by: Alexey Brodkin +[Romain: rebase on top of 2.31] +Signed-off-by: Romain Naour + +Upstream-Status: Pending +--- + 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 0000000000..01e42c03bb --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0020-Make-sure-global-symbol-is-not-an-indirect-or-warnin.patch @@ -0,0 +1,46 @@ +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: Cupertino Miranda +Signed-off-by: Alexey Brodkin +[Romain: rebase on top of 2.31] +Signed-off-by: Romain Naour + +Upstream-Status: Pending +--- + 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 0000000000..9e942399c0 --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0021-PLT-information-was-still-being-generated-when-symbo.patch @@ -0,0 +1,40 @@ +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: Cupertino Miranda +Signed-off-by: Alexey Brodkin +[Romain: rebase on top of 2.31] +Signed-off-by: Romain Naour + +Upstream-Status: Pending +--- + 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 +