\hypertarget{ksyms_8c_source}{}\doxysection{ksyms.\+c}
\label{ksyms_8c_source}\index{dev/ksyms/ksyms.c@{dev/ksyms/ksyms.c}}
\mbox{\hyperlink{ksyms_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00002}00002 \textcolor{comment}{ * SPDX-\/License-\/Identifier: BSD-\/2-\/Clause-\/FreeBSD}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00003}00003 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00004}00004 \textcolor{comment}{ * Copyright (c) 2008-\/2009, Stacey Son <sson@freebsd.org>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00005}00005 \textcolor{comment}{ * All rights reserved.}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00006}00006 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00007}00007 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00008}00008 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00009}00009 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00010}00010 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00011}00011 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00012}00012 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00013}00013 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00014}00014 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00015}00015 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00016}00016 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00017}00017 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00018}00018 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00019}00019 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00020}00020 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00021}00021 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00022}00022 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00023}00023 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00024}00024 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00025}00025 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00026}00026 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00027}00027 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00028}00028 \textcolor{comment}{ * \$FreeBSD\$}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00029}00029 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00030}00030 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00031}00031 \textcolor{preprocessor}{\#include <sys/param.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00032}00032 \textcolor{preprocessor}{\#include <sys/systm.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00033}00033 \textcolor{preprocessor}{\#include <sys/kernel.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00034}00034 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00035}00035 \textcolor{preprocessor}{\#include <sys/conf.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00036}00036 \textcolor{preprocessor}{\#include <sys/elf.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00037}00037 \textcolor{preprocessor}{\#include <sys/linker.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00038}00038 \textcolor{preprocessor}{\#include <sys/malloc.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00039}00039 \textcolor{preprocessor}{\#include <sys/mman.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00040}00040 \textcolor{preprocessor}{\#include <sys/module.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00041}00041 \textcolor{preprocessor}{\#include <sys/proc.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00042}00042 \textcolor{preprocessor}{\#include <sys/queue.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00043}00043 \textcolor{preprocessor}{\#include <sys/resourcevar.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00044}00044 \textcolor{preprocessor}{\#include <sys/rwlock.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00045}00045 \textcolor{preprocessor}{\#include <sys/stat.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00046}00046 \textcolor{preprocessor}{\#include <sys/sx.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00047}00047 \textcolor{preprocessor}{\#include <sys/uio.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00048}00048 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00049}00049 \textcolor{preprocessor}{\#include <machine/elf.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00050}00050 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00051}00051 \textcolor{preprocessor}{\#include <vm/pmap.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00052}00052 \textcolor{preprocessor}{\#include <vm/vm.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00053}00053 \textcolor{preprocessor}{\#include <vm/vm\_extern.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00054}00054 \textcolor{preprocessor}{\#include <vm/vm\_object.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00055}00055 \textcolor{preprocessor}{\#include <vm/vm\_page.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00056}00056 \textcolor{preprocessor}{\#include <vm/vm\_pager.h>}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00057}00057 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00058}00058 \textcolor{preprocessor}{\#include "{}linker\_if.h"{}}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00059}00059 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00060}\mbox{\hyperlink{ksyms_8c_a488960ebebf650a6ea2120c4dcc03721}{00060}} \textcolor{preprocessor}{\#define SHDR\_NULL       0}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00061}\mbox{\hyperlink{ksyms_8c_a44436099ccc43197ebb672795354730a}{00061}} \textcolor{preprocessor}{\#define SHDR\_SYMTAB     1}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00062}\mbox{\hyperlink{ksyms_8c_a5d1652d049d3c8602576650fbdb3e46d}{00062}} \textcolor{preprocessor}{\#define SHDR\_STRTAB     2}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00063}\mbox{\hyperlink{ksyms_8c_a3625573cb3ea84238c6555f01bba257a}{00063}} \textcolor{preprocessor}{\#define SHDR\_SHSTRTAB   3}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00064}00064 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00065}\mbox{\hyperlink{ksyms_8c_a92d0995ea16f12a7ff23bfd042133168}{00065}} \textcolor{preprocessor}{\#define SHDR\_NUM        4}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00066}00066 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00067}\mbox{\hyperlink{ksyms_8c_a743b5ba54404b915b087c071646efb87}{00067}} \textcolor{preprocessor}{\#define STR\_SYMTAB      "{}.symtab"{}}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00068}\mbox{\hyperlink{ksyms_8c_aa227bcd708d88dbff34fb9a9af7cfa8f}{00068}} \textcolor{preprocessor}{\#define STR\_STRTAB      "{}.strtab"{}}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00069}\mbox{\hyperlink{ksyms_8c_a7022eab35141815969148eb4b31fda96}{00069}} \textcolor{preprocessor}{\#define STR\_SHSTRTAB    "{}.shstrtab"{}}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00070}00070 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00071}\mbox{\hyperlink{ksyms_8c_a311294fc75aea893714df862b9d15a01}{00071}} \textcolor{preprocessor}{\#define KSYMS\_DNAME     "{}ksyms"{}}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00072}00072 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00073}\mbox{\hyperlink{ksyms_8c_a38df1d09d72ea2990aa5f96f4c13becb}{00073}} \textcolor{keyword}{static} d\_open\_t \mbox{\hyperlink{ksyms_8c_a38df1d09d72ea2990aa5f96f4c13becb}{ksyms\_open}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00074}\mbox{\hyperlink{ksyms_8c_a352c85a1fb48d45def5b583ec252b1a3}{00074}} \textcolor{keyword}{static} d\_read\_t \mbox{\hyperlink{ksyms_8c_a352c85a1fb48d45def5b583ec252b1a3}{ksyms\_read}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00075}\mbox{\hyperlink{ksyms_8c_a2407cc956af431a8c3140b7218b87ea8}{00075}} \textcolor{keyword}{static} d\_mmap\_single\_t \mbox{\hyperlink{ksyms_8c_a2407cc956af431a8c3140b7218b87ea8}{ksyms\_mmap\_single}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00076}00076 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00077}\mbox{\hyperlink{ksyms_8c_a9f7c9d53caa2b3f4cad8f8d44cc64326}{00077}} \textcolor{keyword}{static} \textcolor{keyword}{struct }cdevsw \mbox{\hyperlink{ksyms_8c_a9f7c9d53caa2b3f4cad8f8d44cc64326}{ksyms\_cdevsw}} = \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00078}00078         .d\_version =    D\_VERSION,}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00079}00079         .d\_flags =      0,}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00080}00080         .d\_open =       \mbox{\hyperlink{ksyms_8c_a38df1d09d72ea2990aa5f96f4c13becb}{ksyms\_open}},}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00081}00081         .d\_read =       \mbox{\hyperlink{ksyms_8c_a352c85a1fb48d45def5b583ec252b1a3}{ksyms\_read}},}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00082}00082         .d\_mmap\_single = \mbox{\hyperlink{ksyms_8c_a2407cc956af431a8c3140b7218b87ea8}{ksyms\_mmap\_single}},}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00083}00083         .d\_name =       \mbox{\hyperlink{ksyms_8c_a311294fc75aea893714df862b9d15a01}{KSYMS\_DNAME}}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00084}00084 \};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00085}00085 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00086}\mbox{\hyperlink{structksyms__softc}{00086}} \textcolor{keyword}{struct }\mbox{\hyperlink{structksyms__softc}{ksyms\_softc}} \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00087}00087         LIST\_ENTRY(\mbox{\hyperlink{structksyms__softc}{ksyms\_softc}})      sc\_list;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00088}00088         vm\_offset\_t             sc\_uaddr;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00089}00089         \textcolor{keywordtype}{size\_t}                  sc\_usize;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00090}00090         vm\_object\_t             sc\_obj;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00091}00091         vm\_size\_t               sc\_objsz;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00092}00092         \textcolor{keyword}{struct }proc            *sc\_proc;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00093}00093 \};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00094}00094 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00095}\mbox{\hyperlink{ksyms_8c_adb4fe232018b800375fa1844a19c08f4}{00095}} \textcolor{keyword}{static} \textcolor{keyword}{struct }sx                 \mbox{\hyperlink{ksyms_8c_adb4fe232018b800375fa1844a19c08f4}{ksyms\_mtx}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00096}\mbox{\hyperlink{ksyms_8c_a5c6c59b372356c449f732aad55f9115a}{00096}} \textcolor{keyword}{static} \textcolor{keyword}{struct }cdev              *\mbox{\hyperlink{ksyms_8c_a5c6c59b372356c449f732aad55f9115a}{ksyms\_dev}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00097}\mbox{\hyperlink{ksyms_8c_a68942371126d0a523177fd33ab9ec949}{00097}} \textcolor{keyword}{static} \mbox{\hyperlink{ksyms_8c_a68942371126d0a523177fd33ab9ec949}{LIST\_HEAD}}(, \mbox{\hyperlink{structksyms__softc}{ksyms\_softc}})      ksyms\_list = LIST\_HEAD\_INITIALIZER(ksyms\_list);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00098}00098 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00099}00099 \textcolor{keyword}{static} \textcolor{keyword}{const} \textcolor{keywordtype}{char}       ksyms\_shstrtab[] =}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00100}00100         \textcolor{stringliteral}{"{}\(\backslash\)0"{}} \mbox{\hyperlink{ksyms_8c_a743b5ba54404b915b087c071646efb87}{STR\_SYMTAB}} \textcolor{stringliteral}{"{}\(\backslash\)0"{}} \mbox{\hyperlink{ksyms_8c_aa227bcd708d88dbff34fb9a9af7cfa8f}{STR\_STRTAB}} \textcolor{stringliteral}{"{}\(\backslash\)0"{}} \mbox{\hyperlink{ksyms_8c_a7022eab35141815969148eb4b31fda96}{STR\_SHSTRTAB}} \textcolor{stringliteral}{"{}\(\backslash\)0"{}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00101}00101 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00102}00102 \textcolor{keyword}{struct }ksyms\_hdr \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00103}00103         Elf\_Ehdr        kh\_ehdr;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00104}00104         Elf\_Phdr        kh\_txtphdr;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00105}00105         Elf\_Phdr        kh\_datphdr;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00106}00106         Elf\_Shdr        kh\_shdr[\mbox{\hyperlink{ksyms_8c_a92d0995ea16f12a7ff23bfd042133168}{SHDR\_NUM}}];}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00107}00107         \textcolor{keywordtype}{char}            kh\_shstrtab[\textcolor{keyword}{sizeof}(ksyms\_shstrtab)];}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00108}00108 \};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00109}00109 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00110}\mbox{\hyperlink{structtsizes}{00110}} \textcolor{keyword}{struct }\mbox{\hyperlink{structtsizes}{tsizes}} \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00111}\mbox{\hyperlink{structtsizes_a9d64d2be370384cd9adb408f32d7442d}{00111}}         \textcolor{keywordtype}{size\_t}          \mbox{\hyperlink{structtsizes_a9d64d2be370384cd9adb408f32d7442d}{ts\_symsz}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00112}\mbox{\hyperlink{structtsizes_ac145f84d05aa0c732b27498222b5024a}{00112}}         \textcolor{keywordtype}{size\_t}          \mbox{\hyperlink{structtsizes_ac145f84d05aa0c732b27498222b5024a}{ts\_strsz}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00113}00113 \};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00114}00114 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00115}\mbox{\hyperlink{structtoffsets}{00115}} \textcolor{keyword}{struct }\mbox{\hyperlink{structtoffsets}{toffsets}} \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00116}\mbox{\hyperlink{structtoffsets_a9f5a9b67405308de8ce60f685783eb02}{00116}}         \textcolor{keyword}{struct }\mbox{\hyperlink{structksyms__softc}{ksyms\_softc}} *\mbox{\hyperlink{structtoffsets_a9f5a9b67405308de8ce60f685783eb02}{to\_sc}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00117}\mbox{\hyperlink{structtoffsets_a90d6aa3ff60091450c88ff2a01b63201}{00117}}         vm\_offset\_t     \mbox{\hyperlink{structtoffsets_a90d6aa3ff60091450c88ff2a01b63201}{to\_symoff}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00118}\mbox{\hyperlink{structtoffsets_ad80d9ceeb7f4b11786920b05b8a158c3}{00118}}         vm\_offset\_t     \mbox{\hyperlink{structtoffsets_ad80d9ceeb7f4b11786920b05b8a158c3}{to\_stroff}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00119}\mbox{\hyperlink{structtoffsets_a6980c14209f6236773da134d820e303b}{00119}}         \textcolor{keywordtype}{unsigned}        \mbox{\hyperlink{structtoffsets_a6980c14209f6236773da134d820e303b}{to\_stridx}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00120}\mbox{\hyperlink{structtoffsets_a1aae4dcacaca51d776dcbbeabf916f1e}{00120}}         \textcolor{keywordtype}{size\_t}          \mbox{\hyperlink{structtoffsets_a1aae4dcacaca51d776dcbbeabf916f1e}{to\_resid}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00121}00121 \};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00122}00122 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00123}\mbox{\hyperlink{ksyms_8c_a6430c5df0a31ff452d98a2879cc8a6d0}{00123}} \textcolor{keyword}{static} \mbox{\hyperlink{ksyms_8c_a6430c5df0a31ff452d98a2879cc8a6d0}{MALLOC\_DEFINE}}(M\_KSYMS, \textcolor{stringliteral}{"{}KSYMS"{}}, \textcolor{stringliteral}{"{}Kernel Symbol Table"{}});}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00124}00124 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00125}00125 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00126}00126 \textcolor{comment}{ * Get the symbol and string table sizes for a kernel module. Add it to the}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00127}00127 \textcolor{comment}{ * running total.}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00128}00128 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00129}00129 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00130}\mbox{\hyperlink{ksyms_8c_a50161b9935d884911a9fa6189168a0ea}{00130}} \mbox{\hyperlink{ksyms_8c_a50161b9935d884911a9fa6189168a0ea}{ksyms\_size\_permod}}(linker\_file\_t lf, \textcolor{keywordtype}{void} *arg)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00131}00131 \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00132}00132         \textcolor{keyword}{struct }\mbox{\hyperlink{structtsizes}{tsizes}} *ts;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00133}00133         \textcolor{keyword}{const} Elf\_Sym *symtab;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00134}00134         caddr\_t strtab;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00135}00135         \textcolor{keywordtype}{long} syms;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00136}00136 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00137}00137         ts = arg;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00138}00138 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00139}00139         syms = LINKER\_SYMTAB\_GET(lf, \&symtab);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00140}00140         ts-\/>\mbox{\hyperlink{structtsizes_a9d64d2be370384cd9adb408f32d7442d}{ts\_symsz}} += syms * \textcolor{keyword}{sizeof}(Elf\_Sym);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00141}00141         ts-\/>\mbox{\hyperlink{structtsizes_ac145f84d05aa0c732b27498222b5024a}{ts\_strsz}} += LINKER\_STRTAB\_GET(lf, \&strtab);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00142}00142 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00143}00143         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00144}00144 \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00145}00145 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00146}00146 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00147}00147 \textcolor{comment}{ * For kernel module get the symbol and string table sizes, returning the}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00148}00148 \textcolor{comment}{ * totals in *ts.}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00149}00149 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00150}00150 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00151}\mbox{\hyperlink{ksyms_8c_a48f09a20a9b9b0284c95b8301f4ed69a}{00151}} \mbox{\hyperlink{ksyms_8c_a48f09a20a9b9b0284c95b8301f4ed69a}{ksyms\_size\_calc}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structtsizes}{tsizes}} *ts)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00152}00152 \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00153}00153 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00154}00154         ts-\/>\mbox{\hyperlink{structtsizes_a9d64d2be370384cd9adb408f32d7442d}{ts\_symsz}} = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00155}00155         ts-\/>\mbox{\hyperlink{structtsizes_ac145f84d05aa0c732b27498222b5024a}{ts\_strsz}} = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00156}00156 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00157}00157         (void)linker\_file\_foreach(\mbox{\hyperlink{ksyms_8c_a50161b9935d884911a9fa6189168a0ea}{ksyms\_size\_permod}}, ts);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00158}00158 \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00159}00159 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00160}00160 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00161}\mbox{\hyperlink{ksyms_8c_a6c4efe230730b4d3a9c21feb0933f04a}{00161}} \mbox{\hyperlink{ksyms_8c_a6c4efe230730b4d3a9c21feb0933f04a}{ksyms\_emit}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structksyms__softc}{ksyms\_softc}} *sc, \textcolor{keywordtype}{void} *buf, off\_t off, \textcolor{keywordtype}{size\_t} sz)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00162}00162 \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00163}00163         \textcolor{keyword}{struct }iovec iov;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00164}00164         \textcolor{keyword}{struct }uio uio;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00165}00165 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00166}00166         iov.iov\_base = buf;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00167}00167         iov.iov\_len = sz;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00168}00168         uio.uio\_iov = \&iov;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00169}00169         uio.uio\_iovcnt = 1;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00170}00170         uio.uio\_offset = off;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00171}00171         uio.uio\_resid = (ssize\_t)sz;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00172}00172         uio.uio\_segflg = UIO\_SYSSPACE;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00173}00173         uio.uio\_rw = UIO\_WRITE;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00174}00174         uio.uio\_td = curthread;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00175}00175 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00176}00176         \textcolor{keywordflow}{return} (uiomove\_object(sc-\/>sc\_obj, sc-\/>sc\_objsz, \&uio));}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00177}00177 \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00178}00178 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00179}\mbox{\hyperlink{ksyms_8c_a3df651ccc776d2d05b433017efa6bc8d}{00179}} \textcolor{preprocessor}{\#define SYMBLKSZ        (256 * sizeof(Elf\_Sym))}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00180}00180 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00181}00181 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00182}00182 \textcolor{comment}{ * For a kernel module, add the symbol and string tables into the}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00183}00183 \textcolor{comment}{ * snapshot buffer.  Fix up the offsets in the tables.}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00184}00184 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00185}00185 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00186}\mbox{\hyperlink{ksyms_8c_a02789ca4feeacaee79b97d276ed6a0a5}{00186}} \mbox{\hyperlink{ksyms_8c_a02789ca4feeacaee79b97d276ed6a0a5}{ksyms\_add}}(linker\_file\_t lf, \textcolor{keywordtype}{void} *arg)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00187}00187 \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00188}00188         \textcolor{keywordtype}{char} *buf;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00189}00189         \textcolor{keyword}{struct }\mbox{\hyperlink{structksyms__softc}{ksyms\_softc}} *sc;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00190}00190         \textcolor{keyword}{struct }\mbox{\hyperlink{structtoffsets}{toffsets}} *to;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00191}00191         \textcolor{keyword}{const} Elf\_Sym *symtab;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00192}00192         Elf\_Sym *symp;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00193}00193         caddr\_t strtab;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00194}00194         \textcolor{keywordtype}{size\_t} len, numsyms, strsz, symsz;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00195}00195         linker\_symval\_t symval;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00196}00196         \textcolor{keywordtype}{int} error, i, nsyms;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00197}00197         \textcolor{keywordtype}{bool} fixup;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00198}00198 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00199}00199         buf = malloc(\mbox{\hyperlink{ksyms_8c_a3df651ccc776d2d05b433017efa6bc8d}{SYMBLKSZ}}, M\_KSYMS, M\_WAITOK);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00200}00200         to = arg;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00201}00201         sc = to-\/>\mbox{\hyperlink{structtoffsets_a9f5a9b67405308de8ce60f685783eb02}{to\_sc}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00202}00202 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00203}00203         MOD\_SLOCK;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00204}00204         numsyms =  LINKER\_SYMTAB\_GET(lf, \&symtab);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00205}00205         strsz = LINKER\_STRTAB\_GET(lf, \&strtab);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00206}00206         symsz = numsyms * \textcolor{keyword}{sizeof}(Elf\_Sym);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00207}00207 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00208}00208 \textcolor{preprocessor}{\#ifdef RELOCATABLE\_KERNEL}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00209}00209         fixup = \textcolor{keyword}{true};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00210}00210 \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00211}00211         fixup = lf-\/>id > 1;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00212}00212 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00213}00213 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00214}00214         \textcolor{keywordflow}{while} (symsz > 0) \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00215}00215                 len = min(\mbox{\hyperlink{ksyms_8c_a3df651ccc776d2d05b433017efa6bc8d}{SYMBLKSZ}}, symsz);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00216}00216                 bcopy(symtab, buf, len);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00217}00217 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00218}00218                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00219}00219 \textcolor{comment}{                 * Fix up symbol table for kernel modules:}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00220}00220 \textcolor{comment}{                 *   string offsets need adjusted}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00221}00221 \textcolor{comment}{                 *   symbol values made absolute}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00222}00222 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00223}00223                 symp = (Elf\_Sym *) buf;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00224}00224                 nsyms = len / \textcolor{keyword}{sizeof}(Elf\_Sym);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00225}00225                 \textcolor{keywordflow}{for} (i = 0; i < nsyms; i++) \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00226}00226                         symp[i].st\_name += to-\/>\mbox{\hyperlink{structtoffsets_a6980c14209f6236773da134d820e303b}{to\_stridx}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00227}00227                         \textcolor{keywordflow}{if} (fixup \&\& LINKER\_SYMBOL\_VALUES(lf,}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00228}00228                             (c\_linker\_sym\_t)\&symtab[i], \&symval) == 0) \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00229}00229                                 symp[i].st\_value = (uintptr\_t)symval.value;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00230}00230                         \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00231}00231                 \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00232}00232 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00233}00233                 \textcolor{keywordflow}{if} (len > to-\/>\mbox{\hyperlink{structtoffsets_a1aae4dcacaca51d776dcbbeabf916f1e}{to\_resid}}) \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00234}00234                         MOD\_SUNLOCK;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00235}00235                         free(buf, M\_KSYMS);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00236}00236                         \textcolor{keywordflow}{return} (ENXIO);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00237}00237                 \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00238}00238                 to-\/>\mbox{\hyperlink{structtoffsets_a1aae4dcacaca51d776dcbbeabf916f1e}{to\_resid}} -\/= len;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00239}00239                 error = \mbox{\hyperlink{ksyms_8c_a6c4efe230730b4d3a9c21feb0933f04a}{ksyms\_emit}}(sc, buf, to-\/>\mbox{\hyperlink{structtoffsets_a90d6aa3ff60091450c88ff2a01b63201}{to\_symoff}}, len);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00240}00240                 to-\/>\mbox{\hyperlink{structtoffsets_a90d6aa3ff60091450c88ff2a01b63201}{to\_symoff}} += len;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00241}00241                 \textcolor{keywordflow}{if} (error != 0) \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00242}00242                         MOD\_SUNLOCK;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00243}00243                         free(buf, M\_KSYMS);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00244}00244                         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00245}00245                 \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00246}00246 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00247}00247                 symtab += nsyms;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00248}00248                 symsz -\/= len;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00249}00249         \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00250}00250         free(buf, M\_KSYMS);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00251}00251         MOD\_SUNLOCK;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00252}00252 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00253}00253         \textcolor{keywordflow}{if} (strsz > to-\/>\mbox{\hyperlink{structtoffsets_a1aae4dcacaca51d776dcbbeabf916f1e}{to\_resid}})}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00254}00254                 \textcolor{keywordflow}{return} (ENXIO);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00255}00255         to-\/>\mbox{\hyperlink{structtoffsets_a1aae4dcacaca51d776dcbbeabf916f1e}{to\_resid}} -\/= strsz;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00256}00256         error = \mbox{\hyperlink{ksyms_8c_a6c4efe230730b4d3a9c21feb0933f04a}{ksyms\_emit}}(sc, strtab, to-\/>\mbox{\hyperlink{structtoffsets_ad80d9ceeb7f4b11786920b05b8a158c3}{to\_stroff}}, strsz);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00257}00257         to-\/>\mbox{\hyperlink{structtoffsets_ad80d9ceeb7f4b11786920b05b8a158c3}{to\_stroff}} += strsz;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00258}00258         to-\/>\mbox{\hyperlink{structtoffsets_a6980c14209f6236773da134d820e303b}{to\_stridx}} += strsz;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00259}00259 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00260}00260         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00261}00261 \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00262}00262 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00263}00263 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00264}00264 \textcolor{comment}{ * Create a single ELF symbol table for the kernel and kernel modules loaded}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00265}00265 \textcolor{comment}{ * at this time. Write this snapshot out in the process address space. Return}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00266}00266 \textcolor{comment}{ * 0 on success, otherwise error.}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00267}00267 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00268}00268 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00269}\mbox{\hyperlink{ksyms_8c_ad86d47d7f25b57de815caf35061e1f6e}{00269}} \mbox{\hyperlink{ksyms_8c_ad86d47d7f25b57de815caf35061e1f6e}{ksyms\_snapshot}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structksyms__softc}{ksyms\_softc}} *sc, \textcolor{keyword}{struct} \mbox{\hyperlink{structtsizes}{tsizes}} *ts)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00270}00270 \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00271}00271         \textcolor{keyword}{struct }\mbox{\hyperlink{structtoffsets}{toffsets}} to;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00272}00272         \textcolor{keyword}{struct }ksyms\_hdr *hdr;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00273}00273         \textcolor{keywordtype}{int} error;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00274}00274 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00275}00275         hdr = malloc(\textcolor{keyword}{sizeof}(*hdr), M\_KSYMS, M\_WAITOK | M\_ZERO);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00276}00276 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00277}00277         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00278}00278 \textcolor{comment}{         * Create the ELF header.}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00279}00279 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00280}00280         hdr-\/>kh\_ehdr.e\_ident[EI\_PAD] = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00281}00281         hdr-\/>kh\_ehdr.e\_ident[EI\_MAG0] = ELFMAG0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00282}00282         hdr-\/>kh\_ehdr.e\_ident[EI\_MAG1] = ELFMAG1;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00283}00283         hdr-\/>kh\_ehdr.e\_ident[EI\_MAG2] = ELFMAG2;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00284}00284         hdr-\/>kh\_ehdr.e\_ident[EI\_MAG3] = ELFMAG3;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00285}00285         hdr-\/>kh\_ehdr.e\_ident[EI\_DATA] = ELF\_DATA;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00286}00286         hdr-\/>kh\_ehdr.e\_ident[EI\_OSABI] = ELFOSABI\_FREEBSD;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00287}00287         hdr-\/>kh\_ehdr.e\_ident[EI\_CLASS] = ELF\_CLASS;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00288}00288         hdr-\/>kh\_ehdr.e\_ident[EI\_VERSION] = EV\_CURRENT;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00289}00289         hdr-\/>kh\_ehdr.e\_ident[EI\_ABIVERSION] = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00290}00290         hdr-\/>kh\_ehdr.e\_type = ET\_EXEC;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00291}00291         hdr-\/>kh\_ehdr.e\_machine = ELF\_ARCH;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00292}00292         hdr-\/>kh\_ehdr.e\_version = EV\_CURRENT;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00293}00293         hdr-\/>kh\_ehdr.e\_entry = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00294}00294         hdr-\/>kh\_ehdr.e\_phoff = offsetof(\textcolor{keyword}{struct} ksyms\_hdr, kh\_txtphdr);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00295}00295         hdr-\/>kh\_ehdr.e\_shoff = offsetof(\textcolor{keyword}{struct} ksyms\_hdr, kh\_shdr);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00296}00296         hdr-\/>kh\_ehdr.e\_flags = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00297}00297         hdr-\/>kh\_ehdr.e\_ehsize = \textcolor{keyword}{sizeof}(Elf\_Ehdr);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00298}00298         hdr-\/>kh\_ehdr.e\_phentsize = \textcolor{keyword}{sizeof}(Elf\_Phdr);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00299}00299         hdr-\/>kh\_ehdr.e\_phnum = 2;       \textcolor{comment}{/* Text and Data */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00300}00300         hdr-\/>kh\_ehdr.e\_shentsize = \textcolor{keyword}{sizeof}(Elf\_Shdr);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00301}00301         hdr-\/>kh\_ehdr.e\_shnum = \mbox{\hyperlink{ksyms_8c_a92d0995ea16f12a7ff23bfd042133168}{SHDR\_NUM}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00302}00302         hdr-\/>kh\_ehdr.e\_shstrndx = \mbox{\hyperlink{ksyms_8c_a3625573cb3ea84238c6555f01bba257a}{SHDR\_SHSTRTAB}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00303}00303 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00304}00304         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00305}00305 \textcolor{comment}{         * Add both the text and data program headers.}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00306}00306 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00307}00307         hdr-\/>kh\_txtphdr.p\_type = PT\_LOAD;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00308}00308         \textcolor{comment}{/* XXX -\/ is there a way to put the actual .text addr/size here? */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00309}00309         hdr-\/>kh\_txtphdr.p\_vaddr = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00310}00310         hdr-\/>kh\_txtphdr.p\_memsz = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00311}00311         hdr-\/>kh\_txtphdr.p\_flags = PF\_R | PF\_X;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00312}00312 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00313}00313         hdr-\/>kh\_datphdr.p\_type = PT\_LOAD;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00314}00314         \textcolor{comment}{/* XXX -\/ is there a way to put the actual .data addr/size here? */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00315}00315         hdr-\/>kh\_datphdr.p\_vaddr = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00316}00316         hdr-\/>kh\_datphdr.p\_memsz = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00317}00317         hdr-\/>kh\_datphdr.p\_flags = PF\_R | PF\_W | PF\_X;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00318}00318 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00319}00319         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00320}00320 \textcolor{comment}{         * Add the section headers: null, symtab, strtab, shstrtab.}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00321}00321 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00322}00322 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00323}00323         \textcolor{comment}{/* First section header -\/ null */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00324}00324 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00325}00325         \textcolor{comment}{/* Second section header -\/ symtab */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00326}00326         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a44436099ccc43197ebb672795354730a}{SHDR\_SYMTAB}}].sh\_name = 1; \textcolor{comment}{/* String offset (skip null) */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00327}00327         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a44436099ccc43197ebb672795354730a}{SHDR\_SYMTAB}}].sh\_type = SHT\_SYMTAB;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00328}00328         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a44436099ccc43197ebb672795354730a}{SHDR\_SYMTAB}}].sh\_flags = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00329}00329         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a44436099ccc43197ebb672795354730a}{SHDR\_SYMTAB}}].sh\_addr = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00330}00330         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a44436099ccc43197ebb672795354730a}{SHDR\_SYMTAB}}].sh\_offset = \textcolor{keyword}{sizeof}(*hdr);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00331}00331         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a44436099ccc43197ebb672795354730a}{SHDR\_SYMTAB}}].sh\_size = ts-\/>\mbox{\hyperlink{structtsizes_a9d64d2be370384cd9adb408f32d7442d}{ts\_symsz}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00332}00332         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a44436099ccc43197ebb672795354730a}{SHDR\_SYMTAB}}].sh\_link = \mbox{\hyperlink{ksyms_8c_a5d1652d049d3c8602576650fbdb3e46d}{SHDR\_STRTAB}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00333}00333         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a44436099ccc43197ebb672795354730a}{SHDR\_SYMTAB}}].sh\_info = ts-\/>\mbox{\hyperlink{structtsizes_a9d64d2be370384cd9adb408f32d7442d}{ts\_symsz}} / \textcolor{keyword}{sizeof}(Elf\_Sym);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00334}00334         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a44436099ccc43197ebb672795354730a}{SHDR\_SYMTAB}}].sh\_addralign = \textcolor{keyword}{sizeof}(long);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00335}00335         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a44436099ccc43197ebb672795354730a}{SHDR\_SYMTAB}}].sh\_entsize = \textcolor{keyword}{sizeof}(Elf\_Sym);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00336}00336 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00337}00337         \textcolor{comment}{/* Third section header -\/ strtab */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00338}00338         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a5d1652d049d3c8602576650fbdb3e46d}{SHDR\_STRTAB}}].sh\_name = 1 + \textcolor{keyword}{sizeof}(\mbox{\hyperlink{ksyms_8c_a743b5ba54404b915b087c071646efb87}{STR\_SYMTAB}});}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00339}00339         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a5d1652d049d3c8602576650fbdb3e46d}{SHDR\_STRTAB}}].sh\_type = SHT\_STRTAB;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00340}00340         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a5d1652d049d3c8602576650fbdb3e46d}{SHDR\_STRTAB}}].sh\_flags = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00341}00341         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a5d1652d049d3c8602576650fbdb3e46d}{SHDR\_STRTAB}}].sh\_addr = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00342}00342         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a5d1652d049d3c8602576650fbdb3e46d}{SHDR\_STRTAB}}].sh\_offset =}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00343}00343             hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a44436099ccc43197ebb672795354730a}{SHDR\_SYMTAB}}].sh\_offset + ts-\/>\mbox{\hyperlink{structtsizes_a9d64d2be370384cd9adb408f32d7442d}{ts\_symsz}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00344}00344         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a5d1652d049d3c8602576650fbdb3e46d}{SHDR\_STRTAB}}].sh\_size = ts-\/>\mbox{\hyperlink{structtsizes_ac145f84d05aa0c732b27498222b5024a}{ts\_strsz}};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00345}00345         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a5d1652d049d3c8602576650fbdb3e46d}{SHDR\_STRTAB}}].sh\_link = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00346}00346         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a5d1652d049d3c8602576650fbdb3e46d}{SHDR\_STRTAB}}].sh\_info = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00347}00347         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a5d1652d049d3c8602576650fbdb3e46d}{SHDR\_STRTAB}}].sh\_addralign = \textcolor{keyword}{sizeof}(char);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00348}00348         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a5d1652d049d3c8602576650fbdb3e46d}{SHDR\_STRTAB}}].sh\_entsize = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00349}00349 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00350}00350         \textcolor{comment}{/* Fourth section -\/ shstrtab */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00351}00351         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a3625573cb3ea84238c6555f01bba257a}{SHDR\_SHSTRTAB}}].sh\_name = 1 + \textcolor{keyword}{sizeof}(\mbox{\hyperlink{ksyms_8c_a743b5ba54404b915b087c071646efb87}{STR\_SYMTAB}}) +}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00352}00352             \textcolor{keyword}{sizeof}(\mbox{\hyperlink{ksyms_8c_aa227bcd708d88dbff34fb9a9af7cfa8f}{STR\_STRTAB}});}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00353}00353         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a3625573cb3ea84238c6555f01bba257a}{SHDR\_SHSTRTAB}}].sh\_type = SHT\_STRTAB;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00354}00354         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a3625573cb3ea84238c6555f01bba257a}{SHDR\_SHSTRTAB}}].sh\_flags = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00355}00355         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a3625573cb3ea84238c6555f01bba257a}{SHDR\_SHSTRTAB}}].sh\_addr = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00356}00356         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a3625573cb3ea84238c6555f01bba257a}{SHDR\_SHSTRTAB}}].sh\_offset =}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00357}00357             offsetof(\textcolor{keyword}{struct} ksyms\_hdr, kh\_shstrtab);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00358}00358         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a3625573cb3ea84238c6555f01bba257a}{SHDR\_SHSTRTAB}}].sh\_size = \textcolor{keyword}{sizeof}(ksyms\_shstrtab);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00359}00359         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a3625573cb3ea84238c6555f01bba257a}{SHDR\_SHSTRTAB}}].sh\_link = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00360}00360         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a3625573cb3ea84238c6555f01bba257a}{SHDR\_SHSTRTAB}}].sh\_info = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00361}00361         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a3625573cb3ea84238c6555f01bba257a}{SHDR\_SHSTRTAB}}].sh\_addralign = 0 \textcolor{comment}{/* sizeof(char) */};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00362}00362         hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a3625573cb3ea84238c6555f01bba257a}{SHDR\_SHSTRTAB}}].sh\_entsize = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00363}00363 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00364}00364         \textcolor{comment}{/* Copy shstrtab into the header. */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00365}00365         bcopy(ksyms\_shstrtab, hdr-\/>kh\_shstrtab, \textcolor{keyword}{sizeof}(ksyms\_shstrtab));}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00366}00366 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00367}00367         to.\mbox{\hyperlink{structtoffsets_a9f5a9b67405308de8ce60f685783eb02}{to\_sc}} = sc;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00368}00368         to.\mbox{\hyperlink{structtoffsets_a90d6aa3ff60091450c88ff2a01b63201}{to\_symoff}} = hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a44436099ccc43197ebb672795354730a}{SHDR\_SYMTAB}}].sh\_offset;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00369}00369         to.\mbox{\hyperlink{structtoffsets_ad80d9ceeb7f4b11786920b05b8a158c3}{to\_stroff}} = hdr-\/>kh\_shdr[\mbox{\hyperlink{ksyms_8c_a5d1652d049d3c8602576650fbdb3e46d}{SHDR\_STRTAB}}].sh\_offset;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00370}00370         to.\mbox{\hyperlink{structtoffsets_a6980c14209f6236773da134d820e303b}{to\_stridx}} = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00371}00371         to.\mbox{\hyperlink{structtoffsets_a1aae4dcacaca51d776dcbbeabf916f1e}{to\_resid}} = sc-\/>sc\_objsz -\/ \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct }ksyms\_hdr);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00372}00372 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00373}00373         \textcolor{comment}{/* emit header */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00374}00374         error = \mbox{\hyperlink{ksyms_8c_a6c4efe230730b4d3a9c21feb0933f04a}{ksyms\_emit}}(sc, hdr, 0, \textcolor{keyword}{sizeof}(*hdr));}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00375}00375         free(hdr, M\_KSYMS);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00376}00376         \textcolor{keywordflow}{if} (error != 0)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00377}00377                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00378}00378 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00379}00379         \textcolor{comment}{/* Add symbol and string tables for each kernel module. */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00380}00380         error = linker\_file\_foreach(\mbox{\hyperlink{ksyms_8c_a02789ca4feeacaee79b97d276ed6a0a5}{ksyms\_add}}, \&to);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00381}00381         \textcolor{keywordflow}{if} (error != 0)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00382}00382                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00383}00383         \textcolor{keywordflow}{if} (to.\mbox{\hyperlink{structtoffsets_a1aae4dcacaca51d776dcbbeabf916f1e}{to\_resid}} != 0)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00384}00384                 \textcolor{keywordflow}{return} (ENXIO);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00385}00385         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00386}00386 \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00387}00387 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00388}00388 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00389}\mbox{\hyperlink{ksyms_8c_abe6ff1e9bbd3cca5e9001c56a0a6cb9f}{00389}} \mbox{\hyperlink{ksyms_8c_abe6ff1e9bbd3cca5e9001c56a0a6cb9f}{ksyms\_cdevpriv\_dtr}}(\textcolor{keywordtype}{void} *data)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00390}00390 \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00391}00391         \textcolor{keyword}{struct }\mbox{\hyperlink{structksyms__softc}{ksyms\_softc}} *sc;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00392}00392         vm\_object\_t obj;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00393}00393 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00394}00394         sc = (\textcolor{keyword}{struct }\mbox{\hyperlink{structksyms__softc}{ksyms\_softc}} *)data;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00395}00395 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00396}00396         sx\_xlock(\&\mbox{\hyperlink{ksyms_8c_adb4fe232018b800375fa1844a19c08f4}{ksyms\_mtx}});}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00397}00397         LIST\_REMOVE(sc, sc\_list);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00398}00398         sx\_xunlock(\&\mbox{\hyperlink{ksyms_8c_adb4fe232018b800375fa1844a19c08f4}{ksyms\_mtx}});}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00399}00399         obj = sc-\/>sc\_obj;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00400}00400         \textcolor{keywordflow}{if} (obj != NULL)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00401}00401                 vm\_object\_deallocate(obj);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00402}00402         free(sc, M\_KSYMS);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00403}00403 \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00404}00404 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00405}00405 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00406}\mbox{\hyperlink{ksyms_8c_a6d4e8b2da3fd9a745ffd55e75f2c8be0}{00406}} \mbox{\hyperlink{ksyms_8c_a38df1d09d72ea2990aa5f96f4c13becb}{ksyms\_open}}(\textcolor{keyword}{struct} cdev *dev, \textcolor{keywordtype}{int} flags, \textcolor{keywordtype}{int} fmt \_\_unused, \textcolor{keyword}{struct} thread *td)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00407}00407 \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00408}00408         \textcolor{keyword}{struct }\mbox{\hyperlink{structtsizes}{tsizes}} ts;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00409}00409         \textcolor{keyword}{struct }\mbox{\hyperlink{structksyms__softc}{ksyms\_softc}} *sc;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00410}00410         vm\_object\_t object;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00411}00411         vm\_size\_t elfsz;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00412}00412         \textcolor{keywordtype}{int} error, \textcolor{keywordflow}{try};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00413}00413 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00414}00414         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00415}00415 \textcolor{comment}{         * Limit one open() per process. The process must close()}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00416}00416 \textcolor{comment}{         * before open()'ing again.}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00417}00417 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00418}00418         sx\_xlock(\&\mbox{\hyperlink{ksyms_8c_adb4fe232018b800375fa1844a19c08f4}{ksyms\_mtx}});}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00419}00419         LIST\_FOREACH(sc, \&ksyms\_list, sc\_list) \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00420}00420                 \textcolor{keywordflow}{if} (sc-\/>sc\_proc == td-\/>td\_proc) \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00421}00421                         sx\_xunlock(\&\mbox{\hyperlink{ksyms_8c_adb4fe232018b800375fa1844a19c08f4}{ksyms\_mtx}});}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00422}00422                         \textcolor{keywordflow}{return} (EBUSY);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00423}00423                 \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00424}00424         \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00425}00425 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00426}00426         sc = malloc(\textcolor{keyword}{sizeof}(*sc), M\_KSYMS, M\_WAITOK | M\_ZERO);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00427}00427         sc-\/>sc\_proc = td-\/>td\_proc;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00428}00428         LIST\_INSERT\_HEAD(\&ksyms\_list, sc, sc\_list);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00429}00429         sx\_xunlock(\&\mbox{\hyperlink{ksyms_8c_adb4fe232018b800375fa1844a19c08f4}{ksyms\_mtx}});}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00430}00430 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00431}00431         error = devfs\_set\_cdevpriv(sc, \mbox{\hyperlink{ksyms_8c_abe6ff1e9bbd3cca5e9001c56a0a6cb9f}{ksyms\_cdevpriv\_dtr}});}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00432}00432         \textcolor{keywordflow}{if} (error != 0) \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00433}00433                 \mbox{\hyperlink{ksyms_8c_abe6ff1e9bbd3cca5e9001c56a0a6cb9f}{ksyms\_cdevpriv\_dtr}}(sc);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00434}00434                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00435}00435         \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00436}00436 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00437}00437         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00438}00438 \textcolor{comment}{         * MOD\_SLOCK doesn't work here (because of a lock reversal with}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00439}00439 \textcolor{comment}{         * KLD\_SLOCK).  Therefore, simply try up to 3 times to get a "{}clean"{}}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00440}00440 \textcolor{comment}{         * snapshot of the kernel symbol table.  This should work fine in the}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00441}00441 \textcolor{comment}{         * rare case of a kernel module being loaded/unloaded at the same}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00442}00442 \textcolor{comment}{         * time.}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00443}00443 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00444}00444         \textcolor{keywordflow}{for} (\textcolor{keywordflow}{try} = 0; \textcolor{keywordflow}{try} < 3; \textcolor{keywordflow}{try}++) \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00445}00445                 \mbox{\hyperlink{ksyms_8c_a48f09a20a9b9b0284c95b8301f4ed69a}{ksyms\_size\_calc}}(\&ts);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00446}00446                 elfsz = \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct }ksyms\_hdr) + ts.ts\_symsz + ts.ts\_strsz;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00447}00447 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00448}00448                 \textcolor{keywordtype}{object} = vm\_pager\_allocate(OBJT\_PHYS, NULL, round\_page(elfsz),}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00449}00449                     VM\_PROT\_ALL, 0, td-\/>td\_ucred);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00450}00450                 sc-\/>sc\_obj = object;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00451}00451                 sc-\/>sc\_objsz = elfsz;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00452}00452 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00453}00453                 error = \mbox{\hyperlink{ksyms_8c_ad86d47d7f25b57de815caf35061e1f6e}{ksyms\_snapshot}}(sc, \&ts);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00454}00454                 \textcolor{keywordflow}{if} (error == 0)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00455}00455                         \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00456}00456 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00457}00457                 vm\_object\_deallocate(sc-\/>sc\_obj);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00458}00458                 sc-\/>sc\_obj = NULL;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00459}00459         \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00460}00460         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00461}00461 \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00462}00462 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00463}00463 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00464}\mbox{\hyperlink{ksyms_8c_abd9aeb062355da97f62860990c76047c}{00464}} \mbox{\hyperlink{ksyms_8c_a352c85a1fb48d45def5b583ec252b1a3}{ksyms\_read}}(\textcolor{keyword}{struct} cdev *dev, \textcolor{keyword}{struct} uio *uio, \textcolor{keywordtype}{int} flags \_\_unused)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00465}00465 \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00466}00466         \textcolor{keyword}{struct }\mbox{\hyperlink{structksyms__softc}{ksyms\_softc}} *sc;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00467}00467         \textcolor{keywordtype}{int} error;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00468}00468 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00469}00469         error = devfs\_get\_cdevpriv((\textcolor{keywordtype}{void} **)\&sc);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00470}00470         \textcolor{keywordflow}{if} (error != 0)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00471}00471                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00472}00472         \textcolor{keywordflow}{return} (uiomove\_object(sc-\/>sc\_obj, sc-\/>sc\_objsz, uio));}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00473}00473 \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00474}00474 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00475}00475 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00476}\mbox{\hyperlink{ksyms_8c_ad96faa3e0ae34274d32e8e74e9788cc2}{00476}} \mbox{\hyperlink{ksyms_8c_a2407cc956af431a8c3140b7218b87ea8}{ksyms\_mmap\_single}}(\textcolor{keyword}{struct} cdev *dev, vm\_ooffset\_t *offset, vm\_size\_t size,}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00477}00477     vm\_object\_t *objp, \textcolor{keywordtype}{int} nprot)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00478}00478 \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00479}00479         \textcolor{keyword}{struct }\mbox{\hyperlink{structksyms__softc}{ksyms\_softc}} *sc;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00480}00480         vm\_object\_t obj;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00481}00481         \textcolor{keywordtype}{int} error;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00482}00482 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00483}00483         error = devfs\_get\_cdevpriv((\textcolor{keywordtype}{void} **)\&sc);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00484}00484         \textcolor{keywordflow}{if} (error != 0)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00485}00485                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00486}00486 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00487}00487         \textcolor{keywordflow}{if} (*offset >= round\_page(sc-\/>sc\_objsz) ||}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00488}00488             size > round\_page(sc-\/>sc\_objsz) -\/ *offset ||}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00489}00489             (nprot \& \string~PROT\_READ) != 0)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00490}00490                 \textcolor{keywordflow}{return} (EINVAL);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00491}00491 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00492}00492         obj = sc-\/>sc\_obj;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00493}00493         vm\_object\_reference(obj);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00494}00494         *objp = obj;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00495}00495         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00496}00496 \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00497}00497 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00498}00498 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00499}\mbox{\hyperlink{ksyms_8c_a057025e18bee4bb6c1ba1403f3d5e9c7}{00499}} \mbox{\hyperlink{ksyms_8c_a057025e18bee4bb6c1ba1403f3d5e9c7}{ksyms\_modevent}}(module\_t mod \_\_unused, \textcolor{keywordtype}{int} type, \textcolor{keywordtype}{void} *data \_\_unused)}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00500}00500 \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00501}00501         \textcolor{keywordtype}{int} error;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00502}00502 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00503}00503         error = 0;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00504}00504         \textcolor{keywordflow}{switch} (type) \{}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00505}00505         \textcolor{keywordflow}{case} MOD\_LOAD:}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00506}00506                 sx\_init(\&\mbox{\hyperlink{ksyms_8c_adb4fe232018b800375fa1844a19c08f4}{ksyms\_mtx}}, \textcolor{stringliteral}{"{}KSyms mtx"{}});}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00507}00507                 \mbox{\hyperlink{ksyms_8c_a5c6c59b372356c449f732aad55f9115a}{ksyms\_dev}} = make\_dev(\&\mbox{\hyperlink{ksyms_8c_a9f7c9d53caa2b3f4cad8f8d44cc64326}{ksyms\_cdevsw}}, 0, UID\_ROOT, GID\_WHEEL,}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00508}00508                     0400, \mbox{\hyperlink{ksyms_8c_a311294fc75aea893714df862b9d15a01}{KSYMS\_DNAME}});}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00509}00509                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00510}00510         \textcolor{keywordflow}{case} MOD\_UNLOAD:}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00511}00511                 \textcolor{keywordflow}{if} (!LIST\_EMPTY(\&ksyms\_list))}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00512}00512                         \textcolor{keywordflow}{return} (EBUSY);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00513}00513                 destroy\_dev(\mbox{\hyperlink{ksyms_8c_a5c6c59b372356c449f732aad55f9115a}{ksyms\_dev}});}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00514}00514                 sx\_destroy(\&\mbox{\hyperlink{ksyms_8c_adb4fe232018b800375fa1844a19c08f4}{ksyms\_mtx}});}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00515}00515                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00516}00516         \textcolor{keywordflow}{case} MOD\_SHUTDOWN:}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00517}00517                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00518}00518         \textcolor{keywordflow}{default}:}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00519}00519                 error = EOPNOTSUPP;}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00520}00520                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00521}00521         \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00522}00522         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00523}00523 \}}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00524}00524 }
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00525}\mbox{\hyperlink{ksyms_8c_ae923783fe2b11e35d430b4370bb54ac2}{00525}} \mbox{\hyperlink{ksyms_8c_ae923783fe2b11e35d430b4370bb54ac2}{DEV\_MODULE}}(ksyms, \mbox{\hyperlink{ksyms_8c_a057025e18bee4bb6c1ba1403f3d5e9c7}{ksyms\_modevent}}, NULL);}
\DoxyCodeLine{\Hypertarget{ksyms_8c_source_l00526}\mbox{\hyperlink{ksyms_8c_ab9bd7328ea1b156d10f334a896613e3b}{00526}} \mbox{\hyperlink{ksyms_8c_ab9bd7328ea1b156d10f334a896613e3b}{MODULE\_VERSION}}(ksyms, 1);}

\end{DoxyCode}
