libctf: rename ctf_dict.ctf_{symtab,strtab}

These two fields are constantly confusing because CTF dicts contain both
a symtypetab and strtab, but these fields are not that: they are the
symtab and strtab from the ELF file.  We have enough string tables now
(internal, external, synthetic external, dynamic) that we need to at
least name them better than this to avoid getting totally confused.
Rename them to ctf_ext_symtab and ctf_ext_strtab.

libctf/

	* ctf-dump.c (ctf_dump_objts): Rename ctf_symtab -> ctf_ext_symtab.
	* ctf-impl.h (struct ctf_dict.ctf_symtab): Rename to...
	(struct ctf_dict.ctf_ext_strtab): ... this.
	(struct ctf_dict.ctf_strtab): Rename to...
	(struct ctf_dict.ctf_ext_strtab): ... this.
	* ctf-lookup.c (ctf_lookup_symbol_name): Adapt.
	(ctf_lookup_symbol_idx): Adapt.
	(ctf_lookup_by_sym_or_name): Adapt.
	* ctf-open.c (ctf_bufopen_internal): Adapt.
	(ctf_dict_close): Adapt.
	(ctf_getsymsect): Adapt.
	(ctf_getstrsect): Adapt.
	(ctf_symsect_endianness): Adapt.
This commit is contained in:
Nick Alcock
2024-01-05 12:17:27 +00:00
parent bb2a9a465e
commit 629acbe4a3
4 changed files with 25 additions and 25 deletions

View File

@@ -1626,8 +1626,8 @@ ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
if (symsect != NULL)
{
memcpy (&fp->ctf_symtab, symsect, sizeof (ctf_sect_t));
memcpy (&fp->ctf_strtab, strsect, sizeof (ctf_sect_t));
memcpy (&fp->ctf_ext_symtab, symsect, sizeof (ctf_sect_t));
memcpy (&fp->ctf_ext_strtab, strsect, sizeof (ctf_sect_t));
}
if (fp->ctf_data.cts_name != NULL)
@@ -1636,14 +1636,14 @@ ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
err = ENOMEM;
goto bad;
}
if (fp->ctf_symtab.cts_name != NULL)
if ((fp->ctf_symtab.cts_name = strdup (fp->ctf_symtab.cts_name)) == NULL)
if (fp->ctf_ext_symtab.cts_name != NULL)
if ((fp->ctf_ext_symtab.cts_name = strdup (fp->ctf_ext_symtab.cts_name)) == NULL)
{
err = ENOMEM;
goto bad;
}
if (fp->ctf_strtab.cts_name != NULL)
if ((fp->ctf_strtab.cts_name = strdup (fp->ctf_strtab.cts_name)) == NULL)
if (fp->ctf_ext_strtab.cts_name != NULL)
if ((fp->ctf_ext_strtab.cts_name = strdup (fp->ctf_ext_strtab.cts_name)) == NULL)
{
err = ENOMEM;
goto bad;
@@ -1651,10 +1651,10 @@ ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
if (fp->ctf_data.cts_name == NULL)
fp->ctf_data.cts_name = _CTF_NULLSTR;
if (fp->ctf_symtab.cts_name == NULL)
fp->ctf_symtab.cts_name = _CTF_NULLSTR;
if (fp->ctf_strtab.cts_name == NULL)
fp->ctf_strtab.cts_name = _CTF_NULLSTR;
if (fp->ctf_ext_symtab.cts_name == NULL)
fp->ctf_ext_symtab.cts_name = _CTF_NULLSTR;
if (fp->ctf_ext_strtab.cts_name == NULL)
fp->ctf_ext_strtab.cts_name = _CTF_NULLSTR;
if (strsect != NULL)
{
@@ -1836,11 +1836,11 @@ ctf_dict_close (ctf_dict_t *fp)
if (fp->ctf_data.cts_name != _CTF_NULLSTR)
free ((char *) fp->ctf_data.cts_name);
if (fp->ctf_symtab.cts_name != _CTF_NULLSTR)
free ((char *) fp->ctf_symtab.cts_name);
if (fp->ctf_ext_symtab.cts_name != _CTF_NULLSTR)
free ((char *) fp->ctf_ext_symtab.cts_name);
if (fp->ctf_strtab.cts_name != _CTF_NULLSTR)
free ((char *) fp->ctf_strtab.cts_name);
if (fp->ctf_ext_strtab.cts_name != _CTF_NULLSTR)
free ((char *) fp->ctf_ext_strtab.cts_name);
else if (fp->ctf_data_mmapped)
ctf_munmap (fp->ctf_data_mmapped, fp->ctf_data_mmapped_len);
@@ -1909,13 +1909,13 @@ ctf_getdatasect (const ctf_dict_t *fp)
ctf_sect_t
ctf_getsymsect (const ctf_dict_t *fp)
{
return fp->ctf_symtab;
return fp->ctf_ext_symtab;
}
ctf_sect_t
ctf_getstrsect (const ctf_dict_t *fp)
{
return fp->ctf_strtab;
return fp->ctf_ext_strtab;
}
/* Set the endianness of the symbol table attached to FP. */
@@ -1930,8 +1930,8 @@ ctf_symsect_endianness (ctf_dict_t *fp, int little_endian)
our idea of the endianness has changed. */
if (old_endianness != fp->ctf_symsect_little_endian
&& fp->ctf_sxlate != NULL && fp->ctf_symtab.cts_data != NULL)
assert (init_symtab (fp, fp->ctf_header, &fp->ctf_symtab) == 0);
&& fp->ctf_sxlate != NULL && fp->ctf_ext_symtab.cts_data != NULL)
assert (init_symtab (fp, fp->ctf_header, &fp->ctf_ext_symtab) == 0);
}
/* Return the CTF handle for the parent CTF dict, if one exists. Otherwise