From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id uVhNMyzsaGp0CzIAWB0awg (envelope-from ) for ; Tue, 28 Jul 2026 13:51:40 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=gJT+olaA; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id CD4CC1E09E; Tue, 28 Jul 2026 13:51:40 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 461191E099 for ; Tue, 28 Jul 2026 13:51:40 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D35BE4BB3BC1 for ; Tue, 28 Jul 2026 17:51:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D35BE4BB3BC1 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=gJT+olaA Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 0D86A4BB3B90 for ; Tue, 28 Jul 2026 17:51:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0D86A4BB3B90 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 0D86A4BB3B90 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785261075; cv=none; b=h+SUJDvxJwk60LkHfEW4J48Lvql/+l3FMhz862pu4BWyEP2lDBjytnUgRvh4XAag5ngCergGsu7awjgDXm/6RoPY0j3TI8Q+h12ayBF9JYA89R9VaU07P1T3J75YGbwROq8mIo8yLZqqBqT0Q+Qafo8PqEh51ELvjwqPGTxoDx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785261075; c=relaxed/simple; bh=0/e6TmJnNp97tB31P9k3mAHDTJBnosDSk/0d57K7lOc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=UikgXNLX+Bzi6aI5ZAmDCv9Qr2hcm48Lu8s84NVsm9HObzPrZav5vDs9BnlH5V5DGzbC6cCMjCfD/1aipzHB5+8i4seDcI7cOZ3gCcBR0FEmKuj+gM6/9NdmpJmx2HhP9LeZRBXRvSQV8CYrwuD/Nc8cRHMPzHzks3gnSE4hQB8= ARC-Authentication-Results: i=1; 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=gJT+olaA DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0D86A4BB3B90 Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66SEmPap1492463 for ; Tue, 28 Jul 2026 17:51:14 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=xgUbs4ceFT3v9+z364hkW993y6oprnHwcO728KRZw ag=; b=gJT+olaAaKhnpBtLwIoh6scE05gRAh0egLk9BAwGvgxD27j8Xd/MZulFO ELdP+2fAR8+ok8jBuG7XPLiw/iV9sYcV+YLi6INVSNqOuZS9A6w+KBTuEAUNqPFZ 2bTv/4q9XW0Srzf2gP/DdegdL3CzVzDSFMtuiOORoX2ogwcnHSPvyrx6QxFxpm/b 9VbitDMTHWe5iFM415JJrbT0KGlCaAIybZnbRCauQn7dJvsNOBNjUHan1vzqGflm EPWjQsH+vkQV1yTdu4mEqOhc54fLj19WpDLILm8HUJu3xnDRoxW7gIDht1TrDKvt zmLSjVuj5BsBAd+HeiM1i6EE53z5A== 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 4fmv0xprcr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 28 Jul 2026 17:51:13 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 66SHfPEL027258 for ; Tue, 28 Jul 2026 17:51:13 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4fna5y2uuc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 28 Jul 2026 17:51:12 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 66SHp46d30015972 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Jul 2026 17:51:04 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6A1A420043; Tue, 28 Jul 2026 17:51:04 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A8FD620040; Tue, 28 Jul 2026 17:51:03 +0000 (GMT) Received: from kubota.pok.stglabs.ibm.com (unknown [9.114.39.181]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 28 Jul 2026 17:51:03 +0000 (GMT) From: Abhay Kandpal To: gdb-patches@sourceware.org Cc: Ulrich.Weigand@de.ibm.com, cel@linux.ibm.com, abhay.k@ibm.com, Abhay Kandpal Subject: [PATCH v2] PowerPC: Fix compile command by reverting to default code model Date: Tue, 28 Jul 2026 12:50:53 -0500 Message-ID: <20260728175053.1875987-1-abhay@linux.ibm.com> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: pz3ZsXNCX4GIsQz73vv6ztvq-eht6eLv X-Proofpoint-ORIG-GUID: pz3ZsXNCX4GIsQz73vv6ztvq-eht6eLv X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI4MDE1NiBTYWx0ZWRfX5CNA2VqC5Eze /7P/3CPL3S/CUQ2cvL2i3xdIvH1hiFjtfOzhNrUcNzTjcgoQs1ZhNjVkq0G97Ih8hx46wHI/ooj JfsutN6JUF+iEhno7i1Q/aA8vHE5GZQ= X-Authority-Analysis: v=2.4 cv=dYuwG3Xe c=1 sm=1 tr=0 ts=6a68ec11 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=RAioF0-LDSMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=CCpqsmhAAAAA:8 a=9YnczZhIcSK_HdDo-k8A:9 a=ul9cdbp4aOFLsgKbc677:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI4MDE1NiBTYWx0ZWRfX/rDgy8hi1Mu4 gZ7nOtEwRNoUIhcbCPCv5iYAD8yXBJOS5NjFJJgzzL4ppJGrxAsgHfsi1iOqRJKkWirmOPRBjiG 2uFvnvHBehk50CYkiS6ja/19sHOAXY8QauVJsXmEHvPY7wqxgXdBANAHGW2MKVchyObVEjkBjmE JVgggcE5MIehyuXsrvHiCFnv6P57EbijTIyZybtPNvj8xQvWmIn2cg/yfftG252EoNAeoOvcGWu seX03ihG+rLHPGOK6YbBrtL2tJkT3PfYuPjD3jIXKFmol7jZotWuCk8ubAZalqNGVykg8URXjaQ LFnW/rJA4yX2VQXsKl3vszgg8EdDItLP3oI8ajPUtIG71UgmFNdhj8lhLb+VppB5zK4LV9C7Z0J UckzmWcQM6A2yNfX6PNQq7Sw7tk0kicYPd4idGsl+M5zXgE6WiPYi8ObP4No4WDXiZA4d+DdjGi hgIR1EFPbSvNY0OuU9g== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-28_04,2026-07-28_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 clxscore=1015 phishscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607280156 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On ppc64le, the "compile" command produces corrupted code when the compiled expression takes the address of a symbol in the inferior. For example: (gdb) break -qualified main (gdb) run (gdb) compile code pmf = &A::get_var1 (gdb) x/2gx &pmf 0x7fffffffeb68: 0x0000800010000d78 0x0000000000000000 The stored address is wrong: the low 32 bits are correct (0x10000d78, the true address of A::get_var1) but bit 47 is incorrectly set. When the compiled code later calls through such a pointer the inferior jumps to unmapped memory and receives SIGSEGV. Commit 533f04079c7 ("[gdb] [rs6000] Add ppc64_linux_gcc_target_options method.") made ppc64 return an empty string from gdbarch_gcc_target_options, overriding the "-m64 -mcmodel=large" that default_gcc_target_options supplies for 64-bit targets, so GCC uses -mcmodel=medium instead. With the medium model, references to the inferior's symbols are compiled as TOC-relative accesses using R_PPC64_TOC16_HA/LO relocations, whose combined displacement is a signed 32-bit value (+/- 2GB). GDB allocates the compiled module in the inferior with an mmap that the kernel places in the high mmap region (e.g. around 0x7ffff7f30000), while the inferior's own text is low (e.g. around 0x10000000). The distance between them is close to 2^47, far beyond the reach of a TOC16 relocation, so the displacement is silently truncated to 32 bits, producing an address that is off by 2^47. Revert 533f04079c7 so that ppc64 again uses default_gcc_target_options ("-m64 -mcmodel=large"). With the large model GCC emits a real .toc section and loads addresses as full 64-bit values from it, so the only TOC-relative references are into the module's own .toc, always in range wherever the module is mapped. The .TOC. handling from commit bad23de3543 ("[gdb] Handle .TOC. sections during gdb-compile for rs6000 target.") still applies, now resolving via the genuine .toc section rather than the .text fallback the medium model required. Tested on powerpc64le-linux (Fedora, GCC 15.2.1). Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34456 gdb/ * ppc-linux-tdep.c (ppc64_linux_gcc_target_options): Remove. (ppc_linux_init_abi): Don't set gcc_target_options. --- This patch is reg tested. gdb/ppc-linux-tdep.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index 1d54b72bb1d..8a55ff5d4af 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -2076,14 +2076,6 @@ ppc64_gnu_triplet_regexp (struct gdbarch *gdbarch) return "p(ower)?pc64"; /* codespell:ignore. */ } -/* Implement the linux_gcc_target_options method. */ - -static std::string -ppc64_linux_gcc_target_options (struct gdbarch *gdbarch) -{ - return ""; -} - /* Fetch and return the TLS DTV (dynamic thread vector) address for PTID. Throw a suitable TLS error if something goes wrong. */ @@ -2337,8 +2329,6 @@ ppc_linux_init_abi (struct gdbarch_info info, set_gdbarch_gnu_triplet_regexp (gdbarch, ppc64le_gnu_triplet_regexp); else set_gdbarch_gnu_triplet_regexp (gdbarch, ppc64_gnu_triplet_regexp); - /* Set GCC target options. */ - set_gdbarch_gcc_target_options (gdbarch, ppc64_linux_gcc_target_options); /* Internal thread local address support. */ set_gdbarch_get_thread_local_address (gdbarch, svr4_tls_get_thread_local_address); -- 2.52.0