libctf, include: add ctf_getsymsect and ctf_getstrsect
authorNick Alcock <nick.alcock@oracle.com>
Fri, 20 Nov 2020 13:34:04 +0000 (13:34 +0000)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 20 Nov 2020 13:34:12 +0000 (13:34 +0000)
libctf has long provided ctf_getdatasect, which hands back a pointer to
the CTF section a (read-only) dict came from.  But it has no such
functions to return pointers to the ELF symbol table or string table
it's working from, which is unfortunate because several libctf functions
(ctf_open, ctf_fdopen, and ctf_bfdopen) figure out which string and
symbol table to use themselves, and don't tell the user what they
decided, so the caller can't agree on which symtab to use with libctf
even if it wanted to.

Add a pair of functions to return the symtab and strtab in use.  Like
ctf_getdatasect, these return ctf_sect_t structures by value, filled
with all-NULL/0 content if a symtab or strtab is not being used.

include/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

* ctf-api.h (ctf_getsymsect): New.
(ctf_getstrsect): Likewise.

libctf/ChangeLog
2020-11-20  Nick Alcock  <nick.alcock@oracle.com>

* ctf-open.c (ctf_getsymsect): New.
(ctf_getstrsect): Likewise.
* libctf.ver: Add them.

include/ChangeLog
include/ctf-api.h
libctf/ChangeLog
libctf/ctf-open.c
libctf/libctf.ver

index 1d4eac95ad6ae6ad328567809915e682afbfbca8..704c9af3ba8ce0a9ec4cfc706757ed6e4324f513 100644 (file)
@@ -1,3 +1,8 @@
+2020-11-20  Nick Alcock  <nick.alcock@oracle.com>
+
+       * ctf-api.h (ctf_getsymsect): New.
+       (ctf_getstrsect): Likewise.
+
 2020-11-20  Nick Alcock  <nick.alcock@oracle.com>
 
        * ctf-api.h (ctf_arc_lookup_symbol): New.
index f0c00c01a89cf08d72dd94c18172d4b368af72ea..8687475cc64843a0d3cf858508fbf0cd688f877f 100644 (file)
@@ -307,6 +307,8 @@ extern ctf_archive_t *ctf_open (const char *filename,
                                const char *target, int *errp);
 extern void ctf_close (ctf_archive_t *);
 extern ctf_sect_t ctf_getdatasect (const ctf_dict_t *);
+extern ctf_sect_t ctf_getsymsect (const ctf_dict_t *);
+extern ctf_sect_t ctf_getstrsect (const ctf_dict_t *);
 extern ctf_archive_t *ctf_get_arc (const ctf_dict_t *);
 extern ctf_archive_t *ctf_arc_open (const char *, int *);
 extern ctf_archive_t *ctf_arc_bufopen (const ctf_sect_t *,
index deca027786dc7b028aa1b703ef189968ba6b3937..685c06a01420b6898efd066e1d1cd6bf7f8a36b8 100644 (file)
@@ -1,3 +1,9 @@
+2020-11-20  Nick Alcock  <nick.alcock@oracle.com>
+
+       * ctf-open.c (ctf_getsymsect): New.
+       (ctf_getstrsect): Likewise.
+       * libctf.ver: Add them.
+
 2020-11-20  Nick Alcock  <nick.alcock@oracle.com>
 
        * ctf-impl.h (struct ctf_archive_internal) <ctfi_dicts>: New, dicts
index 3281c678ac4664bbc3847c1f2ae2b8e07c312b3e..ecf27eeeb21da6ef6ecf5bd44c7bdc480154a3d7 100644 (file)
@@ -1854,6 +1854,18 @@ ctf_getdatasect (const ctf_dict_t *fp)
   return fp->ctf_data;
 }
 
+ctf_sect_t
+ctf_getsymsect (const ctf_dict_t *fp)
+{
+  return fp->ctf_symtab;
+}
+
+ctf_sect_t
+ctf_getstrsect (const ctf_dict_t *fp)
+{
+  return fp->ctf_strtab;
+}
+
 /* Return the CTF handle for the parent CTF dict, if one exists.  Otherwise
    return NULL to indicate this dict has no imported parent.  */
 ctf_dict_t *
index f0633f26c4cd688bcae4ca7b7025c5e96b97f66d..cfecc894350b0bed2b24e9263a8a61ade7c8ca83 100644 (file)
@@ -190,4 +190,7 @@ LIBCTF_1.1 {
 
        ctf_arc_lookup_symbol;
        ctf_arc_flush_caches;
+
+       ctf_getsymsect;
+       ctf_getstrsect;
 } LIBCTF_1.0;