libctf: fix some tabdamage and move some code around

ctf-link.c is unnecessarily confusing because ctf_link_lazy_open is
positioned near functions that have nothing to do with opening files.

Move it around, and fix some tabdamage that's crept in lately.

libctf/ChangeLog
2021-03-18  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-link.c (ctf_link_lazy_open): Move up in the file, to near
	ctf_link_add_ctf.
	* ctf-lookup.c (ctf_lookup_symbol_idx): Repair tabdamage.
	(ctf_lookup_by_sym_or_name): Likewise.
	* testsuite/libctf-lookup/struct-iteration.c: Likewise.
	* testsuite/libctf-regression/type-add-unnamed-struct.c: Likewise.
This commit is contained in:
Nick Alcock 2021-03-18 12:37:52 +00:00
parent a1f463bedd
commit 087945261c
5 changed files with 65 additions and 56 deletions

View file

@ -592,9 +592,9 @@ ctf_lookup_symbol_idx (ctf_dict_t *fp, const char *symname)
cache->ctf_symhash_latest) < 0)
goto oom;
if (strcmp (sym.st_name, symname) == 0)
return cache->ctf_symhash_latest++;
}
break;
return cache->ctf_symhash_latest++;
}
break;
case sizeof (Elf32_Sym):
{
Elf32_Sym *symp = (Elf32_Sym *) sp->cts_data;
@ -607,8 +607,8 @@ ctf_lookup_symbol_idx (ctf_dict_t *fp, const char *symname)
cache->ctf_symhash_latest) < 0)
goto oom;
if (strcmp (sym.st_name, symname) == 0)
return cache->ctf_symhash_latest++;
}
return cache->ctf_symhash_latest++;
}
break;
default:
ctf_set_errno (fp, ECTF_SYMTAB);
@ -902,7 +902,7 @@ ctf_lookup_by_sym_or_name (ctf_dict_t *fp, unsigned long symidx,
if (symidx > fp->ctf_dynsymmax)
goto try_parent;
sym = fp->ctf_dynsymidx[symidx];
sym = fp->ctf_dynsymidx[symidx];
err = ECTF_NOTYPEDAT;
if (!sym || (sym->st_shndx != STT_OBJECT && sym->st_shndx != STT_FUNC))
goto try_parent;