From patchwork Thu Feb 8 20:53:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 198570 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp445462dyd; Thu, 8 Feb 2024 12:54:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVy2sH2FHwp97Sj9gPas6pqpJzOoUpYPnnm+PTzj27fvMrhzeiKsE4aUH43x6hyypx8hDPNSbvVeq+iy8+szRsq6ZEXaQ== X-Google-Smtp-Source: AGHT+IFjb/F9sM+rWSa6IB/QDdVoMQUYCHCPtNj/oxP7+du9Skdfrf26pIn7mgzKDkWCUoxRBL+s X-Received: by 2002:a05:6808:4243:b0:3bf:d1f4:5563 with SMTP id dp3-20020a056808424300b003bfd1f45563mr446768oib.59.1707425668615; Thu, 08 Feb 2024 12:54:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707425668; cv=pass; d=google.com; s=arc-20160816; b=pipR/hJgK2971uipZVlblioVrnAkyGGF5hrDaYDgRZCl0JKHuiBhFzzEOHamtYB18T 6By9xV2ikg1O+7buIufCP9K6w127tkUpEQCPxgVoHGxBA5vONIkEAQYaNnmIvmqDgdz2 o2zMOYJmmvkZ4mlUDJYP6CAVMZCRdhfo5m+mqFvwmkBX8DTDgrL9Aiqckphi6KVjLTQu PeIMrCpNrGGp9mQwG+QSxDLGB+fP3O8wdY+DDpBaTUe0fIYOP3Zz70qvBkvECG+lU+2C P5B7XzzDm8cY5YQ8Abn8Q/EFOZjNLe8wTKRyrLyUvX5WP5V+UrabNeuZvAwXz23Jw8xi /mwg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :mime-version:message-id:subject:to:from:date:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=YTl6Jeo0UI6MNSXJmjOJQEXT/HP4g8vGS0/6NEtTj9I=; fh=+B8q/4VfjBJgpCThv6/J8UOou/GZWHPQ+sdLssfyOqQ=; b=d1pF2kIbXVjfR9EUDq1traUQmYBDhmRMrrtCOK8xYNRB2JvftaQBQbV1zzA595yuAJ 4/YyZ92v1u1E4hX+MYRxsrOF2aP16Vak8KvODT1Vf1g4Db5ObYFrtj/cw/Dte2MtBLt7 +HZSKBgKJjJbDNFGXrsTFiGQPSeNDhPbFdRaF0v0GJh6q5b9yvYWxqHbc8vbjkZ4mHWX RFWeZQnxwbRlnQc10uxn37WYmjhVjg+L/iAUlhGBUVYQQObWj+mqhiTg4/hN26XbhTEn 4MYuQotk6ddv1C8eAOyWZuedV0b6KlT6F/N5d1NOH9ruyEL3ysGYM3lSq8oiYM0c55GN X1Pw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NjvdT4GW; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCWPZ/suC7sj/UfWE9DcJg2+PeWl5Webb9nM8Zq8/3girOTwTFQsyz6WJsTwI4B9jL0pHGg5vZsJyKRZr33qqPZ3rQNjFA== Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w14-20020a05622a134e00b0042bf643b863si291832qtk.783.2024.02.08.12.54.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 12:54:28 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NjvdT4GW; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4617A3858403 for ; Thu, 8 Feb 2024 20:54:28 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id 5D94B3858C78 for ; Thu, 8 Feb 2024 20:53:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5D94B3858C78 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 5D94B3858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707425634; cv=none; b=ObLkbTuxjy/gTPc2l94Ah/1Vouos31tt+VHMKnOHiGEmAxI687kqhYmQ+pd5VBOkQW9WUe7ISTfFhg3nYKBcJ79ArmyqqO6Efw2VkezbTfoZyrfTA43nlEIjuJ9B35s70SVLYSpQnFvimMILpxQbzqgsQnkSZqiLXj3IoQYspD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707425634; c=relaxed/simple; bh=lEGJK+uuYQT748L633Vv1YpOmzgnCrnyGZD/ta4dl6I=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=SWn2v+S9VSY80NKZwHV0+6jfOj4FvjqQnzB1Cu6hKiqVf0GY+MuUyIDwEJO5bQvQfXgADwV09V8cs49blXnfKCLpK4r7QFc+ON107qNWYVJe5LjjBCKoO/wl7V7FKGUHF2qrmuc1/7Kel+kfpEtkiXdw7Pw0AKxeYWX4GEFnyv8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-5dc4a487b1eso160411a12.1 for ; Thu, 08 Feb 2024 12:53:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707425627; x=1708030427; darn=sourceware.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=YTl6Jeo0UI6MNSXJmjOJQEXT/HP4g8vGS0/6NEtTj9I=; b=NjvdT4GWN7bLCqGuP4HnZcvxIUbz9ghHgIcc61ad8V1kl36SjYHigA3pwrhmRqnd77 bhrWdPf3wHmzVs9Iax5ML3Ne6Mvo+DlM+BhkqQMjjHeaIwtXPCjiOLlkAewqrMeqh+qu eZ71bj6NtJXkB6hq6JzH80M1XzRR/YSrtr9LfVNsmwOX8jE+fwam0NwmFiaBnO1Qt5oO anJZrPxLqXvXyfx/s8kmp4xQ0w+cI+reiToiMVeE75xx8083t8A1iqQwIcQBYa+jklRm 4mqMR5e6Qsg4OFj/73f+PZg0uFnocYyLlJsJa+MiI9SVvvEYUwhxWVcd8jO1lUOsZ5aV bKdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707425627; x=1708030427; 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=YTl6Jeo0UI6MNSXJmjOJQEXT/HP4g8vGS0/6NEtTj9I=; b=ilwrF5om0LU63HH+dkiqzgtmaXiCi3hQgm5+b76tFuV+XWasi7GaON5t6LWSeOQinY Tz/XI1IBriITw5esKyyD0M27JaPdX3+H1f8ZKAklEvfBUZ7BsoO7Zu7OpPgnOGijg7Bg uBzR2wKjfESHPSjwI5jZ4NNEk/tB6DoWQOzIEsoCzfEfyJXKXh5iuiK3nX5/p/DRlhII nTTtPe3UHBNzeDAh3cp7KNZ/Qsf9euJBGIFTfgWQuC0aM49cjHHOFcp6ctRJnmWWA2l2 hiHgWwPulSCRyxm/HsEn3W3LwcYYbCAnyPpDearwTXqcLptFEdGI1OartWeCpssvo4sq IBuQ== X-Gm-Message-State: AOJu0YxvU8n3ATwHcCK/+URYliQhMKwKJBFFXOqvUDv0/yvY4uy/DZjb oRTOlXX5CO7BeFbVRaWYqQcNo5BEKntF1zfoaTUggzl8wSWanxh6zLaOesjs X-Received: by 2002:a05:6a20:2ca9:b0:19e:9873:aa54 with SMTP id g41-20020a056a202ca900b0019e9873aa54mr681379pzj.58.1707425627361; Thu, 08 Feb 2024 12:53:47 -0800 (PST) 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 gz21-20020a17090b0ed500b00296b90d93absm229414pjb.29.2024.02.08.12.53.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 12:53:46 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 30A231140B74; Fri, 9 Feb 2024 07:23:44 +1030 (ACDT) Date: Fri, 9 Feb 2024 07:23:44 +1030 From: Alan Modra To: binutils@sourceware.org Subject: PR31208, strip can break ELF alignment requirements Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-3033.9 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, T_SCC_BODY_TEXT_LINE 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790365577552551782 X-GMAIL-MSGID: 1790365577552551782 In https://sourceware.org/pipermail/binutils/2007-August/053261.html (git commit 3dea8fca8b86) I disabled a then new linker feature that removed empty PT_LOAD headers in cases where a user specified program headers, and for objcopy. This can be a problem for objcopy/strip and since objcopy operates on sections, any part of a PT_LOAD loading file contents not covered by a section will be omitted anyway. PR 31208 * elf.c (_bfd_elf_map_sections_to_segments): Pass remove_empty_load as true to elf_modify_segment_map for objcopy/strip. diff --git a/bfd/elf.c b/bfd/elf.c index 88c75ae3ce0..8bffd3c5141 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -5789,7 +5789,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, elf_seg_map (abfd) = mfirst; } - if (!elf_modify_segment_map (abfd, info, no_user_phdrs)) + if (!elf_modify_segment_map (abfd, info, no_user_phdrs || info == NULL)) return false; for (count = 0, m = elf_seg_map (abfd); m != NULL; m = m->next)