2 # Copyright (c) 2000 Doug Rabson
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
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.
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
29 #include <sys/linker.h>
34 # Lookup a symbol in the file's symbol table. If the symbol is not
35 # found then return ENOENT, otherwise zero.
37 METHOD int lookup_symbol {
43 METHOD int lookup_debug_symbol {
49 METHOD int symbol_values {
52 linker_symval_t* valp;
55 METHOD int debug_symbol_values {
58 linker_symval_t* valp;
61 METHOD int search_symbol {
69 # Call the callback with each specified function defined in the file.
70 # Stop and return the error if the callback returns an error.
72 METHOD int each_function_name {
74 linker_function_name_callback_t callback;
79 # Call the callback with each specified function and it's value
80 # defined in the file.
81 # Stop and return the error if the callback returns an error.
83 METHOD int each_function_nameval {
85 linker_function_nameval_callback_t callback;
90 # Search for a linker set in a file. Return a pointer to the first
91 # entry (which is itself a pointer), and the number of entries.
92 # "stop" points to the entry beyond the last valid entry.
93 # If count, start or stop are NULL, they are not returned.
95 METHOD int lookup_set {
104 # Unload a file, releasing dependencies and freeing storage.
111 # Load CTF data if necessary and if there is a .SUNW_ctf section
112 # in the ELF file, returning info in the linker CTF structure.
120 # Get the symbol table, returning it in **symtab. Return the
121 # number of symbols, otherwise zero.
123 METHOD long symtab_get {
125 const Elf_Sym **symtab;
129 # Get the string table, returning it in *strtab. Return the
130 # size (in bytes) of the string table, otherwise zero.
132 METHOD long strtab_get {
138 # Load a file, returning the new linker_file_t in *result. If
139 # the class does not recognise the file type, zero should be
140 # returned, without modifying *result. If the file is
141 # recognised, the file should be loaded, *result set to the new
142 # file and zero returned. If some other error is detected an
143 # appropriate errno should be returned.
145 STATICMETHOD int load_file {
147 const char* filename;
148 linker_file_t* result;
150 STATICMETHOD int link_preload {
152 const char* filename;
153 linker_file_t* result;
155 METHOD int link_preload_finish {