Deleted Added
full compact
kern_linker.c (254309) kern_linker.c (254396)
1/*-
2 * Copyright (c) 1997-2000 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

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

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
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1997-2000 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

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

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
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/kern/kern_linker.c 254309 2013-08-14 00:42:21Z markj $");
28__FBSDID("$FreeBSD: head/sys/kern/kern_linker.c 254396 2013-08-16 03:41:41Z markj $");
29
30#include "opt_ddb.h"
31#include "opt_kld.h"
32#include "opt_hwpmc_hooks.h"
33
34#include <sys/param.h>
35#include <sys/kernel.h>
36#include <sys/systm.h>

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

148 linker_file_t dep);
149static caddr_t linker_file_lookup_symbol_internal(linker_file_t file,
150 const char* name, int deps);
151static int linker_load_module(const char *kldname,
152 const char *modname, struct linker_file *parent,
153 struct mod_depend *verinfo, struct linker_file **lfpp);
154static modlist_t modlist_lookup2(const char *name, struct mod_depend *verinfo);
155
29
30#include "opt_ddb.h"
31#include "opt_kld.h"
32#include "opt_hwpmc_hooks.h"
33
34#include <sys/param.h>
35#include <sys/kernel.h>
36#include <sys/systm.h>

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

148 linker_file_t dep);
149static caddr_t linker_file_lookup_symbol_internal(linker_file_t file,
150 const char* name, int deps);
151static int linker_load_module(const char *kldname,
152 const char *modname, struct linker_file *parent,
153 struct mod_depend *verinfo, struct linker_file **lfpp);
154static modlist_t modlist_lookup2(const char *name, struct mod_depend *verinfo);
155
156static char *
157linker_strdup(const char *str)
158{
159 char *result;
160
161 if ((result = malloc((strlen(str) + 1), M_LINKER, M_WAITOK)) != NULL)
162 strcpy(result, str);
163 return (result);
164}
165
166static void
167linker_init(void *arg)
168{
169
170 sx_init(&kld_sx, "kernel linker");
171 TAILQ_INIT(&classes);
172 TAILQ_INIT(&linker_files);
173}

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

572
573 KLD_DPF(FILE, ("linker_make_file: new file, filename='%s' for pathname='%s'\n", filename, pathname));
574 lf = (linker_file_t)kobj_create((kobj_class_t)lc, M_LINKER, M_WAITOK);
575 if (lf == NULL)
576 return (NULL);
577 lf->refs = 1;
578 lf->userrefs = 0;
579 lf->flags = 0;
156static void
157linker_init(void *arg)
158{
159
160 sx_init(&kld_sx, "kernel linker");
161 TAILQ_INIT(&classes);
162 TAILQ_INIT(&linker_files);
163}

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

562
563 KLD_DPF(FILE, ("linker_make_file: new file, filename='%s' for pathname='%s'\n", filename, pathname));
564 lf = (linker_file_t)kobj_create((kobj_class_t)lc, M_LINKER, M_WAITOK);
565 if (lf == NULL)
566 return (NULL);
567 lf->refs = 1;
568 lf->userrefs = 0;
569 lf->flags = 0;
580 lf->filename = linker_strdup(filename);
581 lf->pathname = linker_strdup(pathname);
570 lf->filename = strdup(filename, M_LINKER);
571 lf->pathname = strdup(pathname, M_LINKER);
582 LINKER_GET_NEXT_FILE_ID(lf->id);
583 lf->ndeps = 0;
584 lf->deps = NULL;
585 lf->loadcnt = ++loadcnt;
586 STAILQ_INIT(&lf->common);
587 TAILQ_INIT(&lf->modules);
588 TAILQ_INSERT_TAIL(&linker_files, lf, link);
589 return (lf);

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

1913static char *
1914linker_search_kld(const char *name)
1915{
1916 char *cp, *ep, *result;
1917 int len;
1918
1919 /* qualified at all? */
1920 if (strchr(name, '/'))
572 LINKER_GET_NEXT_FILE_ID(lf->id);
573 lf->ndeps = 0;
574 lf->deps = NULL;
575 lf->loadcnt = ++loadcnt;
576 STAILQ_INIT(&lf->common);
577 TAILQ_INIT(&lf->modules);
578 TAILQ_INSERT_TAIL(&linker_files, lf, link);
579 return (lf);

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

1903static char *
1904linker_search_kld(const char *name)
1905{
1906 char *cp, *ep, *result;
1907 int len;
1908
1909 /* qualified at all? */
1910 if (strchr(name, '/'))
1921 return (linker_strdup(name));
1911 return (strdup(name, M_LINKER));
1922
1923 /* traverse the linker path */
1924 len = strlen(name);
1925 for (ep = linker_path; *ep; ep++) {
1926 cp = ep;
1927 /* find the end of this component */
1928 for (; *ep != 0 && *ep != ';'; ep++);
1929 result = linker_lookup_file(cp, ep - cp, name, len, NULL);

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

2006 */
2007 KASSERT(verinfo == NULL, ("linker_load_module: verinfo"
2008 " is not NULL"));
2009 pathname = linker_search_kld(kldname);
2010 } else {
2011 if (modlist_lookup2(modname, verinfo) != NULL)
2012 return (EEXIST);
2013 if (kldname != NULL)
1912
1913 /* traverse the linker path */
1914 len = strlen(name);
1915 for (ep = linker_path; *ep; ep++) {
1916 cp = ep;
1917 /* find the end of this component */
1918 for (; *ep != 0 && *ep != ';'; ep++);
1919 result = linker_lookup_file(cp, ep - cp, name, len, NULL);

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

1996 */
1997 KASSERT(verinfo == NULL, ("linker_load_module: verinfo"
1998 " is not NULL"));
1999 pathname = linker_search_kld(kldname);
2000 } else {
2001 if (modlist_lookup2(modname, verinfo) != NULL)
2002 return (EEXIST);
2003 if (kldname != NULL)
2014 pathname = linker_strdup(kldname);
2004 pathname = strdup(kldname, M_LINKER);
2015 else if (rootvnode == NULL)
2016 pathname = NULL;
2017 else
2018 /*
2019 * Need to find a KLD with required module
2020 */
2021 pathname = linker_search_module(modname,
2022 strlen(modname), verinfo);

--- 160 unchanged lines hidden ---
2005 else if (rootvnode == NULL)
2006 pathname = NULL;
2007 else
2008 /*
2009 * Need to find a KLD with required module
2010 */
2011 pathname = linker_search_module(modname,
2012 strlen(modname), verinfo);

--- 160 unchanged lines hidden ---