public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: Nick Alcock <nix@sourceware.org>
To: binutils-cvs@sourceware.org
Subject: [binutils-gdb] libctf: make ctf_lookup of symbols by name work in more cases
Date: Fri, 19 Apr 2024 15:52:15 +0000 (GMT)	[thread overview]
Message-ID: <20240419155215.A8F743849AE9@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9049b960f2bc7f0cb9db80d255e9fbec9f476f0f

commit 9049b960f2bc7f0cb9db80d255e9fbec9f476f0f
Author: Nick Alcock <nick.alcock@oracle.com>
Date:   Tue Apr 2 16:06:50 2024 +0100

    libctf: make ctf_lookup of symbols by name work in more cases
    
    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.
    
    This lets you do symbol lookups in unlinked object files and unlinked
    dicts written out via libctf's writeout functions.
    
    libctf/
    
            * 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 long symidx,
     }
 
   err = ECTF_NOSYMTAB;
-  if (sp->cts_data == NULL)
+  if (sp->cts_data == NULL && symname == NULL &&
+      ((is_function && !fp->ctf_funcidx_names) ||
+       (!is_function && !fp->ctf_objtidx_names)))
     goto try_parent;
 
   /* This covers both out-of-range lookups by index and a dynamic dict which

                 reply	other threads:[~2024-04-19 15:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240419155215.A8F743849AE9@sourceware.org \
    --to=nix@sourceware.org \
    --cc=binutils-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).