[binutils-gdb] ctf_dump_objts output string

Alan Modra amodra@sourceware.org
Tue Feb 3 20:58:24 GMT 2026


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

commit 8602bb6b799f70b4e7025b595022ad8681f2732f
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Feb 4 06:52:55 2026 +1030

    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.

Diff:
---
 ld/testsuite/ld-ctf/data-func-conflicted-vars.d | 1 +
 ld/testsuite/ld-ctf/data-func-conflicted.d      | 1 +
 libctf/ctf-dump.c                               | 9 +++++----
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/ld/testsuite/ld-ctf/data-func-conflicted-vars.d b/ld/testsuite/ld-ctf/data-func-conflicted-vars.d
index 4e570c6a61a..59ab0a34108 100644
--- a/ld/testsuite/ld-ctf/data-func-conflicted-vars.d
+++ b/ld/testsuite/ld-ctf/data-func-conflicted-vars.d
@@ -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]*\) -> .*
diff --git a/ld/testsuite/ld-ctf/data-func-conflicted.d b/ld/testsuite/ld-ctf/data-func-conflicted.d
index b0db511a987..bdbcd4fc1f3 100644
--- a/ld/testsuite/ld-ctf/data-func-conflicted.d
+++ b/ld/testsuite/ld-ctf/data-func-conflicted.d
@@ -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]*\) -> .*
diff --git a/libctf/ctf-dump.c b/libctf/ctf-dump.c
index 3fd8cb87f9f..561d17ff7a2 100644
--- a/libctf/ctf-dump.c
+++ b/libctf/ctf-dump.c
@@ -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)
     {


More information about the Binutils-cvs mailing list