Date: Mon, 22 May 2006 20:11:24 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 97632 for review Message-ID: <200605222011.k4MKBOMT004384@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=97632 Change 97632 by jb@jb_freebsd2 on 2006/05/22 20:10:37 Add a method tos list file function names and their values. Affected files ... .. //depot/projects/dtrace/src/sys/kern/link_elf.c#2 edit .. //depot/projects/dtrace/src/sys/kern/link_elf_obj.c#2 edit .. //depot/projects/dtrace/src/sys/kern/linker_if.m#2 edit Differences ... ==== //depot/projects/dtrace/src/sys/kern/link_elf.c#2 (text+ko) ==== @@ -119,6 +119,9 @@ static int link_elf_each_function_name(linker_file_t, int (*)(const char *, void *), void *); +static int link_elf_each_function_nameval(linker_file_t, + int (*)(linker_file_t, linker_symval_t*, void *), + void *); static void link_elf_reloc_local(linker_file_t); static Elf_Addr elf_lookup(linker_file_t lf, Elf_Size symidx, int deps); @@ -132,6 +135,7 @@ KOBJMETHOD(linker_link_preload_finish, link_elf_link_preload_finish), KOBJMETHOD(linker_lookup_set, link_elf_lookup_set), KOBJMETHOD(linker_each_function_name, link_elf_each_function_name), + KOBJMETHOD(linker_each_function_nameval, link_elf_each_function_nameval), { 0, 0 } }; @@ -1216,6 +1220,29 @@ return (0); } +static int +link_elf_each_function_nameval(linker_file_t file, + int (*callback)(linker_file_t, linker_symval_t *, void *), void *opaque) { + linker_symval_t symval; + elf_file_t ef = (elf_file_t)file; + const Elf_Sym* symp; + int i, error; + + /* Exhaustive search */ + for (i = 0, symp = ef->ddbsymtab; i < ef->ddbsymcnt; i++, symp++) { + if (symp->st_value != 0 && + ELF_ST_TYPE(symp->st_info) == STT_FUNC) { + error = link_elf_symbol_values(file, (c_linker_sym_t) symp, &symval); + if (error) + return (error); + error = callback(file, &symval, opaque); + if (error) + return (error); + } + } + return (0); +} + #ifdef __ia64__ /* * Each KLD has its own GP. The GP value for each load module is given by ==== //depot/projects/dtrace/src/sys/kern/link_elf_obj.c#2 (text+ko) ==== @@ -122,6 +122,9 @@ void ***, void ***, int *); static int link_elf_each_function_name(linker_file_t, int (*)(const char *, void *), void *); +static int link_elf_each_function_nameval(linker_file_t, + int (*)(linker_file_t, linker_symval_t*, void *), + void *); static void link_elf_reloc_local(linker_file_t); static Elf_Addr elf_obj_lookup(linker_file_t lf, Elf_Size symidx, int deps); @@ -136,6 +139,7 @@ KOBJMETHOD(linker_link_preload_finish, link_elf_link_preload_finish), KOBJMETHOD(linker_lookup_set, link_elf_lookup_set), KOBJMETHOD(linker_each_function_name, link_elf_each_function_name), + KOBJMETHOD(linker_each_function_nameval, link_elf_each_function_nameval), { 0, 0 } }; @@ -1061,6 +1065,29 @@ return (0); } +static int +link_elf_each_function_nameval(linker_file_t file, + int (*callback)(linker_file_t, linker_symval_t *, void *), void *opaque) { + linker_symval_t symval; + elf_file_t ef = (elf_file_t)file; + const Elf_Sym* symp; + int i, error; + + /* Exhaustive search */ + for (i = 0, symp = ef->ddbsymtab; i < ef->ddbsymcnt; i++, symp++) { + if (symp->st_value != 0 && + ELF_ST_TYPE(symp->st_info) == STT_FUNC) { + error = link_elf_symbol_values(file, (c_linker_sym_t) symp, &symval); + if (error) + return (error); + error = callback(file, &symval, opaque); + if (error) + return (error); + } + } + return (0); +} + /* * Symbol lookup function that can be used when the symbol index is known (ie * in relocations). It uses the symbol index instead of doing a fully fledged ==== //depot/projects/dtrace/src/sys/kern/linker_if.m#2 (text+ko) ==== @@ -64,6 +64,17 @@ }; # +# Call the callback with each specified function and it's value +# defined in the file. +# Stop and return the error if the callback returns an error. +# +METHOD int each_function_nameval { + linker_file_t file; + linker_function_nameval_callback_t callback; + void* opaque; +}; + +# # Search for a linker set in a file. Return a pointer to the first # entry (which is itself a pointer), and the number of entries. # "stop" points to the entry beyond the last valid entry.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200605222011.k4MKBOMT004384>