From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id D25F63939C23 for ; Tue, 22 Jun 2021 18:55:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D25F63939C23 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15MIiNbO009313 for ; Tue, 22 Jun 2021 14:55:04 -0400 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0b-001b2d01.pphosted.com with ESMTP id 39bm9naep9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 22 Jun 2021 14:55:04 -0400 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 15MIqitt011537 for ; Tue, 22 Jun 2021 18:55:03 GMT Received: from b03cxnp07027.gho.boulder.ibm.com (b03cxnp07027.gho.boulder.ibm.com [9.17.130.14]) by ppma04dal.us.ibm.com with ESMTP id 39bds1mes9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 22 Jun 2021 18:55:03 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp07027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 15MIt02S20119814 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Jun 2021 18:55:00 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0AD0A6A04D; Tue, 22 Jun 2021 18:55:00 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 839BE6A05D; Tue, 22 Jun 2021 18:54:58 +0000 (GMT) Received: from lexx (unknown [9.171.93.118]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 22 Jun 2021 18:54:58 +0000 (GMT) Message-ID: <606184731c3ea9b484a098f393ffd1efd8190fe2.camel@vnet.ibm.com> Subject: gdb compile for powerpc64 target - Could not find symbol ".TOC." From: will schmidt To: Ulrich Weigand , "gdb-patches@sourceware.org" Cc: rogerio , "Carl E. Love" Date: Tue, 22 Jun 2021 13:54:56 -0500 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-10.el7) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 5Tgu8D3GeI-bAMixk7Jamf2Zl-n0knYU X-Proofpoint-ORIG-GUID: 5Tgu8D3GeI-bAMixk7Jamf2Zl-n0knYU X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-22_11:2021-06-22, 2021-06-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=619 clxscore=1015 malwarescore=0 phishscore=0 spamscore=0 bulkscore=0 impostorscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106220113 X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Tue, 22 Jun 2021 18:55:06 -0000 Hi, I've been looking at the gdb-compile tests on a powerpc64le target. In particular the testsuite/gdb.compile/compile-print.exp test. I've locally made a change to set a ppc64le_gnu_triplet_regexp value of "powerpc64le?" to allow gdb to actually find the compiler and libcc1 for this platform. With this change the simplest tests are successful, i.e. gdb_test "compile print main" gdb_test "compile print/x 256" However, anything more complex will fail. i.e. gdb_test "compile print varint" During gdb/compile/compile-object-load.c: compile-object-load() the following is emitted: warning: Could not find symbol ".TOC." for compiled module "/tmp/gdbobj-wIKWtk/out15.o". My best guess is that we need to incorporate some amount of special handling for the TOC entry to help find the symbols we are after. But.. I havn't stumbled across anything similar for other targets, and I havn't yet gleamed enlightenment looking at the existing code in compile-object-load. :-) As a hack I have tried treating the TOC symbol like we do the GOT entry, those attempts will later crash as we will trip over a zero dereference when trying to get at the symbol to print it. With "set debug compile" enabled, a few bits of possibly relevant info.. COLLECT_GCC_OPTIONS='-m64' '-mcmodel=large' '-A' 'system=linux' '-A' 'system=unix' '-A' 'system=posix' '-msecure-plt' '-mcpu=power8' '-g' '-fstack-protector-strong' '-std=gnu11' '-fno-exceptions' '-Wno-implicit-function-declaration' '-O0' '-gdwarf-4' '-fPIE' '-Wall' '-Wno-unused-but-set-variable' '-Wno-unused-variable' '-fno-stack-protector' '-fplugin=libcc1plugin' '-fplugin-arg-libcc1plugin-fd=14' '-c' '-o' '/tmp/gdbobj-wIKWtk/out18.o' '-v' The compiled code (objdump -d out*.o) looks like so: 0000000000000008 <_gdb_expr>: 8: f8 ff 4c e8 ld r2,-8(r12) c: 14 62 42 7c add r2,r2,r12 10: f8 ff e1 fb std r31,-8(r1) 14: b1 ff 21 f8 stdu r1,-80(r1) 18: 78 0b 3f 7c mr r31,r1 1c: 30 00 7f f8 std r3,48(r31) 20: 38 00 9f f8 std r4,56(r31) 24: 00 00 22 3d addis r9,r2,0 28: 00 00 29 e9 ld r9,0(r9) 2c: 02 00 29 e9 lwa r9,0(r9) 30: 20 00 3f 91 stw r9,32(r31) 34: 20 00 5f 81 lwz r10,32(r31) 38: 38 00 3f e9 ld r9,56(r31) 3c: 00 00 49 91 stw r10,0(r9) 40: 00 00 00 60 nop 44: 50 00 3f 38 addi r1,r31,80 48: f8 ff e1 eb ld r31,-8(r1) 4c: 20 00 80 4e blr ... I do see the iteration of symbols in compile-object-load(), these appear to match the (readelf) section header names as indexed by the (readelf) .symtab table entries. ala: ... ELF symbol "out18.c" flags [4005] ELF symbol ".text" flags [1000105] ELF symbol ".toc" flags [1000105] ELF symbol ".debug_info" flags [1000105] ELF symbol ".debug_abbrev" flags [1000105] ELF symbol ".debug_line" flags [1000105] ELF symbol ".debug_str" flags [1000105] ELF symbol ".debug_frame" flags [1000105] ELF symbol "_gdb_expr" flags [a] ELF symbol ".TOC." flags [0] Per "readelf -a" against the generated .o file, i can see: Symbol table '.symtab' contains 11 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS out5.c 2: 0000000000000000 0 SECTION LOCAL DEFAULT 1 3: 0000000000000000 0 SECTION LOCAL DEFAULT 5 4: 0000000000000000 0 SECTION LOCAL DEFAULT 6 5: 0000000000000000 0 SECTION LOCAL DEFAULT 8 6: 0000000000000000 0 SECTION LOCAL DEFAULT 11 7: 0000000000000000 0 SECTION LOCAL DEFAULT 13 8: 0000000000000000 0 SECTION LOCAL DEFAULT 16 9: 0000000000000008 84 FUNC GLOBAL DEFAULT [: 8] 1 _gdb_expr 10: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND .TOC. Relocation section '.rela.text' at offset 0x6a8 contains 4 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000000000 000a0000002c R_PPC64_REL64 0000000000000000 .TOC. - 8 000000000008 000000000076 R_PPC64_ENTRY 0 000000000024 000300000032 R_PPC64_TOC16_HA 0000000000000000 .toc + 0 000000000028 000300000040 R_PPC64_TOC16_LO_ 0000000000000000 .toc + 0 Any hints or advice on how to chase this further are welcomed. Thanks -Will