diff options
author | Petr Machata <pmachata@redhat.com> | 2012-02-18 11:17:29 +0100 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2012-04-19 00:57:35 +0200 |
commit | 2b46cfc1127d390eddd9593fe5ce5399c1f68130 (patch) | |
tree | be4ce983280d64681bc3eaa295fc0837eac0b833 /ltrace-elf.h | |
parent | a7db59c355cef464073496221ad27519a48466f9 (diff) | |
download | ltrace-2b46cfc1127d390eddd9593fe5ce5399c1f68130.tar.gz |
The first crude version of tracing across libraries
- the patch will be sliced later
Diffstat (limited to 'ltrace-elf.h')
-rw-r--r-- | ltrace-elf.h | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/ltrace-elf.h b/ltrace-elf.h index 507a466..7616814 100644 --- a/ltrace-elf.h +++ b/ltrace-elf.h @@ -3,8 +3,16 @@ #include <gelf.h> #include <stdlib.h> -#include "proc.h" +struct Process; +struct library; + +/* XXX Ok, the original idea was to separate the low-level ELF data + * from the abstract "struct library" object, but we use some of the + * following extensively in the back end. Not all though. So what we + * use should be move to struct library, and the rest of this + * structure maybe could be safely hidden in .c. How to integrate the + * arch-specific bits into struct library is unclear as of now. */ struct ltelf { int fd; Elf *elf; @@ -18,16 +26,16 @@ struct ltelf { size_t relplt_count; Elf_Data *symtab; const char *strtab; + const char *soname; size_t symtab_count; Elf_Data *opd; GElf_Addr *opd_addr; size_t opd_size; - Elf32_Word *hash; - int hash_type; int lte_flags; GElf_Addr dyn_addr; size_t dyn_sz; GElf_Addr base_addr; + GElf_Addr entry_addr; #ifdef __mips__ size_t pltgot_addr; size_t mips_local_gotno; @@ -37,22 +45,22 @@ struct ltelf { }; #define ELF_MAX_SEGMENTS 50 -#define LTE_HASH_MALLOCED 1 #define LTE_PLT_EXECUTABLE 2 -#define PLTS_ARE_EXECUTABLE(lte) ((lte->lte_flags & LTE_PLT_EXECUTABLE) != 0) +#define PLTS_ARE_EXECUTABLE(lte) (((lte)->lte_flags & LTE_PLT_EXECUTABLE) != 0) -extern size_t library_num; -extern char *library[MAX_LIBRARIES]; +int open_elf(struct ltelf *lte, const char *filename); -extern int open_elf(struct ltelf *lte, const char *filename); -extern struct library_symbol *read_elf(Process *proc, GElf_Addr *entryp); +/* XXX is it possible to put breakpoints in VDSO and VSYSCALL + * pseudo-libraries? For now we assume that all libraries can be + * opened via a filesystem. BASE is ignored for ET_EXEC files. */ +struct library *ltelf_read_library(const char *filename, GElf_Addr base); -extern GElf_Addr arch_plt_sym_val(struct ltelf *, size_t, GElf_Rela *); +/* Create a library object representing the main binary. The entry + * point address is stored to *ENTRYP. */ +struct library *ltelf_read_main_binary(struct Process *proc, const char *path); -#ifndef SHT_GNU_HASH -#define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table. */ -#endif +GElf_Addr arch_plt_sym_val(struct ltelf *, size_t, GElf_Rela *); #if __WORDSIZE == 32 #define PRI_ELF_ADDR PRIx32 |