X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=library.h;h=4506621bc9e6614486fd382ba0a2cf401edcf41b;hb=3ea27fbec92833a25a66f237706ca47a2791db10;hp=4d649e0fb75f01f3718937149a634a7e0cf3b5b8;hpb=d5232406664fdc51640eeba8f0e49f26275921df;p=platform%2Fupstream%2Fltrace.git diff --git a/library.h b/library.h index 4d649e0..4506621 100644 --- a/library.h +++ b/library.h @@ -19,15 +19,17 @@ * 02110-1301 USA */ -#ifndef _LIBRARY_H_ -#define _LIBRARY_H_ +#ifndef LIBRARY_H +#define LIBRARY_H #include +#include #if defined(HAVE_LIBDW) # include #endif +#include "dict.h" #include "callback.h" #include "forward.h" #include "sysdep.h" @@ -41,11 +43,21 @@ enum toplt { size_t arch_addr_hash(const arch_addr_t *addr); int arch_addr_eq(const arch_addr_t *addr1, const arch_addr_t *addr2); -/* For handling -l. */ -struct library_exported_name { - struct library_exported_name *next; - const char *name; - int own_name : 1; + +/* For handling -l and for handling library export aliases (different symbol + * name, same address) + * + * This structure needs to + * - store (addr, name) tuples + * - be searchable by addr (when populating) + * - be searchable by name (when looking for aliases) + * - be enumeratable (by activate_latent_in()) + */ +struct library_exported_names { + // I store the data in several structures to facilitate different types + // of access + struct dict names; // maps a name to an address + struct dict addrs; // maps an address to a vect of names }; struct library_symbol { @@ -158,8 +170,10 @@ struct library { /* List of names that this library implements, and that match * -l filter. Each time a new library is mapped, its list of * exports is examined, and corresponding PLT slots are - * enabled. */ - struct library_exported_name *exported_names; + * enabled. This data structure also keeps track of export + * addresses to find symbols with different names, but same + * addresses */ + struct library_exported_names exported_names; /* Prototype library associated with this library. */ struct protolib *protolib; @@ -171,6 +185,7 @@ struct library { char own_soname : 1; char own_pathname : 1; + bool should_activate_latent : 1; struct arch_library_data arch; struct os_library_data os; @@ -241,4 +256,39 @@ int arch_translate_address(struct ltelf *lte, int arch_translate_address_dyn(struct process *proc, arch_addr_t addr, arch_addr_t *ret); -#endif /* _LIBRARY_H_ */ + +/* Pushes a name/address tuple to the list of a library's exports. Returns 0 on + * success + */ +int library_exported_names_push(struct library_exported_names *names, + uint64_t addr, char *name, + int own_name ); + +/* Iterates through the a library's export list, reporting each symbol that is + * an alias of the given 'aliasname' symbol. This 'aliasname' symbol itself is + * NOT reported, so if this symbol is unique, the callback is not called at all. + * + * If we want to iterate through the whole alias list, set + * name_start_after=NULL. If we want to start iterating immediately past a + * particular symbol name, pass a pointer to this symbol name in + * name_start_after. This must be a pointer in the internal dict, preferably + * returned by an earlier call to this function + * + * If the callback fails at any point, a pointer to the failing key is returned. + * On success, returns NULL. The returned pointer can be passed back to this + * function in name_start_after to resume skipping this element + */ +const char** library_exported_names_each_alias( + struct library_exported_names *names, + const char *aliasname, + const char **name_start_after, + enum callback_status (*cb)(const char *, + void *), + void *data); + +/* Returns 0 if the exported names list does not contain a given name, or 1 if + * it does */ +int library_exported_names_contains(struct library_exported_names* names, + const char* queryname); + +#endif /* LIBRARY_H */