Date: Wed, 30 Jan 2008 23:29:01 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 134500 for review Message-ID: <200801302329.m0UNT1E5021558@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=134500 Change 134500 by jb@jb_freebsd1 on 2008/01/30 23:28:35 IDdtrace. Affected files ... .. //depot/projects/dtrace7/src/sys/kern/link_elf.c#2 edit .. //depot/projects/dtrace7/src/sys/kern/link_elf_obj.c#2 edit Differences ... ==== //depot/projects/dtrace7/src/sys/kern/link_elf.c#2 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/link_elf.c,v 1.93 2007/05/31 11:51:51 kib Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/link_elf.c,v 1.95 2008/01/13 14:44:09 attilio Exp $"); #include "opt_gdb.h" #include "opt_mac.h" @@ -121,6 +121,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); @@ -134,6 +137,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 } }; @@ -572,7 +576,7 @@ vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); #ifdef MAC - error = mac_check_kld_load(curthread->td_ucred, nd.ni_vp); + error = mac_kld_check_load(curthread->td_ucred, nd.ni_vp); if (error) { firstpage = NULL; goto out; @@ -1222,6 +1226,30 @@ 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/dtrace7/src/sys/kern/link_elf_obj.c#2 (text+ko) ==== @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/link_elf_obj.c,v 1.95 2007/05/31 11:51:51 kib Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/link_elf_obj.c,v 1.97 2008/01/13 14:44:09 attilio Exp $"); #include "opt_ddb.h" #include "opt_mac.h" @@ -124,6 +124,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); @@ -138,6 +141,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 } }; @@ -410,7 +414,7 @@ vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); #ifdef MAC - error = mac_check_kld_load(td->td_ucred, nd.ni_vp); + error = mac_kld_check_load(td->td_ucred, nd.ni_vp); if (error) { goto out; } @@ -1064,6 +1068,30 @@ 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801302329.m0UNT1E5021558>