Message ID | 20250312163640.218942-1-jremus@linux.ibm.com |
---|---|
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 D2E3E3858414 for <patchwork@sourceware.org>; Wed, 12 Mar 2025 16:37:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D2E3E3858414 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=hcNAwIMw X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 332333858C5F for <binutils@sourceware.org>; Wed, 12 Mar 2025 16:36:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 332333858C5F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 332333858C5F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741797411; cv=none; b=Wfi4sMDw2l2uXafYy9WiN1wcKTdr7/8IuQy+x+Pt1uoi97tNHoUwzmU6+/hSkwYn+bepEcb/sSYaRDOe5MG1iXvYlAb1c4dysIGxiXc/JKeUXWPqym1cr/DncqSS5QhmolLRbKlYoFzjK7ILs/q77WGXTN0Q1ecYeaqAGxTuiKg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741797411; c=relaxed/simple; bh=vlSaL5j5AobCrSJ1dIBKgcmIkLJcsf8jIr89zj/0N88=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=tHljolR/6Wwywl9QDK9ZoM7xDBCZjpRoR6Cj2e1Y9a5NOcVLXFXzBGGGufSJUMDa7Kmu+E9+aI8B2mgoxPlRkhaO3X0AMD9mRv0HaDmgP8mzXc4Jn993j6hsQ/KIvnKNUcQMebqR0I5vINMs3EeQ8s1e+GCpoKAHkjajQK3KAZU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 332333858C5F Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 52CE3dqD023479; Wed, 12 Mar 2025 16:36:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=8O3Xzzbl+jkIdsSeU id1OLTRWnUGmHgH5OVDkE5pyBs=; b=hcNAwIMw3D4dzIISIlbIHYzG0PgZThW+l B5DU1Y18rd07ZMxtLafzpRJD9UraOHEICEZLriHlHOS9qXrt9EkzuDVSZyC/EBl3 7/r9SkEBIp85Tu3mTkVoa2viYDOeyAXIUHfJCnc9b9zy2JS+ejo6Dvhd9/NLrT/D IlIl1MoQMZ8E5LsdUnFC8qkCDXZPwUKG9gYB14mK3SXlH8ED8uvsjyCxLqkWr4jQ qjQHLgzQ4FEJaf+gP94R2kDWo0oUYsdZsHWef4okTlg2t3aumIJ4TzftsoQxq/fq ozOz7qiyWfYd0LVPHPAupbUmtgCQ2pkVgIayPNHrJrLw1zLVp9oJw== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 45bbpprthr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Mar 2025 16:36:47 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 52CE0MTn003076; Wed, 12 Mar 2025 16:36:46 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 45atstn2j3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 12 Mar 2025 16:36:46 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 52CGahw451577270 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Mar 2025 16:36:43 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 594BD2004B; Wed, 12 Mar 2025 16:36:43 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2CD6520043; Wed, 12 Mar 2025 16:36:43 +0000 (GMT) Received: from tuxmaker.lnxne.boe (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 12 Mar 2025 16:36:43 +0000 (GMT) From: Jens Remus <jremus@linux.ibm.com> To: binutils@sourceware.org, Indu Bhagat <indu.bhagat@oracle.com> Cc: Jens Remus <jremus@linux.ibm.com>, Andreas Krebbel <krebbel@linux.ibm.com> Subject: [RFC PATCH] ld: bfd: sframe: Update section size also for relocatable links Date: Wed, 12 Mar 2025 17:36:40 +0100 Message-ID: <20250312163640.218942-1-jremus@linux.ibm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250308073853.78738-1-indu.bhagat@oracle.com> References: <20250308073853.78738-1-indu.bhagat@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: DokSEl0Zx3Ahn5B5W_ym54cC8L4LQ-Oa X-Proofpoint-GUID: DokSEl0Zx3Ahn5B5W_ym54cC8L4LQ-Oa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1093,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-03-12_05,2025-03-11_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2502280000 definitions=main-2503120113 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 |
[RFC] ld: bfd: sframe: Update section size also for relocatable links
|
|
Checks
Context | Check | Description |
---|---|---|
linaro-tcwg-bot/tcwg_binutils_build--master-arm | warning | Skipped upon request |
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 | warning | Skipped upon request |
Commit Message
Jens Remus
March 12, 2025, 4:36 p.m. UTC
For relocatable links the output .sframe section size may be wrong.
This can be observed when dumping the SFrame information from the x86-64
sframe-reloc-1 test:
Name Address Off Size
.sframe 0000000000000000 000110 00007f
Offset Type Symbol's Value Symbol's Name + Addend
000000000000001c R_X86_64_PC32 0000000000000000 .text + 1c
0000000000000030 R_X86_64_PC32 0000000000000000 .text + 65
0x00000000 e2de0201 0300f800 02000000 08000000 ................
0x00000010 1e000000 00000000 28000000 00000000 ........(.......
0x00000020 35000000 00000000 04000000 00000000 5...............
0x00000030 00000000 25000000 0f000000 04000000 ....%...........
offset 1st FRE---^^^^^^^^ ^^^^^^^^---number of FREs
0x00000040 00000000 00030801 0510f004 0410f034 ...............4
FDE info---^^ | begin of FDEs
0x00000050 0508f000 03080105 10f00404 10f02405 ..............$.
11111112222222223333333334444---FRE 1, 2, 3, 4
0x00000060 08f00000 00000000 00000000 00000000 ................
4444^^^^...
0x00000070 00000000 00000000 00000000 000000 ...............
...^^^^^^---excessive section
When running the x86-64 test cross build on a big-endian system, such
as s390x, objdump and readelf fail to dump the SFrame information with
the following error message:
Error: SFrame decode failure: Buffer does not contain SFrame data.
This is because the following check in flip_sframe() fails, which gets
only invoked if the endianness of the SFrame data is different from the
host system one:
/* All FDEs and FREs must have been endian flipped by now. */
if ((j != ihp->sfh_num_fres) || (bytes_flipped != (buf_size - hdrsz)))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
With:
j=8, ihp->sfh_num_fres=8, bytes_flipped=70, buf_size=127, hdrsz=28
bfd/
* elf-sframe.c (_bfd_elf_write_section_sframe): Update section
size also for relocatable links.
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
---
Notes (jremus):
Hello Indu,
I ran into this while crafting a sample that shows the issue I see with
FDE sorting in relocatable links with multiple text sections. Please
consider to add to or merge with your "[RFC 0/4] Fix relocatable links
with SFrame section" series.
Maybe it would make sense to add a check that would catch this when
sframe_flip() is not invoked?
Thanks and regards,
Jens
bfd/elf-sframe.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/bfd/elf-sframe.c b/bfd/elf-sframe.c index e0bc7cf2a433..4fb6c3eb4624 100644 --- a/bfd/elf-sframe.c +++ b/bfd/elf-sframe.c @@ -636,13 +636,11 @@ _bfd_elf_write_section_sframe (bfd *abfd, struct bfd_link_info *info) (file_ptr) sec->output_offset, sec->size)) retval = false; - else if (!bfd_link_relocatable (info)) + else { Elf_Internal_Shdr *hdr = &elf_section_data (sec)->this_hdr; hdr->sh_size = sec->size; } - /* For relocatable links, do not update the section size as the section - contents have not been relocated. */ sframe_encoder_free (&sfe_ctx);