[Ltrace-devel] [PATCH 07/11] Extend the -x option.

Joe Damato ice799 at gmail.com
Mon Nov 8 23:47:40 UTC 2010


Searches for the specified symbol in the loaded libraries. This will only search
the dynamic symbol table (dynsym), but can probably be extended to also search
the symbol table, if one exists.
---
 ltrace-elf.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/ltrace-elf.c b/ltrace-elf.c
index 00a7e5f..dafb5cb 100644
--- a/ltrace-elf.c
+++ b/ltrace-elf.c
@@ -605,6 +605,30 @@ read_elf(Process *proc) {
 				break;
 			}
 	}
+
+	int found_count = 0;
+
+	for (xptr = opt_x; xptr; xptr = xptr->next) {
+		if (xptr->found)
+			continue;
+
+		GElf_Sym sym;
+		GElf_Addr addr;
+		if (in_load_libraries(xptr->name, lte, library_num+1, &sym)) {
+			debug(2, "found symbol %s @ %lx, adding it.", xptr->name, sym.st_value);
+			addr = sym.st_value;
+			if (ELF32_ST_TYPE (sym.st_info) == STT_FUNC) {
+				add_library_symbol(addr, xptr->name, lib_tail, LS_TOPLT_NONE, 0);
+				xptr->found = 1;
+				found_count++;
+			}
+		}
+		if (found_count == opt_x_cnt){
+			debug(2, "done, found everything: %d\n", found_count);
+			break;
+		}
+	}
+
 	for (xptr = opt_x; xptr; xptr = xptr->next)
 		if ( ! xptr->found) {
 			char *badthing = "WARNING";
-- 
1.7.0.4




More information about the Ltrace-devel mailing list