kern_linker.c (40162) | kern_linker.c (40395) |
---|---|
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.8 1998/10/10 00:07:53 peter Exp $ | 26 * $Id: kern_linker.c,v 1.9 1998/10/10 02:29:07 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> --- 34 unchanged lines hidden (view full) --- 69linker_add_class(const char* desc, void* priv, 70 struct linker_class_ops* ops) 71{ 72 linker_class_t lc; 73 74 lc = malloc(sizeof(struct linker_class), M_LINKER, M_NOWAIT); 75 if (!lc) 76 return ENOMEM; | 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> --- 34 unchanged lines hidden (view full) --- 69linker_add_class(const char* desc, void* priv, 70 struct linker_class_ops* ops) 71{ 72 linker_class_t lc; 73 74 lc = malloc(sizeof(struct linker_class), M_LINKER, M_NOWAIT); 75 if (!lc) 76 return ENOMEM; |
77 bzero(lc, sizeof(*lc)); |
|
77 78 lc->desc = desc; 79 lc->priv = priv; 80 lc->ops = ops; 81 TAILQ_INSERT_HEAD(&classes, lc, link); 82 83 return 0; 84} --- 162 unchanged lines hidden (view full) --- 247 filename = pathname; 248 249 KLD_DPF(FILE, ("linker_make_file: new file, filename=%s\n", filename)); 250 lockmgr(&lock, LK_EXCLUSIVE|LK_RETRY, 0, curproc); 251 namelen = strlen(filename) + 1; 252 lf = malloc(sizeof(struct linker_file) + namelen, M_LINKER, M_WAITOK); 253 if (!lf) 254 goto out; | 78 79 lc->desc = desc; 80 lc->priv = priv; 81 lc->ops = ops; 82 TAILQ_INSERT_HEAD(&classes, lc, link); 83 84 return 0; 85} --- 162 unchanged lines hidden (view full) --- 248 filename = pathname; 249 250 KLD_DPF(FILE, ("linker_make_file: new file, filename=%s\n", filename)); 251 lockmgr(&lock, LK_EXCLUSIVE|LK_RETRY, 0, curproc); 252 namelen = strlen(filename) + 1; 253 lf = malloc(sizeof(struct linker_file) + namelen, M_LINKER, M_WAITOK); 254 if (!lf) 255 goto out; |
256 bzero(lf, sizeof(*lf)); |
|
255 256 lf->refs = 1; 257 lf->userrefs = 0; 258 lf->filename = (char*) (lf + 1); 259 strcpy(lf->filename, filename); 260 lf->id = next_file_id++; 261 lf->ndeps = 0; 262 lf->deps = NULL; --- 71 unchanged lines hidden (view full) --- 334linker_file_add_dependancy(linker_file_t file, linker_file_t dep) 335{ 336 linker_file_t* newdeps; 337 338 newdeps = malloc((file->ndeps + 1) * sizeof(linker_file_t*), 339 M_LINKER, M_WAITOK); 340 if (newdeps == NULL) 341 return ENOMEM; | 257 258 lf->refs = 1; 259 lf->userrefs = 0; 260 lf->filename = (char*) (lf + 1); 261 strcpy(lf->filename, filename); 262 lf->id = next_file_id++; 263 lf->ndeps = 0; 264 lf->deps = NULL; --- 71 unchanged lines hidden (view full) --- 336linker_file_add_dependancy(linker_file_t file, linker_file_t dep) 337{ 338 linker_file_t* newdeps; 339 340 newdeps = malloc((file->ndeps + 1) * sizeof(linker_file_t*), 341 M_LINKER, M_WAITOK); 342 if (newdeps == NULL) 343 return ENOMEM; |
344 bzero(newdeps, (file->ndeps + 1) * sizeof(linker_file_t*)); |
|
342 343 if (file->deps) { 344 bcopy(file->deps, newdeps, file->ndeps * sizeof(linker_file_t*)); 345 free(file->deps, M_LINKER); 346 } 347 file->deps = newdeps; 348 file->deps[file->ndeps] = dep; 349 file->ndeps++; --- 58 unchanged lines hidden (view full) --- 408 cp = malloc(sizeof(struct common_symbol) 409 + common_size 410 + strlen(name) + 1, 411 M_LINKER, M_WAITOK); 412 if (!cp) { 413 KLD_DPF(SYM, ("linker_file_lookup_symbol: nomem\n")); 414 return 0; 415 } | 345 346 if (file->deps) { 347 bcopy(file->deps, newdeps, file->ndeps * sizeof(linker_file_t*)); 348 free(file->deps, M_LINKER); 349 } 350 file->deps = newdeps; 351 file->deps[file->ndeps] = dep; 352 file->ndeps++; --- 58 unchanged lines hidden (view full) --- 411 cp = malloc(sizeof(struct common_symbol) 412 + common_size 413 + strlen(name) + 1, 414 M_LINKER, M_WAITOK); 415 if (!cp) { 416 KLD_DPF(SYM, ("linker_file_lookup_symbol: nomem\n")); 417 return 0; 418 } |
419 bzero(cp, sizeof(struct common_symbol) + common_size + strlen(name)+ 1); |
|
416 417 cp->address = (caddr_t) (cp + 1); 418 cp->name = cp->address + common_size; 419 strcpy(cp->name, name); 420 bzero(cp->address, common_size); 421 STAILQ_INSERT_TAIL(&file->common, cp, link); 422 423 KLD_DPF(SYM, ("linker_file_lookup_symbol: new common value=%x\n", cp->address)); --- 309 unchanged lines hidden (view full) --- 733 for (sipp = (struct sysinit **)sysinits->ls_items; *sipp; sipp++) { 734 if ((*sipp)->func == module_register_init) { 735 moddata = (*sipp)->udata; 736 moddata->_file = lf; 737 } 738 } 739 sysinit_add((struct sysinit **)sysinits->ls_items); 740 } | 420 421 cp->address = (caddr_t) (cp + 1); 422 cp->name = cp->address + common_size; 423 strcpy(cp->name, name); 424 bzero(cp->address, common_size); 425 STAILQ_INSERT_TAIL(&file->common, cp, link); 426 427 KLD_DPF(SYM, ("linker_file_lookup_symbol: new common value=%x\n", cp->address)); --- 309 unchanged lines hidden (view full) --- 737 for (sipp = (struct sysinit **)sysinits->ls_items; *sipp; sipp++) { 738 if ((*sipp)->func == module_register_init) { 739 moddata = (*sipp)->udata; 740 moddata->_file = lf; 741 } 742 } 743 sysinit_add((struct sysinit **)sysinits->ls_items); 744 } |
741 742 break; | |
743 } 744 } 745} 746 747SYSINIT(preload, SI_SUB_KLD, SI_ORDER_MIDDLE, linker_preload, 0); 748 749/* 750 * Search for a not-loaded module by name. --- 76 unchanged lines hidden --- | 745 } 746 } 747} 748 749SYSINIT(preload, SI_SUB_KLD, SI_ORDER_MIDDLE, linker_preload, 0); 750 751/* 752 * Search for a not-loaded module by name. --- 76 unchanged lines hidden --- |