From patchwork Tue Sep 1 02:33:08 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Turner X-Patchwork-Id: 142570 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0070A4BA79A1 for ; Tue, 1 Sep 2026 02:34:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0070A4BA79A1 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=L4iDgDul X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by sourceware.org (Postfix) with ESMTPS id 6D03B4BA23EB for ; Tue, 1 Sep 2026 02:33:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6D03B4BA23EB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6D03B4BA23EB Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::112b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788230004; cv=none; b=d4ha5Z/W/3wpAWCUxGqaADee/H9Bgrxkppngk8gEQNTkzBPFLnvXdpQDInDGTz44V8X2p7Onr9vqo5NbtrYB6noDTZQzCW9scTRAQ9SRdTvG9AHkwdqw31Vtjda6HPQJCcLO6fk42F2tZxchk0uhoJbe0lNhHPsyMye/yxMH8wA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788230004; c=relaxed/simple; bh=4uwKW6oISFCkA+iUuiLE1X1X/IlHhTYwkw2N6LwQJ2E=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=XfAXED4O1Wie3ECYEPnmCJAsGh4F1+OhJ5jQwFXUTo4X0CPxM7ni481fx8cTO7kzZsgofcRq6cqjI5/G2nccF9E72HQK3lv2IR5hVPDKlzoe8JygbC38xI+9jc2k5SoV8uegCaSVpDTYIn81KdX8QCKNItbyK4uiZPwcermQ9VM= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=L4iDgDul DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D03B4BA23EB Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-8200b55dc47so40422007b3.3 for ; Mon, 31 Aug 2026 19:33:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788230004; x=1788834804; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=c49xvp6JYqq2Vm8oWKJh81pcIRZiVhEFuJezJBbnPGo=; b=L4iDgDulA5CH1qHB/nEn9bQXHvJPjrOfDqqbzxvWOhiVE49jQGhtCTtI5Fki/dB8+N U19sGFWhGYw3oOoi7AC/fC0EV5uWMU4JR3FuaNTTYWXzZLqSB0HMHYhM4RbsgpiS0Dg2 jd3gDlCFwzE66mE2/8/otXFKewvwqmiDbDZOWWSQXX6FhiU4wcRDBenPhwFwQ18VfDKE mGNPtewk0EJ5qB/MVW15P/gCWfnZ4iHHYqJqoyhmHMReTSocIca6rG99m7WqIH+RaTDT HJ1C7XV3MkoJlpn/37tJpyryhJ3p2JAuQUluUB3eDCM+CS8n6smziBA3Em5u36L79DQF dJpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788230004; x=1788834804; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=c49xvp6JYqq2Vm8oWKJh81pcIRZiVhEFuJezJBbnPGo=; b=R5qCU+D+9eGYMp3TTJkQTMh4XQiWD4LwzOyHWvrsmkCCzPSRaPMg0Q9yvmGnEFi6hj Uw4DcZaXTPmLaZHIIR2ziXTCHJB1BhRxkJMC02Eg9C6zRo4lKugbjhvFdy6GMQptbehy CtQe3hEX6AoQMoCeD1UREmzLmdMfUnvnGUTJAA60Ryg3yZbpimez7/xIs+kI+QhjGszk yQHQRHDrTRyTYwaZSYatagWXPOr882OQKmACSBNF/Gs8s6F0Hou83N7h0UWlQo85slBf OdTIs7rHr2ASGRvnRmnTY0u1Kjc3y0b6RL5I3QPjaEbviME2Dtma6uhATJ9JUuQ72eX5 hH/w== X-Gm-Message-State: AFuF++m5svBqbZJtaH0ZfsrTjCkI3LuU1BDOJAhQvoWSY5NuHVECV78B HJ8uo7ZoZJ4mGHAFw+HREijaA3Ni4O728MgUSQ17qVESruAKdwpheW3FKnCPxA== X-Gm-Gg: AYBFou2vj2uPH3fNz3lTkJ4L/8KylrZ508xZF7TINuwu2SCZGChdqBXKGCzE8YrgaoC 5d5ABe3rC4vp515cVVShHJCOGfkwIqXv7+zi5QJyFb2VbCTS2n4dOTgib7tyURSVUKQWnEfFbxZ 63BOrZapFJH8UlwusVx4VeXPOkp6gRhmmkFsYFxIXUuZaTSkIHPjb1MC1/jcxavPQE+1f3f5+VS SWAhnZIPNV7uHwJWpYaFTFmkCNPW+OGLhpSJpGhfdwrG0s8PzczqB6t13pu+74CFAmCr+RCY+Pg cNgwgONxDBJsnESA6c3qlk8DrTm5XU3eq3wjkLoUpD+wvLiIfcVeU9CgVEPuxnUHD46isVollrc Sju5Iera+y1baKXd7xs4Sm0xpmC2iw29mzDMmKDDzbkA2YY7V429CL9jTGr0QdMZjfVVpsKOu+8 D7VCuLSymklNmtImkRnAxS1KORw8a8UlbK/Csir7ENQZpA4aiE93oP7F1pMG3mD4/8U9Crp91NE fe7J0rzzVTbzwBgVSu1/3vN5uWZZnuh+IL+8zRqfcWP9s83UBg= X-Received: by 2002:a05:690c:6608:b0:861:2228:a4d3 with SMTP id 00721157ae682-8612228af79mr56764897b3.19.1788230003473; Mon, 31 Aug 2026 19:33:23 -0700 (PDT) Received: from localhost (107-220-129-194.lightspeed.chrlnc.sbcglobal.net. [107.220.129.194]) by smtp.gmail.com with ESMTPSA id 00721157ae682-85e5ed19446sm64861357b3.14.2026.08.31.19.33.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2026 19:33:21 -0700 (PDT) From: Matt Turner To: binutils@sourceware.org Cc: Magnus Lindholm , Alan Modra , Matt Turner Subject: [PATCH 01/11] alpha: initialize every field of a new got entry Date: Mon, 31 Aug 2026 22:33:08 -0400 Message-ID: <20260901023318.3503991-2-mattst88@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260901023318.3503991-1-mattst88@gmail.com> References: <20260901023318.3503991-1-mattst88@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org get_got_entry allocates a got entry with bfd_alloc and then assigns the fields one by one, but never assigns flags. elf64_alpha_merge_gots reads it, so two got subsections that merge OR uninitialized memory into the surviving entry. A literal always has flags assigned by check_relocs before then, from its LITUSEs or from the fallback that marks it as an address use, but an entry created for a TLS relocation has no such assignment. elf64_alpha_relax_tls_get_addr allocates one the same way when it switches a general dynamic sequence to initial exec and the object has no GOTTPREL entry yet. That one leaves both flags and plt_offset uninitialized, and a stray plt_offset is not a value the rest of the code expects to see. Allocate both with bfd_zalloc and assign only the fields whose initial value is not zero. A new field then needs no assignment at either site, rather than one that is easy to forget at the second. Found with valgrind. --- bfd/elf64-alpha.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git ./bfd/elf64-alpha.c ./bfd/elf64-alpha.c index 8b8a97a4b05..4fc1a542704 100644 --- ./bfd/elf64-alpha.c +++ ./bfd/elf64-alpha.c @@ -1718,7 +1718,7 @@ get_got_entry (bfd *abfd, struct alpha_elf_link_hash_entry *h, size_t amt; amt = sizeof (struct alpha_elf_got_entry); - gotent = (struct alpha_elf_got_entry *) bfd_alloc (abfd, amt); + gotent = (struct alpha_elf_got_entry *) bfd_zalloc (abfd, amt); if (!gotent) return NULL; @@ -1728,8 +1728,6 @@ get_got_entry (bfd *abfd, struct alpha_elf_link_hash_entry *h, gotent->plt_offset = -1; gotent->use_count = 1; gotent->reloc_type = r_type; - gotent->reloc_done = 0; - gotent->reloc_xlated = 0; gotent->next = *slot; *slot = gotent; @@ -3655,7 +3653,7 @@ elf64_alpha_relax_tls_get_addr (struct alpha_relax_info *info, bfd_vma symval, else { tprel_gotent = (struct alpha_elf_got_entry *) - bfd_alloc (info->abfd, sizeof (struct alpha_elf_got_entry)); + bfd_zalloc (info->abfd, sizeof (struct alpha_elf_got_entry)); if (!tprel_gotent) return false; @@ -3665,8 +3663,7 @@ elf64_alpha_relax_tls_get_addr (struct alpha_relax_info *info, bfd_vma symval, tprel_gotent->gotobj = info->gotobj; tprel_gotent->addend = irel->r_addend; tprel_gotent->got_offset = -1; - tprel_gotent->reloc_done = 0; - tprel_gotent->reloc_xlated = 0; + tprel_gotent->plt_offset = -1; } tprel_gotent->use_count = 1;