| Message ID | 20260728064909.1080844-1-abhay@linux.ibm.com |
|---|---|
| State | New |
| Headers |
Return-Path: <gdb-patches-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 398DF4BB24E3 for <patchwork@sourceware.org>; Tue, 28 Jul 2026 06:49:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 398DF4BB24E3 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=S5Ihc4rb X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 8CCC94BA798E for <gdb-patches@sourceware.org>; Tue, 28 Jul 2026 06:49:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8CCC94BA798E 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 8CCC94BA798E 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=1785221369; cv=none; b=lHUUQPF1V35ArZQOu3zrCwzh1FWdp6CJcqsgN/0zez8GWMmehr0YE/KRZUFtricEjHZyBrF9fxRZqK9qIoAa7pR92cwuWm+JwR2VVHrQBXMI2fWCkjnAbqEJChk7S/tJu+RfGImTdsgYYEkqLdZoXjOZzqE66TRNmerucXpOU8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785221369; c=relaxed/simple; bh=zMM6EdNseNP5bXU1YxFnoydM4SwavKk7CstZIqXoUiw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=CpPodRj0E3JQx2jjDxlqKqItBrtAq4E07VlOly+9vRdIKAgeahfpqhjCxS8DiRLPRPyjANtorgUjGJKNQnX9yZbm12qu7f4uRWL2gJqbmGihkA7rXFXgSBH2qSzOqV5n67mVEOfZaRcGzwlKQsw63tsBd801KA7kg0UmRNwCL7U= 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=S5Ihc4rb DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8CCC94BA798E 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 66S3lWSD4140082 for <gdb-patches@sourceware.org>; Tue, 28 Jul 2026 06:49:28 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=swrmj/OnKINKv9yb86jO6oeGNlJV8yDHnFFlJ2NcY qA=; b=S5Ihc4rbtPbtfXDb3AmGqKXMd+/VN9Ekv42i0EakYPm1pF1xN9T/UcEM+ 8pxHMXg0IsSEVNEqhixNTx32KFJox12JVPhLPgcb04W/67fxNxEiTycZe/xMHe0+ 1M0Xchma7zQZQ/72oycgCaWAiwUYFnWgGJtgk15QpkvElwr8RWnj4R4zlLDzHFYb PTAfI0fbhSnjJx0BMGMrCnMoUIYR7s4XecJICTTqeMXRbcz1I5NrqGSqDuoQqksY hIA7Vb03wiGgnzbq7YrrM4kcs6pE6PEj1yDFVEDDIJ2AyRPYoii8selbFn5bh7xp 4geJyBWi6U7MzEWqcnO1sIkypUETw== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4fmv0xkvpj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for <gdb-patches@sourceware.org>; Tue, 28 Jul 2026 06:49:28 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 66S6fNl4031698 for <gdb-patches@sourceware.org>; Tue, 28 Jul 2026 06:49:27 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4fn7uw0spy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for <gdb-patches@sourceware.org>; Tue, 28 Jul 2026 06:49:27 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 66S6nJs149873200 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Jul 2026 06:49:19 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 277DE200B0; Tue, 28 Jul 2026 06:49:19 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6787A200AE; Tue, 28 Jul 2026 06:49:18 +0000 (GMT) Received: from kubota.pok.stglabs.ibm.com (unknown [9.114.39.181]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 28 Jul 2026 06:49:18 +0000 (GMT) From: Abhay Kandpal <abhay@linux.ibm.com> To: gdb-patches@sourceware.org Cc: Ulrich.Weigand@de.ibm.com, cel@linux.ibm.com, abhay.k@ibm.com, Abhay Kandpal <abhay@linux.ibm.com> Subject: [PATCH v1] PowerPC: Use -mcmodel=large for the compile command Date: Tue, 28 Jul 2026 01:49:09 -0500 Message-ID: <20260728064909.1080844-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: c2fy10oUwA2--ijGHoMhauhi0IEUxg60 X-Proofpoint-ORIG-GUID: c2fy10oUwA2--ijGHoMhauhi0IEUxg60 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzI4MDA2MCBTYWx0ZWRfX6SQjZprIXenH 1ikfp8+yyQi5AtS83lvgEwnCVhEIwV1/n2Olfofbq5IHitl/5k2srv+AzM4YxwhBEviThMC26W5 o1mkuLqHzk3nwjo5l5g51qmNOd5U2io= X-Authority-Analysis: v=2.4 cv=dYuwG3Xe c=1 sm=1 tr=0 ts=6a6850f8 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=RAioF0-LDSMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=CCpqsmhAAAAA:8 a=wTrnE5GWe4l1GwSljxMA:9 a=ul9cdbp4aOFLsgKbc677:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzI4MDA2MCBTYWx0ZWRfX50mfX7QcpjE1 AtWg97sD99yLKFNi9C/NgwGTpAuGeikg8znAtq+OhQofyzLE9LrhHn0W86idPYwot0LGyKI51j+ RGDUNANdWv23eFWh0+LfBCgkys3LDf0vVJmLQjDobcQ/oEdreImEg3AMjr6qSXQlioS4uPpdKkm wPG+Tmtct+9H0O9Aguzb32IADOaCQ6dp8smg1ddAJ65PEU1NJKC68gC5vbHTW5Wk2YmHwJfET4e MceHepuYJxHGJirzfWlrRwzkAPZTgVRzdTx/VpKzAuMF0uURpAx9nVvuuu/sv9sy+x7s7AvG0uV fUUv4j6l0HkXYDWbf0KTZKkNPBAR1g3nllaY0bCpcx446y8BUAoWMXpiAv5C0+D6F99gO/snM4D rls6hsmwBZhBZlKgerutk71leCxOkN96y498EZETn+bsbihJl8o0Wyvz6+CO2ss8jO+YwJAfuEL 0TGIyDeHryJ2fRMnvaA== 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_01,2026-07-27_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 clxscore=1011 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-2607280060 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_PBL, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
[v1] PowerPC: Use -mcmodel=large for the compile command
|
|
Checks
| Context | Check | Description |
|---|---|---|
| linaro-tcwg-bot/tcwg_gdb_build--master-arm | success | Build passed |
| linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 | success | Build passed |
| linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 | fail | Patch failed to apply |
| linaro-tcwg-bot/tcwg_gdb_check--master-arm | fail | Patch failed to apply |
Commit Message
Abhay Kandpal
July 28, 2026, 6:49 a.m. UTC
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.
The cause is the code model used to compile the injected object.
Commit 533f04079c7 ("[gdb] [rs6000] Add
ppc64_linux_gcc_target_options method.") made ppc64 return an empty
string from gdbarch_gcc_target_options, overriding the
"-mcmodel=large" that default_gcc_target_options supplies for 64-bit
targets, so GCC falls back to -mcmodel=medium.
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.
Restore -mcmodel=large for ppc64. With the large model GCC emits a
real .toc section and loads symbol addresses as full 64-bit values
from it, so the only TOC-relative references are into the module's
own .toc, which is always in range regardless of where the module is
mapped. The .TOC. handling added by commit bad23de3543 ("[gdb]
Handle .TOC. sections during gdb-compile for rs6000 target.")
continues to work; it now resolves via the module's genuine .toc
section rather than the .text fallback that 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): Return
"-mcmodel=large".
---
This patch is reg tested.
gdb/ppc-linux-tdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Abhay Kandpal <abhay@linux.ibm.com> wrote: >The cause is the code model used to compile the injected object. >Commit 533f04079c7 ("[gdb] [rs6000] Add >ppc64_linux_gcc_target_options method.") made ppc64 return an empty >string from gdbarch_gcc_target_options, overriding the >"-mcmodel=large" that default_gcc_target_options supplies for 64-bit >targets, so GCC falls back to -mcmodel=medium. I can see why large model is more appropriate for this type of compilation. However, your patch just reverts the effect of the above commit, without actually reverting it. (This causes ppc64_linux_gcc_target_options to pretty much duplicate default_gcc_target_options.) I think it would be preferable to fully revert the commit instead. Bye, Ulrich
Thanks Ulrich — v2 fully reverts 533f04079c7 as you suggested, so ppc64 uses default_gcc_target_options. BR, Abhay On 28/07/26 15:54, Ulrich Weigand wrote: > Abhay Kandpal<abhay@linux.ibm.com> wrote: > >> The cause is the code model used to compile the injected object. >> Commit 533f04079c7 ("[gdb] [rs6000] Add >> ppc64_linux_gcc_target_options method.") made ppc64 return an empty >> string from gdbarch_gcc_target_options, overriding the >> "-mcmodel=large" that default_gcc_target_options supplies for 64-bit >> targets, so GCC falls back to -mcmodel=medium. > I can see why large model is more appropriate for this type > of compilation. However, your patch just reverts the effect > of the above commit, without actually reverting it. (This > causes ppc64_linux_gcc_target_options to pretty much duplicate > default_gcc_target_options.) I think it would be preferable > to fully revert the commit instead. > > Bye, > Ulrich
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index 1d54b72bb1d..67f31e7b308 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -2081,7 +2081,7 @@ ppc64_gnu_triplet_regexp (struct gdbarch *gdbarch) static std::string ppc64_linux_gcc_target_options (struct gdbarch *gdbarch) { - return ""; + return "-mcmodel=large"; } /* Fetch and return the TLS DTV (dynamic thread vector) address for PTID.