From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 307273858D37 for ; Thu, 2 Nov 2023 16:31:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 307273858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 307273858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698942674; cv=none; b=esfYEd/GoMqtSkw00DCh0/yGkeo4wRsii/JZxRJJ8slkT7oB/YBqtte98NIbDRuEnhmajNRRMWQlQGsuz/lv5RKuXOcz0CWIE0g0pRb4umDEetJmNJypzRcuy5Mw0AahV8sQL/pJE8zDTe1QUgzQoeOIB8pHKWxwL9UfT1BcNFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698942674; c=relaxed/simple; bh=hgIU0hULZqWsCl2SkLdbmhhDHF7ita5csRZJiavywCk=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=xXRjxAZak0cxYYXPjQ2YgdxbnPsz4IMypyA6lWRjMFVoKJgkYpOD2vTajuruc9TegP0rld5eit4L27GJU3wPX/3eTay/U8oCLLiE9PPT1C4b3BmOMd8ipO5hpc/AGyISWzO/Kkau/qrtaeDMvIyGibxCDtdtjGkd6Wsjf1nQXww= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698942663; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2fv9MkkLpWbomTj+cmOUQoRA8Lfhq9GkUG61q+NiMt8=; b=crBZTnNs4ObkVOZWMkESjxjBgsKRgj+MDOn3rzw2ZwcKFvgXySjy5bXs8eA1Wsoz83Vx7R qUAaQLGN7JV9a5MFkm4behjgNcICnd+rBaBJQQyn/CBB1wotRUiiBczzV5X8xcFMlLrWT6 CmeyhcDzNo7gcHmlBMv75dSQXDbd8Kk= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-662-5HM__-zhMRSxg4KnrAnl0g-1; Thu, 02 Nov 2023 12:31:02 -0400 X-MC-Unique: 5HM__-zhMRSxg4KnrAnl0g-1 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-2802c0b610dso1118728a91.1 for ; Thu, 02 Nov 2023 09:31:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698942661; x=1699547461; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2fv9MkkLpWbomTj+cmOUQoRA8Lfhq9GkUG61q+NiMt8=; b=psPLSZ02CT5/eu8/k69A+7/1S9oZSOmqsJg9NG/4Nl3QcXCAO0S1snWoKZSI11nCLL sfr/iBj/FUZE3ensvompGgFOvbFQ9sRuQVFztUwFQhr+PqHxFQPVkQ15W40z7x4mLko/ GJ3annhO5wZuC9oJH/db4jDxmPqofIGJyGZ54rX9jRTTqg1F/OeJR/NCGSgGfpLF9mH5 XMFB037hnZEOLvR7edi84VG4qmXKgVoVVOswEqjJb6kQBK803V+wVTP8HC3w+4iEKXuO IQ5K42lgwCB+W3R2QVBVOcsrGZTTp/u/+3gqvdd3sNOAKhKnSKLjisp6DGyvMyAt/r17 lODg== X-Gm-Message-State: AOJu0YzwAHZ6PtOT2u9/fYtZTTdRiLUpPyQBzrJuNM7Wh1JAGkPvxWWq 6R+mahvjvlmeSFDbIM86nfIyK5Hj60jZGT/EXTwZWKLexAsGacIt0vatZZIjqsAjst/rtU0BiLn M48DlxTeTsnJQeJqcG6s5gJOZ/lUsexHFa/SiqE3dJoz106t4/eU= X-Received: by 2002:a17:90a:2f47:b0:280:3f33:64d8 with SMTP id s65-20020a17090a2f4700b002803f3364d8mr13010606pjd.21.1698942661455; Thu, 02 Nov 2023 09:31:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBK7SvOjWAdwPWXrLhvRIiDk2PVPJXc5eboaNBgAXgTY4jYlwVhw6H3Ij629LZaV3yxgVdQJBqw428XuemVEw= X-Received: by 2002:a17:90a:2f47:b0:280:3f33:64d8 with SMTP id s65-20020a17090a2f4700b002803f3364d8mr13010584pjd.21.1698942661090; Thu, 02 Nov 2023 09:31:01 -0700 (PDT) MIME-Version: 1.0 References: <20231031203312.536219-1-amerey@redhat.com> <9a13a2cee1bff48ae7121515ccef4bcd5b047601.camel@klomp.org> In-Reply-To: <9a13a2cee1bff48ae7121515ccef4bcd5b047601.camel@klomp.org> From: Aaron Merey Date: Thu, 2 Nov 2023 12:30:50 -0400 Message-ID: Subject: Re: [PATCH] readelf: Support .gdb_index version 9 To: Mark Wielaard Cc: Frank Eigler , elfutils-devel@sourceware.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Nov 2, 2023 at 10:20=E2=80=AFAM Frank Ch. Eigler = wrote: > > > BTW the description of the gdb_index at the top > > https://sourceware.org/gdb/current/onlinedocs/gdb/Index-Section-Format.= html > > doesn't resolve anymore. It is now > > https://sourceware.org/gdb/current/onlinedocs/gdb.html/Index-Section-Fo= rmat.html > > Added another httpd redirect to make the first link work too. Thanks Frank. On Thu, Nov 2, 2023 at 8:54=E2=80=AFAM Mark Wielaard wrote= : > > > + printf (_("\nShortcut table at offset %#" PRIx32 " contains %zu slot= s:\n"), > > + shortcut_off, shortcut_nr); > > That is a fancy way to print "contains 2 slots" :) My intention was to require fewer changes to the code if the shortcut table was extended in a future version. But yes at the moment this is slightly excessive! > > > + uint32_t lang =3D read_4ubyte_unaligned (dbg, readp); > > + readp +=3D 4; > > + > > + printf (_("Language of main: %s\n"), dwarf_lang_name (lang)); > > Note that dwarf_lang_name calls string_or_unknown with false for > print_unknown_num so it might make sense to either flip that to true > (but there is probably a reason it doesn't print the hex num) or to > always add the hex num after the name so the user doesn't just get ??? > on an unknown DWARF_LANG constant. Binutils readelf includes the language hex number for unknown languages and we should too. I will add the hex number to the output when the language is unknown. > > > + printf (_("Name of main: ")); > > + > > + if (lang !=3D 0) > > + { > > + uint32_t name =3D read_4ubyte_unaligned (dbg, readp); > > + readp +=3D 4; > > + const unsigned char *sym =3D const_start + name; > > + > > + if (unlikely ((size_t) (dataend - const_start) < name > > + || memchr (sym, '\0', dataend - sym) =3D=3D NULL)) > > + goto invalid_data; > > Good end of string check. > BTW. DW_LANG constants are going away with DWARF6: > https://dwarfstd.org/languages-v6.html Interesting. If gdb continues to support .gdb_index then we may end up extending the shortcut table to include the new DW_AT_language_version. > > +Shortcut table at offset 0x207c contains 2 slots: > > +Language of main: ??? > > +Name of main: > > +EOF > > This seems an unfortunate example. Why is the language unknown? > But maybe it is a nice example to show why you should at least print > the hex num of the language? Currently gdb only populates the shortcut table when it can find DW_AT_main_subprogram or DW_AT_calling_convention with value DW_CC_program. gcc doesn't emit this for C/C++ programs so their shortcut tables all have language and name set to 0. See https://sourceware.org/bugzilla/show_bug.cgi?id=3D30996 I will change this testcase to include the hex number of the language. Aaron