Message ID | Z813o_k_loiKCw-K@squeak.grove.modra.org |
---|---|
State | New |
Headers |
Return-Path: <binutils-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9D2C83858C98 for <patchwork@sourceware.org>; Sun, 9 Mar 2025 11:14:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D2C83858C98 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=nCkWI1Wb X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id E70873858D26 for <binutils@sourceware.org>; Sun, 9 Mar 2025 11:12:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E70873858D26 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 E70873858D26 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741518759; cv=none; b=Aldo0Wy/0GIrBC2m27ouGbvIRWhyoSleMQ36BZ6BV2uYXYQFoY21M6+NRVjkWGHparJgkJxuTePVXrCXoG1eJhxc6kDWrOV0pYYtRuXS2PWpUu2xhcClxOdsyf+j4PbwV535zkbm3kLYzZKdY0KQxi72dAECYboltMdAzRAthZs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741518759; c=relaxed/simple; bh=8nafit8j7Qd/tzzdG28duE1wr3xItWVHGpri5aC0mH8=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=np+FFpudt1FDkZKh4bTujgrZw7jZSQIYohXwaQEg1CjpFDMAhY2vgDYkOYVy6pVyoSu8r0RadetYOUR6eGyAtWF65ypTM+s/kkRGIw9xa255KKvcbvm0s9sLKcPGPneKn7hA+4gQus8jn1ObW8HqnpCSWhG65aSEkof3VunU28Q= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E70873858D26 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-224191d92e4so53477785ad.3 for <binutils@sourceware.org>; Sun, 09 Mar 2025 04:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741518758; x=1742123558; darn=sourceware.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=cdnVl7bF6hd+tioWp1mAxuljxkWiFtq803AXoGpMaI0=; b=nCkWI1Wb1vNcqtCwolPLAEltdLlNJG9eDedSdbBeGq6Zb3XDZe+qn2/LmL1xsrW48x 8s3StP1XzUsu90wyrz7QKEg4wew0CA3Pu+eTjBTPqP7ZciwNVWF0d3PteoaHK3Xe2VdX 71m/TkiATcpzertiWQoXnpnJLJg8T14EpWD4smfrj1477cqrO52Vgc8PaWRTWP+XK1nx 9dgbB3IGbMZLsmq72G9/VtxpEGhR8EuuaHFbu3788NMWTgqPaQ+Wl5yqDWFZgoBX6NHu FsynHbfDordpH06aBfPpRJow6RPQlQ9cDJifHRhDvAoSAX8vN0/BR7z1O42rT55H/EtA qBWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741518758; x=1742123558; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=cdnVl7bF6hd+tioWp1mAxuljxkWiFtq803AXoGpMaI0=; b=mAaOq/1Ztzv41M0vUPg6f/chmUTKZQ1NW14jRB/woDLkiS+gHZC2MMkYCXzI1rXuLz 15o0CR1eHLYoO0fNSqmuaZnw4hzUpxNjy9M2zqmyjMXdtx80jIzDflKg8as524lYyFr/ FZvyugDIWyxoTxYMmV07KHW6RH0wh5ToZc7UReaKwWx898jkccdao8iHriD37haOTgx/ phPRBkKPrNPVirH/jyKqjUMY6fQkYvLAjt5my14HtTfUzcRlMwPzLzJ68J8nDyzPRDLb sVW6suxsjV5yqMB6rfR7G/yuj30Xck8/zrhE/H6fQ8lqtCerhA4hBuuOyq+FDNlgMe5L V5oA== X-Gm-Message-State: AOJu0YxJMc5/XCjO0SigcIUFUi4jmNjDzGi1Xfb5ovG0LLbzIu8Z53CK uFbfSecdQA3gQRuZkek7acS/2msl/zfgsOuJWSG5/Vq3jHI1Jz49GG1dvQ== X-Gm-Gg: ASbGncs/FUMoQoNJSiTx8mLPrrusubzXirz6et3iMRzW8GxmEcG3QHyMOosCc4486iP 2Pz7q3h6tKFf/8zVK4M5yJToKwZnUymgbMq5+dTcwXO3w1FXL5qWkP/BH2+INCzt8HcPMax3JSP e49eUKz86B87oOfid/74z1O707sDjgMbkoo0RI00Q25vrAzXaQBU2v5ECkyWE/OyaYEfHfbN2XI sDjqn3W5Nt4eKzHSciodhgSutGDEaJZDmZ0fTMSlXPfKs36gXnEp3WvKbavrSGVDb/j/TzAgHAC tH7ifxsqaR5uqxKzuihMn58F/GoJhQ8HyegU8xDpgvHuImGuz0zz/5+Hqbo9d43turLozJGbfyF BP2vp7GD1LKgTlSQ= X-Google-Smtp-Source: AGHT+IFAXORQDo7RPx8GqmX0HIKVyA+4si6nhfPfVjUIDp9zbxIQFLoEELXa8zIcbPjetJuPEQI0+A== X-Received: by 2002:aa7:8590:0:b0:736:ab1e:b1ab with SMTP id d2e1a72fcca58-736ab1eb2ffmr11739669b3a.0.1741518757761; Sun, 09 Mar 2025 04:12:37 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7369970ae29sm6157537b3a.40.2025.03.09.04.12.37 for <binutils@sourceware.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Mar 2025 04:12:37 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 5668A1142102; Sun, 9 Mar 2025 21:42:35 +1030 (ACDT) Date: Sun, 9 Mar 2025 21:42:35 +1030 From: Alan Modra <amodra@gmail.com> To: binutils@sourceware.org Subject: meaningless p_offset for zero p_filesz PT_LOAD Message-ID: <Z813o_k_loiKCw-K@squeak.grove.modra.org> References: <Z8122NMNZMwVpmml@squeak.grove.modra.org> <Z813XYdEuR-N1ElG@squeak.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <Z813XYdEuR-N1ElG@squeak.grove.modra.org> X-Spam-Status: No, score=-3032.2 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.30 Precedence: list List-Id: Binutils mailing list <binutils.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/binutils>, <mailto:binutils-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/binutils/> List-Post: <mailto:binutils@sourceware.org> List-Help: <mailto:binutils-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/binutils>, <mailto:binutils-request@sourceware.org?subject=subscribe> Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org |
Series |
meaningless p_offset for zero p_filesz PT_LOAD
|
|
Checks
Context | Check | Description |
---|---|---|
linaro-tcwg-bot/tcwg_binutils_build--master-arm | fail | Patch failed to apply |
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 | fail | Patch failed to apply |
Commit Message
Alan Modra
March 9, 2025, 11:12 a.m. UTC
Maybe I should have stayed with WONTFIX for pr25237.. This patch avoids generating PT_LOAD segments that trip a bug in glibc's loader. PR 25237 PR 32763 * elf.c (assign_file_positions_for_load_sections): Don't put p_offset zero for empty PT_LOAD.
Comments
On Sun, Mar 9, 2025 at 4:14 AM Alan Modra <amodra@gmail.com> wrote: > > Maybe I should have stayed with WONTFIX for pr25237.. > > This patch avoids generating PT_LOAD segments that trip a bug in > glibc's loader. > > PR 25237 > PR 32763 > * elf.c (assign_file_positions_for_load_sections): Don't put > p_offset zero for empty PT_LOAD. > > diff --git a/bfd/elf.c b/bfd/elf.c > index 20f96e689ce..ee89dd909da 100644 > --- a/bfd/elf.c > +++ b/bfd/elf.c > @@ -6170,7 +6170,10 @@ assign_file_positions_for_load_sections (bfd *abfd, > align = p->p_align; > if (align < 1) > align = 1; > - p->p_offset = off % align; > + /* Avoid p_offset of zero, which might be wrongly > + interpreted as the segment being the first one, > + containing the file header. PR32763. */ > + p->p_offset = (off + align - 1) % align + 1; I think your original patch makes sense since it is odd for p_offset > file size even if it isn't used. > } > } > else > > -- > Alan Modra
diff --git a/bfd/elf.c b/bfd/elf.c index 20f96e689ce..ee89dd909da 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -6170,7 +6170,10 @@ assign_file_positions_for_load_sections (bfd *abfd, align = p->p_align; if (align < 1) align = 1; - p->p_offset = off % align; + /* Avoid p_offset of zero, which might be wrongly + interpreted as the segment being the first one, + containing the file header. PR32763. */ + p->p_offset = (off + align - 1) % align + 1; } } else