From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 53B093858D28 for ; Mon, 6 Dec 2021 16:37:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 53B093858D28 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B6FiPlj036903; Mon, 6 Dec 2021 16:37:08 GMT Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com with ESMTP id 3cshxswxje-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Dec 2021 16:37:07 +0000 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1B6GHlLc031210; Mon, 6 Dec 2021 16:37:07 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma05wdc.us.ibm.com with ESMTP id 3cqyy9shav-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Dec 2021 16:37:07 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1B6Gb4QW19595892 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 6 Dec 2021 16:37:04 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 554E2AE063; Mon, 6 Dec 2021 16:37:04 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2F9D2AE060; Mon, 6 Dec 2021 16:37:03 +0000 (GMT) Received: from li-e362e14c-2378-11b2-a85c-87d605f3c641.ibm.com (unknown [9.211.124.5]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 6 Dec 2021 16:37:02 +0000 (GMT) Message-ID: <73426fba8d9ce1eb5fc60ae64a2ecd57074c510a.camel@us.ibm.com> Subject: Re: [PATCH ver3] gdb: Add PowerPC support to gdb.dwarf2/frame-inlined-in-outer-frame.exp From: Carl Love To: Simon Marchi , gdb-patches@sourceware.org, Ulrich Weigand Cc: Rogerio Alves , Will Schmidt , cel@us.ibm.com Date: Mon, 06 Dec 2021 08:37:02 -0800 In-Reply-To: <92b6daba-54d6-bb1f-4c99-10b3ec32d3ec@polymtl.ca> References: <61a8f3c2be6a60ff211ca02469bf3ce4554a36b1.camel@us.ibm.com> <92b6daba-54d6-bb1f-4c99-10b3ec32d3ec@polymtl.ca> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-16.el8) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 0EmJBTtmJZM5jY09Wa9eacJbusumIN3C X-Proofpoint-ORIG-GUID: 0EmJBTtmJZM5jY09Wa9eacJbusumIN3C X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-06_05,2021-12-06_02,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 mlxscore=0 phishscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112060101 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Dec 2021 16:37:27 -0000 Simon: On Fri, 2021-12-03 at 21:13 -0500, Simon Marchi wrote: > > > Format like this: > > #if defined (__powerpc64__) > # if _CALL_ELF == 2 > ... > # else > ... > # endif > #endif > > Put the assembly statements at column 0, as they would be without the > preprocessor conditionals. I made the requested changes, above, to the patch. > I guess I'll have to trust you because I know nothing about PowerPC > assembly but... this is all really necessary for such a simple > program? Per Will Schmidt's commnets Yes.. Details as I paraphrase them are that ElfV1 (Powerpc Big Endian) requires an opd (Official Procedure Descriptor) section that contains the function descriptors. So, the assembly here is defining the abiversion, and the .opd section (with required alignment), and adding an entry for the _start function in that section. This requirement was eliminated in the ELF V2 ABI, as seen in the simpler #ifdef branch above. Thanks -Will Yes unfortunately. I would also add to what Will said that we need tp explicitly specify which abi version ( directive .abiversion ) for the assembler to use. Otherwise it will assume version 1 by default. Please let me know if the patch is acceptable for mainline. Thanks. Carl --------------------------------------------------------------------- gdb: Add PowerPC support to gdb.dwarf2/frame-inlined-in-outer-frame This patch adds an #elif defined for PowerPC to setup the exit_0 macro. This patch addes the needed macro definitionald logic to handle both elfV1 and elfV2. The patch has been successfully tested on both PowerPC BE, Powerpc LE and X86_64 with no regressions. --- .../gdb.dwarf2/frame-inlined-in-outer-frame.S | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.S b/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.S index 9fb6e7b7164..09fe75d8132 100644 --- a/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.S +++ b/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.S @@ -65,6 +65,16 @@ swi 0x0 .endm +#elif defined __powerpc64__ + +# define RETURN_ADDRESS_REGNO 65 + +.macro exit_0 + li 0, __NR_exit /* r0 - contains system call number */ + li 3, 0 /* r3 - contains first argument for sys call */ + sc +.endm + #else # error "Unsupported architecture" #endif @@ -90,8 +100,28 @@ 16 } */ +#if defined __powerpc64__ +# if _CALL_ELF == 2 +.abiversion 2 /* Tell gdb what ELF version to use. */ +.global _start +_start: +# else +.abiversion 1 /* Tell gdb what ELF version to use. */ +.align 2 +.global _start +.section ".opd", "aw" +.align 3 +_start: +.quad ._start,.TOC.@tocbase,0 +.previous +.type ._start,@function +._start: +# endif +#else .global _start _start: +#endif + .cfi_startproc /* State that the return address for this frame is undefined. */ -- 2.30.2