From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 94281385800F for ; Sun, 3 Jan 2021 02:22:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 94281385800F Received: by mail-pg1-x533.google.com with SMTP id 30so11821556pgr.6 for ; Sat, 02 Jan 2021 18:22:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=bE/HPQbE+Ui1yK9iQKG28tNvqm4h8kk3bMR8LmZ6b9o=; b=mC8QFJcMqbKucuUSbqTXSu8fvF0CNo4QFYfEF5lIyFVn+nzWWZ2+djN4wg632Pu2+d hkiV4Y8vqbrXCufxRDskvE/QTzhKaAw0vG4qQu/7eW7oFcfIusfvX6m5RA9SWLPzWDdu 44ag7FCLIg0MQsBuPH6DyDQrzvDtxZAbHeyeUA3Sk+0wWDDZIGhRY591YyvwAsUi8dZj B1QTFt87CzcaWI2YcWaGF/dF7809N0+CkGFlsrYMeAQkjcCo415Yd7Rq5oOg7mQPzuIz 0UGjnbrgMrqJNJh6ez7WyMUNeiqq0NPqeD5IuKSEcSRrMSDMffL/aoJXpI12Eb85WbCk I/0g== X-Gm-Message-State: AOAM532ecdWPT66rkJQXSzV7aBw5orPbSqPL5uQXradypUEB4Z7Sik1z JmjI9d1nq5k5Z4ls+sm8SE1dnOiRki/cTg== X-Google-Smtp-Source: ABdhPJwl8GWuuGDrNlZOvulVwxsOzffql91puuwIJYCEUpER8ShorCHyZkXhw41dOQCsQU1Tbft5Vg== X-Received: by 2002:aa7:82c1:0:b029:19e:3672:50ca with SMTP id f1-20020aa782c10000b029019e367250camr40522904pfn.12.1609640571271; Sat, 02 Jan 2021 18:22:51 -0800 (PST) Received: from bubble.grove.modra.org ([2406:3400:51d:8cc0:488b:dd26:4949:4c70]) by smtp.gmail.com with ESMTPSA id c3sm49142247pfi.135.2021.01.02.18.22.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Jan 2021 18:22:50 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id F29348536B; Sun, 3 Jan 2021 12:52:46 +1030 (ACDT) Date: Sun, 3 Jan 2021 12:52:46 +1030 From: Alan Modra To: binutils@sourceware.org Subject: PR27140, ppc32 segmentation fault in make_stub Message-ID: <20210103022246.GE5129@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-11.6 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.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: Sun, 03 Jan 2021 02:22:53 -0000 This fixes a thinko in commit fa40fbe4849. st_other global entry bits are relevant only for 64-bit ELFv2. PowerPC gold leaves local sym vector of st_other bits as NULL for 32-bit, hence the segfault. Committed. PR 27140 * powerpc.cc (Target_powerpc::Branch_info::make_stub): Only access object->st_other() when 64-bit. (Stub_table::add_long_branch_entry): Ignore "other" when 32-bit. diff --git a/gold/powerpc.cc b/gold/powerpc.cc index eca9741a90..e2966ef096 100644 --- a/gold/powerpc.cc +++ b/gold/powerpc.cc @@ -3536,7 +3536,7 @@ Target_powerpc::Branch_info::make_stub( from += (this->object_->output_section(this->shndx_)->address() + this->offset_); Address to; - unsigned int other; + unsigned int other = 0; if (gsym != NULL) { switch (gsym->source()) @@ -3564,7 +3564,8 @@ Target_powerpc::Branch_info::make_stub( to = symtab->compute_final_value(gsym, &status); if (status != Symbol_table::CFVS_OK) return true; - other = gsym->nonvis() >> 3; + if (size == 64) + other = gsym->nonvis() >> 3; } else { @@ -3581,7 +3582,8 @@ Target_powerpc::Branch_info::make_stub( || !symval.has_output_value()) return true; to = symval.value(this->object_, 0); - other = this->object_->st_other(this->r_sym_) >> 5; + if (size == 64) + other = this->object_->st_other(this->r_sym_) >> 5; } if (!(size == 32 && this->r_type_ == elfcpp::R_PPC_PLTREL24)) to += this->addend_; @@ -5303,7 +5305,7 @@ Stub_table::add_long_branch_entry( this->need_resize_ = true; p.first->second.toc_ = true; } - if (p.first->second.other_ == 0) + if (size == 64 && p.first->second.other_ == 0) p.first->second.other_ = other; gold_assert(save_res == p.first->second.save_res_); if (p.second || (this->resizing_ && !p.first->second.iter_)) -- Alan Modra Australia Development Lab, IBM