From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2103) id A8F743849AE9; Fri, 19 Apr 2024 15:52:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A8F743849AE9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713541935; bh=pGcnD3xK254EGgaSm94dJbiIW3bSugDEa4EtN2xL4Xo=; h=From:To:Subject:Date:From; b=ncSfJlc4wqvKbphPqYtAVXx5n4DnUqBD4xjksSCFfZ9fLDiP+Kc/nB0tZJSioT2gy 8Eilq8ERgQ//VGVE1LYNUXFNyY14s+I/jkDkhfM/NWtzaDy8LIBIIi3g1xKTpBQnI8 am7M1AzIAmPfZpvHFNmYPZ/FjzSxhSeOqSl1iYpI= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Nick Alcock To: binutils-cvs@sourceware.org Subject: [binutils-gdb] libctf: make ctf_lookup of symbols by name work in more cases X-Act-Checkin: binutils-gdb X-Git-Author: Nick Alcock X-Git-Refname: refs/heads/master X-Git-Oldrev: 0ebf1bdeeda1612dbe8e092dca765527a741e462 X-Git-Newrev: 9049b960f2bc7f0cb9db80d255e9fbec9f476f0f Message-Id: <20240419155215.A8F743849AE9@sourceware.org> Date: Fri, 19 Apr 2024 15:52:15 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D9049b960f2bc= 7f0cb9db80d255e9fbec9f476f0f commit 9049b960f2bc7f0cb9db80d255e9fbec9f476f0f Author: Nick Alcock Date: Tue Apr 2 16:06:50 2024 +0100 libctf: make ctf_lookup of symbols by name work in more cases =20 In particular, we don't need a symbol table if we're looking up a symbol by name and that type of symbol has an indexed symtypetab, since in that case we get the name from the symtypetab index, not from the symbol table. =20 This lets you do symbol lookups in unlinked object files and unlinked dicts written out via libctf's writeout functions. =20 libctf/ =20 * ctf-lookup.c (ctf_lookup_by_sym_or_name): Allow lookups by index even when there is no symtab. Diff: --- libctf/ctf-lookup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libctf/ctf-lookup.c b/libctf/ctf-lookup.c index aa251bafb89..f37dd7e45ce 100644 --- a/libctf/ctf-lookup.c +++ b/libctf/ctf-lookup.c @@ -1045,7 +1045,9 @@ ctf_lookup_by_sym_or_name (ctf_dict_t *fp, unsigned l= ong symidx, } =20 err =3D ECTF_NOSYMTAB; - if (sp->cts_data =3D=3D NULL) + if (sp->cts_data =3D=3D NULL && symname =3D=3D NULL && + ((is_function && !fp->ctf_funcidx_names) || + (!is_function && !fp->ctf_objtidx_names))) goto try_parent; =20 /* This covers both out-of-range lookups by index and a dynamic dict whi= ch