From patchwork Fri Aug 25 02:03:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 136889 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a7d1:0:b0:3f2:4152:657d with SMTP id p17csp1515573vqm; Thu, 24 Aug 2023 19:03:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEK3hSERCE2BKfUQA3my0AUUogPxnvtTmc8cmYXPb0R3LyMb+XWK02YTLx1UeAcWROenKWG X-Received: by 2002:aa7:d502:0:b0:526:5c70:7315 with SMTP id y2-20020aa7d502000000b005265c707315mr12119013edq.6.1692929034822; Thu, 24 Aug 2023 19:03:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692929034; cv=none; d=google.com; s=arc-20160816; b=gdDQ/AGJUbiiLYop2em7Ze4qt0iAZPgxeqPkTk/ca9w8UN9HYrTaYBI3pWsNBEKaJx aPZHj694stxPPPlRz2gZ9AlibP5YE59kz8SjOzzXyxYfttzDHyNjGSWZ7FgSapn03ixB SogyyIO+QJV9A/UX4G/swMIKVBo+qFAbnne6ZR3kVdXcwCJaTHNZM8ZkypYsx5TWkd23 zBcnV2wtPR4ZsZLHo2R0Rtd7lBAO0C7VbPpAtqu+USeyuYLbrS+itEsNme8Mlck05fHh U2WjE2wy73hmlQpIz4TgwPzocF4sn5acNIb0gul4DWpiBGcrSAjrnsa6bkImsunwL7Jn pWmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=75WhBZwBSBu5Wb0wS2QzjJtWqUH3sDQxWi63AYSXXb4=; fh=NLxAvL/bDfPg4AGOtxqvQlND8vazkZrNzKLY8+LAbBY=; b=VO0SPVufieNhcVx3ZJ2KenZDKf7xTIRnQWPO4zzfUG8ZG1tL2ErQhU2II4+hBby8y6 KNNseXfaN5jh9moU7gXZl3XI3YO6LyUh8GWxTONTTvN6JX/yhgjAyxTTKdARjBoxwVPT fi/Frim7T7W0K8YbmlvBfYN6cXSdnDd005SossLpDbTXhQuCom/XaNixJjevDHJbvaNT WAzGqzNlD5OUr9PDGotqJvi8WLzccX42DvSmc1di97ERfC6tO1JxjEd7B2ARAzCySKKX bnK6YrkAAA56iCk4aVdywM7AGNbVOE2wPk5QlUADQKu+Z5xJOQi4K4I0Hd4+QFOazcW7 Lj2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=D1lRIpG8; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id u13-20020aa7d88d000000b0051e23250f88si467330edq.349.2023.08.24.19.03.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 19:03:54 -0700 (PDT) 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; dkim=pass header.i=@sourceware.org header.s=default header.b=D1lRIpG8; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 802A63858C31 for ; Fri, 25 Aug 2023 02:03:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 802A63858C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1692929033; bh=75WhBZwBSBu5Wb0wS2QzjJtWqUH3sDQxWi63AYSXXb4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=D1lRIpG8o9zmFUWyJQoIWSogYJtavUSIFglvHiLnzRHKfobowFYdKW/CWgR5m1br9 U73r89GZKxXWZVwnTjNO3KyqC7j4hJhIx/29BfrQPPDJv90eihkVZ4Gi/1HNp2m7Gz GQHNfdxZb0pM938yfdzRwLNPfEPAENAbwAgOx70s= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id 0E5A83858C53 for ; Fri, 25 Aug 2023 02:03:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E5A83858C53 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1bdbf10333bso4466375ad.1 for ; Thu, 24 Aug 2023 19:03:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692929019; x=1693533819; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=75WhBZwBSBu5Wb0wS2QzjJtWqUH3sDQxWi63AYSXXb4=; b=GlKVQl+b+KRbP5cs6XpvCd6zsEFib6w4UGHYTIbFVTo7fgFDZUSG6RZmruYmFNtzBQ LJmjNMN25pw9i0Wbfc273c0mH/b6/8NfJT9FvnxwFvu7S6yKib2xdSiRdMZB62jw27HI ZVLiB3KcahD7vWsjEm9aK8rRQhtu4UIzG7LoEHX0RJSaFLUrLW5RhBRQ198W32vSv8nY KUJfH51Dk6hFH00/Zy+1bbzV2DUYgKhmzXn+Tc+rU+4bBDlBa3Lyp45Kt5tJL31AT2LV DpUhOEagk6uIZne/mZNcExfCIhsGv/qy2BdYcYVf78MCnshQYliKIpwIfpFkLm4RlBK3 y+xw== X-Gm-Message-State: AOJu0Yw1i2CXw/6ebgCPoDjkyILmtNbRqpOL4JSEIh4FBwnw34t4sR9U kn6a+19EcUu/Mxd1Sm2Jt7oE5Bsj1+3GNA== X-Received: by 2002:a17:902:ea93:b0:1bf:64c9:a67c with SMTP id x19-20020a170902ea9300b001bf64c9a67cmr15343036plb.22.1692929019483; Thu, 24 Aug 2023 19:03:39 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:bbc3:80aa:5336:69d9]) by smtp.gmail.com with ESMTPSA id q10-20020a170902a3ca00b001bb0eebd90asm371871plb.245.2023.08.24.19.03.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 19:03:38 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 0FD6111423DC; Fri, 25 Aug 2023 11:33:36 +0930 (ACST) Date: Fri, 25 Aug 2023 11:33:35 +0930 To: binutils@sourceware.org Subject: PR30794, PowerPC gold: internal error in add_output_section_to_load Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3033.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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: , X-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1775164755623742080 X-GMAIL-MSGID: 1775164755623742080 Caused by commit 5a97377e5513, specifically this code added to Target_powerpc::do_relax + if (parameters->options().output_is_position_independent()) + this->rela_dyn_size_ + = this->rela_dyn_section(layout)->current_data_size(); The problem here is that if .rela.dyn isn't already created then the call to rela_dyn_section creates it, and as this comment in Target_powerpc::do_finalize_sections says: // Annoyingly, we need to make these sections now whether or // not we need them. If we delay until do_relax then we // need to mess with the relaxation machinery checkpointing. We can't be creating sections in do_relax. PR 30794 * powerpc.cc (Target_powerpc::do_relax): Only set rela_dyn_size_ for size == 64, and assert that rela_dyn_ already exists. Tidy code setting plt_thread_safe, which also only needs to be set when size == 64 for ELFv1. diff --git a/gold/powerpc.cc b/gold/powerpc.cc index e66d9cbb900..a4fecaae55a 100644 --- a/gold/powerpc.cc +++ b/gold/powerpc.cc @@ -3714,12 +3714,7 @@ Target_powerpc::do_relax(int pass, unsigned int prev_brlt_size = 0; if (pass == 1) { - bool thread_safe - = this->abiversion() < 2 && parameters->options().plt_thread_safe(); - if (size == 64 - && this->abiversion() < 2 - && !thread_safe - && !parameters->options().user_set_plt_thread_safe()) + if (size == 64 && this->abiversion() < 2) { static const char* const thread_starter[] = { @@ -3747,29 +3742,37 @@ Target_powerpc::do_relax(int pass, /* libgo */ "__go_go", }; + bool thread_safe = parameters->options().plt_thread_safe(); - if (parameters->options().shared()) - thread_safe = true; - else + if (!thread_safe + && !parameters->options().user_set_plt_thread_safe()) { - for (unsigned int i = 0; - i < sizeof(thread_starter) / sizeof(thread_starter[0]); - i++) + if (parameters->options().shared()) + thread_safe = true; + else { - Symbol* sym = symtab->lookup(thread_starter[i], NULL); - thread_safe = (sym != NULL - && sym->in_reg() - && sym->in_real_elf()); - if (thread_safe) - break; + for (unsigned int i = 0; + i < sizeof(thread_starter) / sizeof(thread_starter[0]); + i++) + { + Symbol* sym = symtab->lookup(thread_starter[i], NULL); + thread_safe = (sym != NULL + && sym->in_reg() + && sym->in_real_elf()); + if (thread_safe) + break; + } } } + this->plt_thread_safe_ = thread_safe; } - this->plt_thread_safe_ = thread_safe; - if (parameters->options().output_is_position_independent()) - this->rela_dyn_size_ - = this->rela_dyn_section(layout)->current_data_size(); + if (size == 64 + && parameters->options().output_is_position_independent()) + { + gold_assert (this->rela_dyn_); + this->rela_dyn_size_ = this->rela_dyn_->current_data_size(); + } this->stub_group_size_ = parameters->options().stub_group_size(); bool no_size_errors = true;