From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by sourceware.org (Postfix) with ESMTPS id 94B5E384AB59 for ; Tue, 23 Apr 2024 11:45:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 94B5E384AB59 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 94B5E384AB59 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713872742; cv=none; b=becjsRNobrtsql3/NVddGkfFgMB/t/QRA3zV2ccBpknI6LWAMZajPM+HOomS3Zg6Bb5zQ8PoSHe7KMK0g/sFH/dBO7B5uYteSTW+o8jkwLSeDte6bZuxgzjL2JWbMIgRqh8K8EEbvWKD9ppA/kzaY0dfTJQRx2V4qHd7CVVSK24= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713872742; c=relaxed/simple; bh=mXdevHfI9ccFmToh//Me/XH91oig7ZFpMPRdinh6qwA=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=BOCDxk+BJY1mox1Hrg6eZp49ciJLxF0SZD6/CqhW09KOCAP8OgBecxoYdcHC8JeOTMfuMW7omnIjpN+XDQunMbRXb1raSyjJiMXmMByCKgdLd5Y2RGnnyQ/C6bc5GUOqPAvTvni27IwXfsRGpiP0gDS8Jn0CpSX8h3m0nf/61ns= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1e5715a9ebdso45264115ad.2 for ; Tue, 23 Apr 2024 04:45:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713872739; x=1714477539; darn=sourceware.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=BX1/t0yrBDKFHwTVnk8h3M5ktB/7ytpEkd+yT5ZWUjI=; b=i5wpXnW9rN5ixu20cbpkQLvj2nwoBUhzNMKo0H/dZNWaqOCiO9FxlUaLN1hcMuBH1T m8rB9tS3Uf9Ox2lyZ2QkufjqlQrW/hkeEi+6on0FsVxI5ttGkcoESEBvWsBEzjcLV4/g LkEAzvCzYEjnSH85Sf/MQt5CxMqCmKPN7ngaVh0XyC5SncsUVRqMwfslZd/Y0bpAnYWI E9kOd9bdgVmGOVZ2PosdIGmq18rBv/oGkLXwkZ6/z6ZdA723NIJtNPqsTqKR3u3UEuHG M56YtCBboPNYT+zD9YQAsC/yY8lUrkF2dl7fUjwoV/h7ACRpZ3KGFpKDdCJHOTkpf5co KeOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713872739; x=1714477539; 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=BX1/t0yrBDKFHwTVnk8h3M5ktB/7ytpEkd+yT5ZWUjI=; b=qT/J/BVMakR7/71aqWHgmvseyRwkKH4ghCOlq5Xq870FW4MQUKXTrj0AAPBc7G75ir 8MulFiHGIedI2gHs/5S240Wx5sXBb9ZjjAhtf/21nPAiJer5XAHLcD3EZBOGMLeDC6P9 q+zVmeETnP34F2ald2688k5cs08VtEh9F5H9jAmPXLtBWTs+Mm77AsV8GY5InEdKxRBH Ujg80XOgVCB732DBCM02PsbuUovXF3nFFh1XY1N7FUY+mDi9RXF/mji6eg+K6D20/X3O YpObWVwsQZeeijRsAnagqwhYqds/ii5GyZecgcSmoV2eIaTYxxC2jZGsp77nOKLnoHmT R/Ow== X-Gm-Message-State: AOJu0YxOza5EltRcWV3Lf69GBvBBo+icYiOIY40tkW5CheZQEClYNraY l6GoZh8PdemPx+tnaO1Aj2x/p4UZL1abUH9sZ0FRGxjOsP9fWbTNxI5qow== X-Google-Smtp-Source: AGHT+IHwZCuiXwdUSUiW5x0qbXFUy+FpnO29ujt4dQ4U6mHPNl6ib3l6j3DAcf978CQBeUI6uFxbxQ== X-Received: by 2002:a17:902:db09:b0:1ea:bc:53ac with SMTP id m9-20020a170902db0900b001ea00bc53acmr3084377plx.44.1713872739240; Tue, 23 Apr 2024 04:45:39 -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 d1-20020a170903230100b001dee4a22c2bsm9832311plh.34.2024.04.23.04.45.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 04:45:38 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id A16AF1142750; Tue, 23 Apr 2024 21:15:36 +0930 (ACST) Date: Tue, 23 Apr 2024 21:15:36 +0930 From: Alan Modra To: binutils@sourceware.org Subject: PR31667, objcopy/strip corrupts solaris binaries Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3033.5 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 List-Id: Using want_p_paddr_set_to_zero in commit 45d92439aebd was wrong. Even solaris targets don't have want_p_paddr_set_to_zero, but we should handle them at least somewhat reasonably. PR 31667 * elf.c (IS_SECTION_IN_INPUT_SEGMENT): Remove bed arg, add paddr_valid. Don't use bed->want_p_paddr_set_to_zero. (INCLUDE_SECTION_IN_SEGMENT): Likewise. (rewrite_elf_program_header): Adjust to suit. diff --git a/bfd/elf.c b/bfd/elf.c index 0f4907adc32..74236a658fd 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -7578,10 +7578,9 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd, bfd_vma maxpagesize) 7. SHF_TLS sections are only in PT_TLS or PT_LOAD segments. 8. PT_DYNAMIC should not contain empty sections at the beginning (with the possible exception of .dynamic). */ -#define IS_SECTION_IN_INPUT_SEGMENT(section, segment, bed, opb) \ +#define IS_SECTION_IN_INPUT_SEGMENT(section, segment, opb, paddr_valid) \ (((is_contained_by (section, segment, segment->p_paddr, \ - segment->p_vaddr, opb, \ - bed->want_p_paddr_set_to_zero) \ + segment->p_vaddr, opb, !paddr_valid) \ && (section->flags & SEC_ALLOC) != 0) \ || is_note (section, segment)) \ && segment->p_type != PT_GNU_STACK \ @@ -7600,8 +7599,8 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd, bfd_vma maxpagesize) /* If the output section of a section in the input segment is NULL, it is removed from the corresponding output segment. */ -#define INCLUDE_SECTION_IN_SEGMENT(section, segment, bed, opb) \ - (IS_SECTION_IN_INPUT_SEGMENT (section, segment, bed, opb) \ +#define INCLUDE_SECTION_IN_SEGMENT(section, segment, opb, paddr_valid) \ + (IS_SECTION_IN_INPUT_SEGMENT (section, segment, opb, paddr_valid) \ && section->output_section != NULL) /* Returns TRUE iff seg1 starts after the end of seg2. */ @@ -7746,7 +7745,7 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd, bfd_vma maxpagesize) { /* Find the first section in the input segment, which may be removed from the corresponding output segment. */ - if (IS_SECTION_IN_INPUT_SEGMENT (section, segment, bed, opb)) + if (IS_SECTION_IN_INPUT_SEGMENT (section, segment, opb, p_paddr_valid)) { if (first_section == NULL) first_section = section; @@ -7882,7 +7881,7 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd, bfd_vma maxpagesize) section != NULL; section = section->next) { - if (INCLUDE_SECTION_IN_SEGMENT (section, segment, bed, opb)) + if (INCLUDE_SECTION_IN_SEGMENT (section, segment, opb, p_paddr_valid)) { output_section = section->output_section; -- Alan Modra Australia Development Lab, IBM