diff options
author | Dima Kogan <dima@secretsauce.net> | 2014-06-02 02:01:57 -0700 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-08-22 20:38:26 +0900 |
commit | 5c5c38e500fd8f20bb8d6c0177948dbfe86b6fcd (patch) | |
tree | 4f05fbaf41292a7c264cbe2caedd5c78c8e24a91 /ltrace-elf.c | |
parent | 703e5c6363ae5d07be62c2efa0a17862ce3c1c45 (diff) | |
download | ltrace-5c5c38e500fd8f20bb8d6c0177948dbfe86b6fcd.tar.gz ltrace-5c5c38e500fd8f20bb8d6c0177948dbfe86b6fcd.tar.bz2 ltrace-5c5c38e500fd8f20bb8d6c0177948dbfe86b6fcd.zip |
We now use known prototypes for all aliased symbols (same address)
Some libraries have multiple names for the same function. Prior to this patch,
it was possible to define a prototype for a symbol, and not have ltrace use it
because it saw a different symbol be called. libc is a common source of this.
For instance (on my amd64 Debian box) it defines the nanosleep symbol as both
'nanosleep' and '__GI___nanosleep', at the same address. If a calling library
calls '__GI___nanosleep', then an ltrace prototype for 'nanosleep' would not be
used, even though it should apply to this call
Diffstat (limited to 'ltrace-elf.c')
-rw-r--r-- | ltrace-elf.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/ltrace-elf.c b/ltrace-elf.c index f638342..a6a5531 100644 --- a/ltrace-elf.c +++ b/ltrace-elf.c @@ -901,13 +901,8 @@ static int populate_this_symtab(struct process *proc, const char *filename, struct ltelf *lte, struct library *lib, Elf_Data *symtab, const char *strtab, size_t count, - struct library_exported_name **names) + struct library_exported_names *names) { - /* If a valid NAMES is passed, we pass in *NAMES a list of - * symbol names that this library exports. */ - if (names != NULL) - *names = NULL; - /* Using sorted array would be arguably better, but this * should be well enough for the number of symbols that we * typically deal with. */ @@ -957,20 +952,14 @@ populate_this_symtab(struct process *proc, const char *filename, /* If we are interested in exports, store this name. */ if (names != NULL) { - struct library_exported_name *export - = malloc(sizeof *export); char *name_copy = strdup(name); - - if (name_copy == NULL || export == NULL) { - free(name_copy); - free(export); + if (name_copy == NULL || + library_exported_names_push(names, + sym.st_value, + name_copy, 1) != 0) + { fprintf(stderr, "Couldn't store symbol %s. " "Tracing may be incomplete.\n", name); - } else { - export->name = name_copy; - export->own_name = 1; - export->next = *names; - *names = export; } } @@ -1115,7 +1104,7 @@ populate_symtab(struct process *proc, const char *filename, /* Check whether we want to trace symbols implemented by this * library (-l). */ - struct library_exported_name **names = NULL; + struct library_exported_names *names = NULL; if (exports) { debug(DEBUG_FUNCTION, "-l matches %s", lib->soname); names = &lib->exported_names; |