From patchwork Mon Jan 9 08:35:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mengqinggang X-Patchwork-Id: 40698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2040345wrt; Mon, 9 Jan 2023 00:35:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXsYaGgV/Uu949Z0w5y4xox85/QTzV8Vxx91cUVKYkMH13VMDtWDubCUWq/SX7wFo1EC7r/e X-Received: by 2002:aa7:d60e:0:b0:488:f6a3:2dd6 with SMTP id c14-20020aa7d60e000000b00488f6a32dd6mr36723658edr.41.1673253347510; Mon, 09 Jan 2023 00:35:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673253347; cv=none; d=google.com; s=arc-20160816; b=sXrYqUHzUKpWBHquRkna8+pwBqgTXiLjmjVZxQgpEguag/HOff3e1ckr+ktxYPfv9p urXt36uC94KM0wpDvPdl806BerGHJCOezOhRoi+Mbf/qL4U//7L/BaQ8D01cDUFIHqVG gaStpJ4PijGtbx2+jJLZHqb5deBL4FJQ8MW4KXrbPZLUeOoStFwA9GIO1AOZSW/HLolX ufhHuhkm3kcets2BoBLV936ttNvq7iBaGJh97MrQLYtQa3caz1X9LnjfSC7jrSMuBSZt JCkXvDUUh3JnavjbDcSfSEEdB53dx0iKKd0MyEY6netAt8rg7MgHxcTpXbopPds7DSvM xXlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dmarc-filter :delivered-to; bh=MvYS/ohKgkvkkR+7FdiEaEjCNAFIkUIQNwSNNwIQtDE=; b=JIp3BmJoDrt9NZ6GY/jOv6JYCIHKzrux6jP8Bv+LfJPN9VJeCaFWTJsc+NmtJFymdO Jv7gHxv+QJiQu350cLgcC+Gny5GCt+BQjOg60snwg8BnSd53qkmUKSjOJb6c7F94huoa NWN/fCk0uVrNNh4veEzsRLQsz0I700ZKIx5VMUskPcqylajbiUy1qU1oy5z3WjDSkrGp mct9C20szxlWpNz9FjFhDi7S7091Opr6esiGAvDjaXSZMDS4/7w8rL2zDI+YEBQfb7Tw zTER0DajZvpqquy5sEJDWvERjbi7z6oY6KBRHeIZP+MD+zojRBb8UPsWAStM/sLpooi2 RCFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id e10-20020a056402190a00b004614db9789asi10976876edz.127.2023.01.09.00.35.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 00:35:47 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 567E9385841E for ; Mon, 9 Jan 2023 08:35:46 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 082EE3858D20 for ; Mon, 9 Jan 2023 08:35:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 082EE3858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.2.5.5]) by gateway (Coremail) with SMTP id _____8BxLuvX0btjLXQAAA--.1370S3; Mon, 09 Jan 2023 16:35:36 +0800 (CST) Received: from 5.5.5 (unknown [10.2.5.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxUuXQ0btjaKcWAA--.4785S2; Mon, 09 Jan 2023 16:35:35 +0800 (CST) From: mengqinggang To: binutils@sourceware.org Cc: xuchenghua@loongson.cn, liuzhensong@loongson.cn, chenglulu@loongson.cn, caiyinyu@loongson.cn, xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com, joseph@codesourcery.com, mengqinggang Subject: [PATCH] LoongArch: ld: Fix hidden ifunc symbol linker error bug. Date: Mon, 9 Jan 2023 16:35:26 +0800 Message-Id: <20230109083526.74448-1-mengqinggang@loongson.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8DxUuXQ0btjaKcWAA--.4785S2 X-CM-SenderInfo: 5phqw15lqjwttqj6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjvdXoW7Gr4fZw4kZw1UArWkAr4Dtwb_yoWkArgEva 47tryrKF47tFWUKwn8Wry5ta4IyrZ3XF1vvF1kGrW7Ga47tF15A39xWr1Fkr1UKr4fuFnI vr4qgr1fAFW7ZjkaLaAFLSUrUUUU8b8apTn2vfkv8UJUUUU8wcxFpf9Il3svdxBIdaVrn0 xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3UjIYCTnIWjp_UUUY g7kC6x804xWl14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3w AFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK 6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j6F4UM28EF7 xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJwAa w2AFwI0_Jrv_JF1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44 I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JF0_Jw1lYx0Ex4A2 jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20x vY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwCFI7km07C267AKxVWUXVWUAwC20s02 6c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw 0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvE c7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14 v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7I U8ewZ7UUUUU== X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754533302147948054?= X-GMAIL-MSGID: =?utf-8?q?1754533302147948054?= For hidden ifunc symbols, it not have GOT entry, only have gotplt entry. When process R_LARCH_SOP_PUSH_GPREL, the offset is gotplt entry address minus GOT address. When call bfd_put_NN(got->contents + offset), the absolute value of offset is grather than got size, and other memory not belonging to GOT is be overwritten. bfd/ChangeLog: * elfnn-loongarch.c (loongarch_elf_relocate_section): If hidden ifunc symbol, don't call bfd_put_NN. --- bfd/elfnn-loongarch.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c index fafdc7c7458..449fad6d25d 100644 --- a/bfd/elfnn-loongarch.c +++ b/bfd/elfnn-loongarch.c @@ -2502,7 +2502,10 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, if ((off & 1) != 0) off &= ~1; - else + /* If h has processed (h->got.offset |= 1) or h is hideen + ifunc (h->got.offset == -1), skip it. Hidden ifunc symbol + not has got entry, only has got.plt entry. */ + else if ((h->got.offset & 1) == 0) { /* The pr21964-4. Create relocate entry. */ if (is_pic && h->start_stop)