]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
libctf: make ctf_lookup of symbols by name work in more cases
authorNick Alcock <nick.alcock@oracle.com>
Tue, 2 Apr 2024 15:06:50 +0000 (16:06 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 19 Apr 2024 15:14:47 +0000 (16:14 +0100)
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.

libctf/ctf-lookup.c

index aa251bafb8989efa51b5972baa4953e3e37e159a..f37dd7e45cef47ffc4ce4a321bfd1aceeb27887f 100644 (file)
@@ -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