ctf_dump_objts output string

"Section is indexed" and "No symbol table" are generated at the
beginning of ctf_dump_objts but not output, resulting in an asan
complaint about leaked memory.  Clearly the messages should either not
be generated, or they should be output.  I chose to do the latter in
this patch, which requires some testsuite adjustment.

libctf/
	* ctf-dump.c (ctf_dump_objts): Output "Section is indexed" and
	"No symbol table" strings, enclosed in parentheses and
	indented.
ld/
	* testsuite/ld-ctf/data-func-conflicted-vars.d: Update.
	* testsuite/ld-ctf/data-func-conflicted.d: Update.
This commit is contained in:
Alan Modra 2026-02-04 06:52:55 +10:30
parent 32b096b73e
commit 8602bb6b79
3 changed files with 7 additions and 4 deletions

View file

@ -22,6 +22,7 @@ Contents of CTF section \.ctf:
String section: .*
#...
Data objects:
\(Section is indexed\.\)
bar -> 0x[0-9a-f]*: \(kind 6\) struct var_3 \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
var_1 -> 0x[0-9a-f]*: \(kind 10\) foo_t \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> .*
var_666 -> 0x[0-9a-f]*: \(kind 3\) foo_t \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> .*

View file

@ -21,6 +21,7 @@ Contents of CTF section \.ctf:
String section: .*
#...
Data objects:
\(Section is indexed\.\)
bar -> 0x[0-9a-f]*: \(kind 6\) struct var_3 \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\)
var_1 -> 0x[0-9a-f]*: \(kind 10\) foo_t \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> .*
var_666 -> 0x[0-9a-f]*: \(kind 3\) foo_t \* \(size 0x[0-9a-f]*\) \(aligned at 0x[0-9a-f]*\) -> .*

View file

@ -445,11 +445,12 @@ ctf_dump_objts (ctf_dict_t *fp, ctf_dump_state_t *state, int functions)
ctf_next_t *i = NULL;
char *str = NULL;
if ((functions && fp->ctf_funcidx_names)
|| (!functions && fp->ctf_objtidx_names))
str = str_append (str, _("Section is indexed.\n"));
if (functions ? fp->ctf_funcidx_names : fp->ctf_objtidx_names)
str = str_append (str, _(" (Section is indexed.)\n"));
else if (fp->ctf_ext_symtab.cts_data == NULL)
str = str_append (str, _("No symbol table.\n"));
str = str_append (str, _(" (No symbol table.)\n"));
if (str)
ctf_dump_append (state, str);
while ((id = ctf_symbol_next (fp, &i, &name, functions)) != CTF_ERR)
{