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#
27
28#include <sys/linker.h>
29
30INTERFACE linker;
31
32#
33# Lookup a symbol in the file's symbol table.  If the symbol is not
34# found then return ENOENT, otherwise zero.
35#
36METHOD int lookup_symbol {
37    linker_file_t	file;
38    const char*		name;
39    c_linker_sym_t*	symp;
40};
41
42METHOD int lookup_debug_symbol {
43    linker_file_t	file;
44    const char*		name;
45    c_linker_sym_t*	symp;
46};
47
48METHOD int symbol_values {
49    linker_file_t	file;
50    c_linker_sym_t	sym;
51    linker_symval_t*	valp;
52};
53
54METHOD int debug_symbol_values {
55    linker_file_t	file;
56    c_linker_sym_t	sym;
57    linker_symval_t*	valp;
58};
59
60METHOD int search_symbol {
61    linker_file_t	file;
62    caddr_t		value;
63    c_linker_sym_t*	symp;
64    long*		diffp;
65};
66
67#
68# Call the callback with each specified function defined in the file.
69# Stop and return the error if the callback returns an error.
70#
71METHOD int each_function_name {
72	linker_file_t	file;
73	linker_function_name_callback_t	callback;
74	void*		opaque;
75};
76
77#
78# Call the callback with each specified function and it's value
79# defined in the file.
80# Stop and return the error if the callback returns an error.
81#
82METHOD int each_function_nameval {
83	linker_file_t	file;
84	linker_function_nameval_callback_t	callback;
85	void*		opaque;
86};
87
88#
89# Search for a linker set in a file.  Return a pointer to the first
90# entry (which is itself a pointer), and the number of entries.
91# "stop" points to the entry beyond the last valid entry.
92# If count, start or stop are NULL, they are not returned.
93#
94METHOD int lookup_set {
95    linker_file_t	file;
96    const char*		name;
97    void***		start;
98    void***		stop;
99    int*		count;
100};
101
102#
103# Unload a file, releasing dependencies and freeing storage.
104#
105METHOD void unload {
106    linker_file_t	file;
107};
108
109#
110# Load CTF data if necessary and if there is a .SUNW_ctf section
111# in the ELF file, returning info in the linker CTF structure.
112#
113METHOD int ctf_get {
114	linker_file_t	file;
115	linker_ctf_t	*lc;
116};
117
118#
119# Look up a CTF type in the file's CTF section
120# and return CTF info in the linker CTF structure.
121# Return ENOENT if typename is not found, otherwise zero.
122#
123METHOD int ctf_lookup_typename {
124  linker_file_t file;
125  linker_ctf_t *lc;
126  const char *typename;
127};
128
129#
130# Lookup a symbol in the file's symbol table and the file's CTF info.
131# Return ENOENT if either the symbol or its CTF
132# data is not loaded, otherwise return zero.
133#
134METHOD int lookup_debug_symbol_ctf {
135  linker_file_t file;
136  const char *name;
137  c_linker_sym_t *sym;
138  linker_ctf_t *lc;
139};
140
141#
142# Get the symbol table, returning it in **symtab.  Return the 
143# number of symbols, otherwise zero.
144#
145METHOD long symtab_get {
146	linker_file_t	file;
147	const Elf_Sym	**symtab;
148};
149
150#
151# Get the string table, returning it in *strtab.  Return the
152# size (in bytes) of the string table, otherwise zero.
153#
154METHOD long strtab_get {
155	linker_file_t	file;
156	caddr_t		*strtab;
157};
158
159#
160# Load a file, returning the new linker_file_t in *result.  If
161# the class does not recognise the file type, zero should be
162# returned, without modifying *result.  If the file is
163# recognised, the file should be loaded, *result set to the new
164# file and zero returned.  If some other error is detected an
165# appropriate errno should be returned.
166#
167STATICMETHOD int load_file {
168    linker_class_t	cls;
169    const char*		filename;
170    linker_file_t*	result;
171};
172STATICMETHOD int link_preload {
173    linker_class_t	cls;
174    const char*		filename;
175    linker_file_t*	result;
176};
177METHOD int link_preload_finish {
178    linker_file_t	file;
179};
180
181#ifdef VIMAGE
182#
183# Propagate system tunable values to all vnets.
184#
185METHOD void propagate_vnets {
186	linker_file_t	file;
187};
188#endif
189