From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by sourceware.org (Postfix) with ESMTPS id 0A4B03972824 for ; Thu, 14 May 2020 21:00:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0A4B03972824 Received: by mail-pf1-x436.google.com with SMTP id x77so1928738pfc.0 for ; Thu, 14 May 2020 14:00:39 -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:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DjwYZEBD4dLQZtYkMS0VskGY7+obUaPOSff+m9F9MuQ=; b=i3KNG/qYbU7c9G2QWteE9w8YdUhc2CvTW/YRvtaxpBcHGAzZe6eAHJC+o2zics+Eh/ TubRKj9aNiREI9kScXc/flyDosGd2kMW0KPTbX7mbEC/gI2zR33Ey4aajXhPe/KBVv/N tFDqhdH6S+rrXISn1U5irmuxrsll5qbilZtL0k9rcls+WunohE94ChZBzqQz+YR/pRtL KaDJGWGnT4oXtnBA+Q3ZLbRy7JNUy9cidJ6Hi9j//9Nm0MKuIkVIZW3NbQbqjz3Gbrr4 HegI4KSp90K+BvFYO+gqVVBbWzHHolVE5+f4igW8nGtyJRdlBrALVHuGcy+FFITGS0JV LxHQ== X-Gm-Message-State: AOAM530gdJ2VrRwo4qsCUHmKRvzud4EIQWc0ib8o38XVNf4KcrS5Yev3 yuh62klaNqsBOUX1AV7IY9jEePzr X-Google-Smtp-Source: ABdhPJx2QnFP5oa9rO09Epd1duZ1709ILaEF5jWSme18aPAF6c9KaZejs13HdfJUMUYjEw7V6/iWMg== X-Received: by 2002:a05:6a00:2b4:: with SMTP id q20mr448886pfs.104.1589490037525; Thu, 14 May 2020 14:00:37 -0700 (PDT) Received: from localhost (g216.222-224-245.ppp.wakwak.ne.jp. [222.224.245.216]) by smtp.gmail.com with ESMTPSA id e21sm100815pga.71.2020.05.14.14.00.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 May 2020 14:00:36 -0700 (PDT) From: Stafford Horne To: GNU Binutils Cc: Openrisc , Richard Henderson , Stafford Horne Subject: [PATCH 2/8] or1k: Fix dynamic TLS symbol flag Date: Fri, 15 May 2020 06:00:12 +0900 Message-Id: <20200514210018.2749462-3-shorne@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200514210018.2749462-1-shorne@gmail.com> References: <20200514210018.2749462-1-shorne@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_STOCKGEN, 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: Thu, 14 May 2020 21:00:41 -0000 The dynamic flag used for TLS relocations was not properly being set for some cases causing link failure. The fix here was mostly copied from other BFD implementations. bfd/ChangeLog: yyyy-mm-dd Stafford Horne * bfd/elf32-or1k.c (or1k_elf_relocate_section): Fixup dynamic symbol detection. --- bfd/elf32-or1k.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c index 221a14c5b1..99a36c7f04 100644 --- a/bfd/elf32-or1k.c +++ b/bfd/elf32-or1k.c @@ -1592,6 +1592,7 @@ or1k_elf_relocate_section (bfd *output_bfd, asection *srelgot; bfd_byte *loc; int dynamic; + int indx = 0; srelgot = htab->root.srelgot; @@ -1618,13 +1619,23 @@ or1k_elf_relocate_section (bfd *output_bfd, BFD_ASSERT (elf_hash_table (info)->hgot == NULL || elf_hash_table (info)->hgot->root.u.def.value == 0); + if (h != NULL) + { + bfd_boolean dyn = htab->root.dynamic_sections_created; + bfd_boolean pic = bfd_link_pic (info); + + if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, pic, h) + && (!pic || !SYMBOL_REFERENCES_LOCAL (info, h))) + indx = h->dynindx; + } + /* Dynamic entries will require relocations. If we do not need them we will just use the default R_OR1K_NONE and not set anything. */ - dynamic = bfd_link_pic (info) - || (sec && (sec->flags & SEC_ALLOC) != 0 - && h != NULL - && (h->root.type == bfd_link_hash_defweak || !h->def_regular)); + dynamic = (bfd_link_pic (info) || indx != 0) + && (h == NULL + || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + || h->root.type != bfd_link_hash_undefweak); /* Shared GD. */ if (dynamic -- 2.26.2