aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-impl.h
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2019-04-24 10:46:39 +0100
committerNick Alcock <nick.alcock@oracle.com>2019-05-28 17:08:08 +0100
commit143dce8481f09f60704ab52b98cf8fe6d8b29fc9 (patch)
tree0c7fdc61341278f34fc4e0e6d7cce936971ec3dc /libctf/ctf-impl.h
parent9402cc593f4aa54677203efa9a92c4f28d3033eb (diff)
downloadbinutils-143dce8481f09f60704ab52b98cf8fe6d8b29fc9.zip
binutils-143dce8481f09f60704ab52b98cf8fe6d8b29fc9.tar.gz
binutils-143dce8481f09f60704ab52b98cf8fe6d8b29fc9.tar.bz2
libctf: ELF file opening via BFD
These functions let you open an ELF file with a customarily-named CTF section in it, automatically opening the CTF file or archive and associating the symbol and string tables in the ELF file with the CTF container, so that you can look up the types of symbols in the ELF file via ctf_lookup_by_symbol(), and so that strings can be shared between the ELF file and CTF container, to save space. It uses BFD machinery to do so. This has now been lightly tested and seems to work. In particular, if you already have a bfd you can pass it in to ctf_bfdopen(), and if you want a bfd made for you you can call ctf_open() or ctf_fdopen(), optionally specifying a target (or try once without a target and then again with one if you get ECTF_BFD_AMBIGUOUS back). We use a forward declaration for the struct bfd in ctf-api.h, so that ctf-api.h users are not required to pull in <bfd.h>. (This is mostly for the sake of readelf.) libctf/ * ctf-open-bfd.c: New file. * ctf-open.c (ctf_close): New. * ctf-impl.h: Include bfd.h. (ctf_file): New members ctf_data_mmapped, ctf_data_mmapped_len. (ctf_archive_internal): New members ctfi_abfd, ctfi_data, ctfi_bfd_close. (ctf_bfdopen_ctfsect): New declaration. (_CTF_SECTION): likewise. include/ * ctf-api.h (struct bfd): New forward. (ctf_fdopen): New. (ctf_bfdopen): Likewise. (ctf_open): Likewise. (ctf_arc_open): Likewise.
Diffstat (limited to 'libctf/ctf-impl.h')
-rw-r--r--libctf/ctf-impl.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/libctf/ctf-impl.h b/libctf/ctf-impl.h
index 898be8c..8522a03 100644
--- a/libctf/ctf-impl.h
+++ b/libctf/ctf-impl.h
@@ -31,6 +31,7 @@
#include <limits.h>
#include <ctype.h>
#include <elf.h>
+#include <bfd.h>
#ifdef __cplusplus
extern "C"
@@ -188,6 +189,8 @@ struct ctf_file
ctf_sect_t ctf_data; /* CTF data from object file. */
ctf_sect_t ctf_symtab; /* Symbol table from object file. */
ctf_sect_t ctf_strtab; /* String table from object file. */
+ void *ctf_data_mmapped; /* CTF data we mmapped, to free later. */
+ size_t ctf_data_mmapped_len; /* Length of CTF data we mmapped. */
ctf_hash_t *ctf_structs; /* Hash table of struct types. */
ctf_hash_t *ctf_unions; /* Hash table of union types. */
ctf_hash_t *ctf_enums; /* Hash table of enum types. */
@@ -240,6 +243,8 @@ struct ctf_archive_internal
ctf_sect_t ctfi_symsect;
ctf_sect_t ctfi_strsect;
void *ctfi_data;
+ bfd *ctfi_abfd; /* Optional source of section data. */
+ void (*ctfi_bfd_close) (struct ctf_archive_internal *);
};
/* Return x rounded up to an alignment boundary.
@@ -358,6 +363,7 @@ extern Elf64_Sym *ctf_sym_to_elf64 (const Elf32_Sym *src, Elf64_Sym *dst);
/* Variables, all underscore-prepended. */
+extern const char _CTF_SECTION[]; /* name of CTF ELF section */
extern const char _CTF_NULLSTR[]; /* empty string */
extern int _libctf_debug; /* debugging messages enabled */