FreeBSD kernel kern code
linker_if.m
Go to the documentation of this file.
1 #-
2 # Copyright (c) 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
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 #
14 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
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 # $BSDSUniX$
27 #
28 
29 #include <sys/linker.h>
30 
31 INTERFACE linker;
32 
33 #
34 # Lookup a symbol in the file's symbol table. If the symbol is not
35 # found then return ENOENT, otherwise zero.
36 #
37 METHOD int lookup_symbol {
38  linker_file_t file;
39  const char* name;
40  c_linker_sym_t* symp;
41 };
42 
43 METHOD int symbol_values {
44  linker_file_t file;
45  c_linker_sym_t sym;
46  linker_symval_t* valp;
47 };
48 
49 METHOD int search_symbol {
50  linker_file_t file;
51  caddr_t value;
52  c_linker_sym_t* symp;
53  long* diffp;
54 };
55 
56 #
57 # Call the callback with each specified function defined in the file.
58 # Stop and return the error if the callback returns an error.
59 #
60 METHOD int each_function_name {
61  linker_file_t file;
62  linker_function_name_callback_t callback;
63  void* opaque;
64 };
65 
66 #
67 # Call the callback with each specified function and it's value
68 # defined in the file.
69 # Stop and return the error if the callback returns an error.
70 #
72  linker_file_t file;
73  linker_function_nameval_callback_t callback;
74  void* opaque;
75 };
76 
77 #
78 # Search for a linker set in a file. Return a pointer to the first
79 # entry (which is itself a pointer), and the number of entries.
80 # "stop" points to the entry beyond the last valid entry.
81 # If count, start or stop are NULL, they are not returned.
82 #
83 METHOD int lookup_set {
84  linker_file_t file;
85  const char* name;
86  void*** start;
87  void*** stop;
88  int* count;
89 };
90 
91 #
92 # Unload a file, releasing dependancies and freeing storage.
93 #
94 METHOD void unload {
95  linker_file_t file;
96 };
97 
98 #
99 # Load CTF data if necessary and if there is a .SUNW_ctf section
100 # in the ELF file, returning info in the linker CTF structure.
101 #
102 METHOD int ctf_get {
103  linker_file_t file;
104  linker_ctf_t *lc;
105 };
106 
107 #
108 # Get the symbol table, returning it in **symtab. Return the
109 # number of symbols, otherwise zero.
110 #
111 METHOD long symtab_get {
112  linker_file_t file;
113  const Elf_Sym **symtab;
114 };
115 
116 #
117 # Get the string table, returning it in *strtab. Return the
118 # size (in bytes) of the string table, otherwise zero.
119 #
120 METHOD long strtab_get {
121  linker_file_t file;
122  caddr_t *strtab;
123 };
124 
125 #
126 # Load a file, returning the new linker_file_t in *result. If
127 # the class does not recognise the file type, zero should be
128 # returned, without modifying *result. If the file is
129 # recognised, the file should be loaded, *result set to the new
130 # file and zero returned. If some other error is detected an
131 # appropriate errno should be returned.
132 #
133 STATICMETHOD int load_file {
134  linker_class_t cls;
135  const char* filename;
136  linker_file_t* result;
137 };
138 STATICMETHOD int link_preload {
139  linker_class_t cls;
140  const char* filename;
141  linker_file_t* result;
142 };
144  linker_file_t file;
145 };
METHOD void unload
Definition: linker_if.m:94
long * diffp
Definition: linker_if.m:53
caddr_t value
Definition: linker_if.m:51
METHOD int symbol_values
Definition: linker_if.m:43
void *** start
Definition: linker_if.m:86
const char * filename
Definition: linker_if.m:135
METHOD int each_function_nameval
Definition: linker_if.m:71
METHOD int lookup_set
Definition: linker_if.m:83
linker_function_name_callback_t callback
Definition: linker_if.m:62
c_linker_sym_t * symp
Definition: linker_if.m:40
const Elf_Sym ** symtab
Definition: linker_if.m:113
int * count
Definition: linker_if.m:88
METHOD int link_preload_finish
Definition: linker_if.m:143
caddr_t * strtab
Definition: linker_if.m:122
void * opaque
Definition: linker_if.m:63
METHOD long symtab_get
Definition: linker_if.m:111
c_linker_sym_t sym
Definition: linker_if.m:45
METHOD int ctf_get
Definition: linker_if.m:102
METHOD int lookup_symbol
Definition: linker_if.m:37
linker_symval_t * valp
Definition: linker_if.m:46
linker_file_t * result
Definition: linker_if.m:136
METHOD int search_symbol
Definition: linker_if.m:49
METHOD int each_function_name
Definition: linker_if.m:60
linker_ctf_t * lc
Definition: linker_if.m:104
STATICMETHOD int load_file
Definition: linker_if.m:133
const char * name
Definition: linker_if.m:39
METHOD long strtab_get
Definition: linker_if.m:120
STATICMETHOD int link_preload
Definition: linker_if.m:138
void *** stop
Definition: linker_if.m:87
INTERFACE linker
Definition: linker_if.m:31