From patchwork Wed Oct 23 15:10:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dani Szebenyi X-Patchwork-Id: 99442 Return-Path: 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 32B313858C62 for ; Wed, 23 Oct 2024 15:12:07 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 26F6D3858D21 for ; Wed, 23 Oct 2024 15:11:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 26F6D3858D21 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 26F6D3858D21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729696301; cv=none; b=tXOOIvJPv20Yl21S8fst3Cz142q2w3MIZJCxZHFeXe0dI2m7khbjorMVBwBxuppQx3yJwUdhxKd93yzzuJFGcEF00QP2QX3ybCJc7ZwG/6F3H8d2tt7WotSJTqqCO84FvPcREpGWuEViqI8/T4YKMuFXlWhH+4GHh+TmG2HguNE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729696301; c=relaxed/simple; bh=FV+YYSk+qEdLknu8UQmff68ht0fHBKgHt2JNICcy0DU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=uEWN2db8c+uf8SqqxaVnBtIOOReTUlctNtAylbcZkC2RPd33PoGJ7MQwI56rkYHo30P1xXkoNfLRtJTqy8sYJivz29IQIC2MBKm2ADHRqH1vM0fe/0GyWrhL2/SwmefEbV7SwkC5u7zBCBA5tXgzw7kAINRtjNCAbgvK8KiBENM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49NCbgEP016712; Wed, 23 Oct 2024 15:11:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=pp1; bh=F8Mp5776HlTtKFc0avypAzGwbS3VTRx8rsnw/VuRJ TQ=; b=U70nHH71/sOnpBhK1qWoRfdOvZl523i73v1c94COZCTDROHvfktcN6jO7 u9uY7Vgb7fRED1CWd0ROfGEC4xMEPs22RoEBZ+xLfrQjp2m2oOGRYA9C99uvnbIx PNPMJsXIjHq8U5bVDa37sLhLZy6I2l2nASwklCh8E3ho3H368qdpjzTFfFh846nL hqjKs7OZqln8ErEIjziG+3VIB+UG1iAF4E1pCgHZdPFwwNfRqfv//bK+YAJKNDaD 6vreEi9KSfkLm0pPmbZJFBAl/MTchoaCXJcJU795RCpTtJarEQZXmmRTP9BS/W9w iQzMfq324njBDJE7j4f3rRmf2q08A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42emajkn66-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Oct 2024 15:11:36 +0000 (GMT) Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 49NFBPsZ005266; Wed, 23 Oct 2024 15:11:36 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42emajkn64-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Oct 2024 15:11:36 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 49NBWDRw001521; Wed, 23 Oct 2024 15:11:35 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 42emk9bdhf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Oct 2024 15:11:35 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49NFBVx916122346 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 23 Oct 2024 15:11:32 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CDD7E2004E; Wed, 23 Oct 2024 15:11:31 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F3E3720040; Wed, 23 Oct 2024 15:11:30 +0000 (GMT) Received: from li-68760b29-fd7c-4017-a34c-fc5cee828441.boeblingen.de.ibm.com (unknown [9.152.244.216]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 23 Oct 2024 15:11:30 +0000 (GMT) From: Dani Szebenyi To: binutils@sourceware.org, nickc@redhat.com, amodra@gmail.com Cc: jremus@linux.ibm.com, Dani Szebenyi Subject: [PATCH] Fix writing object contents above 4GB in tekhex format Date: Wed, 23 Oct 2024 17:10:50 +0200 Message-ID: <20241023151112.112480-1-szedani@linux.ibm.com> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 6egxnbo_rHnPutya8S8S7AGo8vLDdi4M X-Proofpoint-GUID: VgvTxpSyU4rjO68S9vsUIoUiVtzVxhV9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 malwarescore=0 mlxscore=0 phishscore=0 priorityscore=1501 suspectscore=0 impostorscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410230091 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org Writing tekhex object with addresses above 4GB resulted in a corrupted object contents, because the upper 32-bit of the address were silently ignored in `writevalue`. While reading a 64-bit address section did work in tekhex format, with the address length encoded as 0. This code adds the neccesary support for writing the upper bits of the address, while not changing the existing behavior for addresses below 4GB. Signed-off-by: Dani Szebenyi --- bfd/tekhex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bfd/tekhex.c b/bfd/tekhex.c index 96022c585ab..46f40b19817 100644 --- a/bfd/tekhex.c +++ b/bfd/tekhex.c @@ -719,11 +719,11 @@ writevalue (char **dst, bfd_vma value) int len; int shift; - for (len = 8, shift = 28; shift; shift -= 4, len--) + for (len = 16, shift = 60; shift; shift -= 4, len--) { if ((value >> shift) & 0xf) { - *p++ = len + '0'; + *p++ = digs[len & 0xf]; while (len) { *p++ = digs[(value >> shift) & 0xf];