From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111465 invoked by alias); 23 May 2017 15:41:24 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 111206 invoked by uid 89); 23 May 2017 15:41:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1974 X-HELO: smtprelay.synopsys.com Received: from smtprelay4.synopsys.com (HELO smtprelay.synopsys.com) (198.182.47.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 May 2017 15:41:21 +0000 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id D110F24E1FA7 for ; Tue, 23 May 2017 08:41:23 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id BF9B86C7; Tue, 23 May 2017 08:41:23 -0700 (PDT) Received: from cmiranda-laptop.internal.synopsys.com (cmiranda-laptop.internal.synopsys.com [10.100.21.32]) by mailhost.synopsys.com (Postfix) with ESMTP id B612E6C6; Tue, 23 May 2017 08:41:22 -0700 (PDT) From: Cupertino Miranda To: binutils@sourceware.org Cc: Cupertino.Miranda@synopsys.com, Claudiu.Zissulescu@synopsys.com, Francois.Bedard@synopsys.com Subject: [PATCH 5/9] [ARC] ARC_PC32 dynamic reloc incorrectly generated. Date: Tue, 23 May 2017 15:41:00 -0000 Message-Id: <20170523154056.19234-6-cmiranda@synopsys.com> In-Reply-To: <20170523154056.19234-1-cmiranda@synopsys.com> References: <20170523154056.19234-1-cmiranda@synopsys.com> X-SW-Source: 2017-05/txt/msg00276.txt.bz2 Fixed issue related to the generation of ARC_PC32 dynamic relocs when symbol is dynamic but still defined in a non shared object. bfd/ChangeLog: Cupertino Miranda elf32-arc.c (elf_arc_relocate_section): Small refactor and condition changes. --- bfd/elf32-arc.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index 784bc0a..901218a 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -1709,16 +1709,22 @@ elf_arc_relocate_section (bfd * output_bfd, } } + +#define IS_ARC_PCREL_TYPE(TYPE) \ + ( (TYPE == R_ARC_PC32) \ + || (TYPE == R_ARC_32_PCREL)) + switch (r_type) { case R_ARC_32: case R_ARC_32_ME: case R_ARC_PC32: case R_ARC_32_PCREL: - if ((bfd_link_pic (info)) - && ((r_type != R_ARC_PC32 && r_type != R_ARC_32_PCREL) + if (bfd_link_pic (info) + && (!IS_ARC_PCREL_TYPE (r_type) || (h != NULL && h->dynindx != -1 + && !h->def_regular && (!info->symbolic || !h->def_regular)))) { Elf_Internal_Rela outrel; @@ -1735,6 +1741,7 @@ elf_arc_relocate_section (bfd * output_bfd, info, input_section, rel->r_offset); + if (outrel.r_offset == (bfd_vma) -1) skip = TRUE; @@ -1742,10 +1749,6 @@ elf_arc_relocate_section (bfd * output_bfd, outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); -#define IS_ARC_PCREL_TYPE(TYPE) \ - ( (TYPE == R_ARC_PC32) \ - || (TYPE == R_ARC_32_PCREL)) - if (skip) { memset (&outrel, 0, sizeof outrel); @@ -1753,10 +1756,10 @@ elf_arc_relocate_section (bfd * output_bfd, } else if (h != NULL && h->dynindx != -1 - && ((IS_ARC_PCREL_TYPE (r_type)) - || !(bfd_link_executable (info) - || SYMBOLIC_BIND (info, h)) - || ! h->def_regular)) + && (IS_ARC_PCREL_TYPE (r_type) + || !(bfd_link_executable (info) + || SYMBOLIC_BIND (info, h)) + || ! h->def_regular)) { BFD_ASSERT (h != NULL); if ((input_section->flags & SEC_ALLOC) != 0) -- 2.9.0