kern_linker.c (edfbe150804a4f40e8282786b00798359c07e652) kern_linker.c (ba031106b171be1a49c3cf273062facdc3b8bc0d)
1/*-
2 * Copyright (c) 1997 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1997 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id: kern_linker.c,v 1.15 1998/11/06 15:10:17 peter Exp $
26 * $Id: kern_linker.c,v 1.16 1998/11/10 08:49:28 peter Exp $
27 */
28
29#include "opt_ddb.h"
30
31#include <sys/param.h>
32#include <sys/kernel.h>
33#include <sys/systm.h>
34#include <sys/malloc.h>

--- 729 unchanged lines hidden (view full) ---

764 else
765 p->p_retval[0] = 0;
766 } else
767 error = ENOENT;
768
769 return error;
770}
771
27 */
28
29#include "opt_ddb.h"
30
31#include <sys/param.h>
32#include <sys/kernel.h>
33#include <sys/systm.h>
34#include <sys/malloc.h>

--- 729 unchanged lines hidden (view full) ---

764 else
765 p->p_retval[0] = 0;
766 } else
767 error = ENOENT;
768
769 return error;
770}
771
772int
773kldsym(struct proc *p, struct kldsym_args *uap)
774{
775 char *symstr = NULL;
776 linker_sym_t sym;
777 linker_symval_t symval;
778 linker_file_t lf;
779 struct kld_sym_lookup lookup;
780 int error = 0;
781
782 if (error = copyin(SCARG(uap, data), &lookup, sizeof(lookup)))
783 goto out;
784 if (lookup.version != sizeof(lookup) || SCARG(uap, cmd) != KLDSYM_LOOKUP) {
785 error = EINVAL;
786 goto out;
787 }
788
789 symstr = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
790 if (error = copyinstr(lookup.symname, symstr, MAXPATHLEN, NULL))
791 goto out;
792
793 if (SCARG(uap, fileid) != 0) {
794 lf = linker_find_file_by_id(SCARG(uap, fileid));
795 if (lf == NULL) {
796 error = ENOENT;
797 goto out;
798 }
799 if (lf->ops->lookup_symbol(lf, symstr, &sym) == 0 &&
800 lf->ops->symbol_values(lf, sym, &symval) == 0) {
801 lookup.symvalue = (u_long)symval.value;
802 lookup.symsize = symval.size;
803 error = copyout(&lookup, SCARG(uap, data), sizeof(lookup));
804 } else
805 error = ENOENT;
806 } else {
807 for (lf = TAILQ_FIRST(&files); lf; lf = TAILQ_NEXT(lf, link)) {
808 if (lf->ops->lookup_symbol(lf, symstr, &sym) == 0 &&
809 lf->ops->symbol_values(lf, sym, &symval) == 0) {
810 lookup.symvalue = (u_long)symval.value;
811 lookup.symsize = symval.size;
812 error = copyout(&lookup, SCARG(uap, data), sizeof(lookup));
813 break;
814 }
815 }
816 if (!lf)
817 error = ENOENT;
818 }
819out:
820 if (symstr)
821 free(symstr, M_TEMP);
822 return error;
823}
824
772/*
773 * Preloaded module support
774 */
775
776static void
777linker_preload(void* arg)
778{
779 caddr_t modptr;

--- 138 unchanged lines hidden ---
825/*
826 * Preloaded module support
827 */
828
829static void
830linker_preload(void* arg)
831{
832 caddr_t modptr;

--- 138 unchanged lines hidden ---