aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2020-11-20 13:34:04 +0000
committerNick Alcock <nick.alcock@oracle.com>2020-11-20 13:34:12 +0000
commit97a2a623d0193dbfc92d92545b63aaffd6099272 (patch)
tree4467ff62484008adf7eb1596909465cd727201a9
parent2c78e92523a650c9cbd68130ce8a766570457cd6 (diff)
downloadfsf-binutils-gdb-97a2a623d0193dbfc92d92545b63aaffd6099272.zip
fsf-binutils-gdb-97a2a623d0193dbfc92d92545b63aaffd6099272.tar.gz
fsf-binutils-gdb-97a2a623d0193dbfc92d92545b63aaffd6099272.tar.bz2
libctf, include: add ctf_getsymsect and ctf_getstrsect
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.
-rw-r--r--include/ChangeLog5
-rw-r--r--include/ctf-api.h2
-rw-r--r--libctf/ChangeLog6
-rw-r--r--libctf/ctf-open.c12
-rw-r--r--libctf/libctf.ver3
5 files changed, 28 insertions, 0 deletions
diff --git a/include/ChangeLog b/include/ChangeLog
index 1d4eac9..704c9af 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,5 +1,10 @@
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.
(ctf_arc_flush_caches): Likewise.
* ctf.h: Document new auto-ctf_import behaviour.
diff --git a/include/ctf-api.h b/include/ctf-api.h
index f0c00c0..8687475 100644
--- a/include/ctf-api.h
+++ b/include/ctf-api.h
@@ -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 *,
diff --git a/libctf/ChangeLog b/libctf/ChangeLog
index deca027..685c06a 100644
--- a/libctf/ChangeLog
+++ b/libctf/ChangeLog
@@ -1,5 +1,11 @@
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
the archive machinery has opened and cached.
<ctfi_symdicts>: New, cache of dicts containing symbols looked up.
diff --git a/libctf/ctf-open.c b/libctf/ctf-open.c
index 3281c67..ecf27ee 100644
--- a/libctf/ctf-open.c
+++ b/libctf/ctf-open.c
@@ -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 *
diff --git a/libctf/libctf.ver b/libctf/libctf.ver
index f0633f2..cfecc89 100644
--- a/libctf/libctf.ver
+++ b/libctf/libctf.ver
@@ -190,4 +190,7 @@ LIBCTF_1.1 {
ctf_arc_lookup_symbol;
ctf_arc_flush_caches;
+
+ ctf_getsymsect;
+ ctf_getstrsect;
} LIBCTF_1.0;