19454b2d8SWarner Losh#- 2326e27d8SDoug Rabson# Copyright (c) 2000 Doug Rabson 3326e27d8SDoug Rabson# All rights reserved. 4326e27d8SDoug Rabson# 5326e27d8SDoug Rabson# Redistribution and use in source and binary forms, with or without 6326e27d8SDoug Rabson# modification, are permitted provided that the following conditions 7326e27d8SDoug Rabson# are met: 8326e27d8SDoug Rabson# 1. Redistributions of source code must retain the above copyright 9326e27d8SDoug Rabson# notice, this list of conditions and the following disclaimer. 10326e27d8SDoug Rabson# 2. Redistributions in binary form must reproduce the above copyright 11326e27d8SDoug Rabson# notice, this list of conditions and the following disclaimer in the 12326e27d8SDoug Rabson# documentation and/or other materials provided with the distribution. 13326e27d8SDoug Rabson# 14326e27d8SDoug Rabson# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15326e27d8SDoug Rabson# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16326e27d8SDoug Rabson# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17326e27d8SDoug Rabson# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18326e27d8SDoug Rabson# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19326e27d8SDoug Rabson# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20326e27d8SDoug Rabson# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21326e27d8SDoug Rabson# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22326e27d8SDoug Rabson# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23326e27d8SDoug Rabson# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24326e27d8SDoug Rabson# SUCH DAMAGE. 25326e27d8SDoug Rabson# 26326e27d8SDoug Rabson# 27326e27d8SDoug Rabson 28326e27d8SDoug Rabson#include <sys/linker.h> 29326e27d8SDoug Rabson 30326e27d8SDoug RabsonINTERFACE linker; 31326e27d8SDoug Rabson 32326e27d8SDoug Rabson# 33326e27d8SDoug Rabson# Lookup a symbol in the file's symbol table. If the symbol is not 34326e27d8SDoug Rabson# found then return ENOENT, otherwise zero. 35326e27d8SDoug Rabson# 36326e27d8SDoug RabsonMETHOD int lookup_symbol { 37326e27d8SDoug Rabson linker_file_t file; 38326e27d8SDoug Rabson const char* name; 39326e27d8SDoug Rabson c_linker_sym_t* symp; 40326e27d8SDoug Rabson}; 41326e27d8SDoug Rabson 4295c20fafSKonstantin BelousovMETHOD int lookup_debug_symbol { 4395c20fafSKonstantin Belousov linker_file_t file; 4495c20fafSKonstantin Belousov const char* name; 4595c20fafSKonstantin Belousov c_linker_sym_t* symp; 4695c20fafSKonstantin Belousov}; 4795c20fafSKonstantin Belousov 48326e27d8SDoug RabsonMETHOD int symbol_values { 49326e27d8SDoug Rabson linker_file_t file; 50326e27d8SDoug Rabson c_linker_sym_t sym; 51326e27d8SDoug Rabson linker_symval_t* valp; 52326e27d8SDoug Rabson}; 53326e27d8SDoug Rabson 5495c20fafSKonstantin BelousovMETHOD int debug_symbol_values { 5595c20fafSKonstantin Belousov linker_file_t file; 5695c20fafSKonstantin Belousov c_linker_sym_t sym; 5795c20fafSKonstantin Belousov linker_symval_t* valp; 5895c20fafSKonstantin Belousov}; 5995c20fafSKonstantin Belousov 60326e27d8SDoug RabsonMETHOD int search_symbol { 61326e27d8SDoug Rabson linker_file_t file; 62326e27d8SDoug Rabson caddr_t value; 63326e27d8SDoug Rabson c_linker_sym_t* symp; 64326e27d8SDoug Rabson long* diffp; 65326e27d8SDoug Rabson}; 66326e27d8SDoug Rabson 67326e27d8SDoug Rabson# 68bb9fe9ddSBrian Feldman# Call the callback with each specified function defined in the file. 69bb9fe9ddSBrian Feldman# Stop and return the error if the callback returns an error. 70bb9fe9ddSBrian Feldman# 71bb9fe9ddSBrian FeldmanMETHOD int each_function_name { 72bb9fe9ddSBrian Feldman linker_file_t file; 73bb9fe9ddSBrian Feldman linker_function_name_callback_t callback; 74bb9fe9ddSBrian Feldman void* opaque; 75bb9fe9ddSBrian Feldman}; 76bb9fe9ddSBrian Feldman 77bb9fe9ddSBrian Feldman# 78f6c15301SJohn Birrell# Call the callback with each specified function and it's value 79f6c15301SJohn Birrell# defined in the file. 80f6c15301SJohn Birrell# Stop and return the error if the callback returns an error. 81f6c15301SJohn Birrell# 82f6c15301SJohn BirrellMETHOD int each_function_nameval { 83f6c15301SJohn Birrell linker_file_t file; 84f6c15301SJohn Birrell linker_function_nameval_callback_t callback; 85f6c15301SJohn Birrell void* opaque; 86f6c15301SJohn Birrell}; 87f6c15301SJohn Birrell 88f6c15301SJohn Birrell# 89f41325dbSPeter Wemm# Search for a linker set in a file. Return a pointer to the first 90f41325dbSPeter Wemm# entry (which is itself a pointer), and the number of entries. 91f41325dbSPeter Wemm# "stop" points to the entry beyond the last valid entry. 92f41325dbSPeter Wemm# If count, start or stop are NULL, they are not returned. 93f41325dbSPeter Wemm# 94f41325dbSPeter WemmMETHOD int lookup_set { 95f41325dbSPeter Wemm linker_file_t file; 96f41325dbSPeter Wemm const char* name; 97f41325dbSPeter Wemm void*** start; 98f41325dbSPeter Wemm void*** stop; 99f41325dbSPeter Wemm int* count; 100f41325dbSPeter Wemm}; 101f41325dbSPeter Wemm 102f41325dbSPeter Wemm# 103e3043798SPedro F. Giffuni# Unload a file, releasing dependencies and freeing storage. 104326e27d8SDoug Rabson# 105326e27d8SDoug RabsonMETHOD void unload { 106326e27d8SDoug Rabson linker_file_t file; 107326e27d8SDoug Rabson}; 108326e27d8SDoug Rabson 109326e27d8SDoug Rabson# 11082c4945bSJohn Birrell# Load CTF data if necessary and if there is a .SUNW_ctf section 11182c4945bSJohn Birrell# in the ELF file, returning info in the linker CTF structure. 11282c4945bSJohn Birrell# 11382c4945bSJohn BirrellMETHOD int ctf_get { 11482c4945bSJohn Birrell linker_file_t file; 11582c4945bSJohn Birrell linker_ctf_t *lc; 11682c4945bSJohn Birrell}; 11782c4945bSJohn Birrell 11882c4945bSJohn Birrell# 119*c21bc6f3SBojan Novković# Look up a CTF type in the file's CTF section 120*c21bc6f3SBojan Novković# and return CTF info in the linker CTF structure. 121*c21bc6f3SBojan Novković# Return ENOENT if typename is not found, otherwise zero. 122*c21bc6f3SBojan Novković# 123*c21bc6f3SBojan NovkovićMETHOD int ctf_lookup_typename { 124*c21bc6f3SBojan Novković linker_file_t file; 125*c21bc6f3SBojan Novković linker_ctf_t *lc; 126*c21bc6f3SBojan Novković const char *typename; 127*c21bc6f3SBojan Novković}; 128*c21bc6f3SBojan Novković 129*c21bc6f3SBojan Novković# 130*c21bc6f3SBojan Novković# Lookup a symbol in the file's symbol table and the file's CTF info. 131*c21bc6f3SBojan Novković# Return ENOENT if either the symbol or its CTF 132*c21bc6f3SBojan Novković# data is not loaded, otherwise return zero. 133*c21bc6f3SBojan Novković# 134*c21bc6f3SBojan NovkovićMETHOD int lookup_debug_symbol_ctf { 135*c21bc6f3SBojan Novković linker_file_t file; 136*c21bc6f3SBojan Novković const char *name; 137*c21bc6f3SBojan Novković c_linker_sym_t *sym; 138*c21bc6f3SBojan Novković linker_ctf_t *lc; 139*c21bc6f3SBojan Novković}; 140*c21bc6f3SBojan Novković 141*c21bc6f3SBojan Novković# 14200a5db46SStacey Son# Get the symbol table, returning it in **symtab. Return the 14300a5db46SStacey Son# number of symbols, otherwise zero. 14400a5db46SStacey Son# 14500a5db46SStacey SonMETHOD long symtab_get { 14600a5db46SStacey Son linker_file_t file; 147e76f11f4SAndriy Gapon const Elf_Sym **symtab; 14800a5db46SStacey Son}; 14900a5db46SStacey Son 15000a5db46SStacey Son# 15100a5db46SStacey Son# Get the string table, returning it in *strtab. Return the 15200a5db46SStacey Son# size (in bytes) of the string table, otherwise zero. 15300a5db46SStacey Son# 15400a5db46SStacey SonMETHOD long strtab_get { 15500a5db46SStacey Son linker_file_t file; 15600a5db46SStacey Son caddr_t *strtab; 15700a5db46SStacey Son}; 15800a5db46SStacey Son 15900a5db46SStacey Son# 160326e27d8SDoug Rabson# Load a file, returning the new linker_file_t in *result. If 161326e27d8SDoug Rabson# the class does not recognise the file type, zero should be 162326e27d8SDoug Rabson# returned, without modifying *result. If the file is 163326e27d8SDoug Rabson# recognised, the file should be loaded, *result set to the new 164326e27d8SDoug Rabson# file and zero returned. If some other error is detected an 165326e27d8SDoug Rabson# appropriate errno should be returned. 166326e27d8SDoug Rabson# 167326e27d8SDoug RabsonSTATICMETHOD int load_file { 168326e27d8SDoug Rabson linker_class_t cls; 169326e27d8SDoug Rabson const char* filename; 170326e27d8SDoug Rabson linker_file_t* result; 171326e27d8SDoug Rabson}; 17254823af2SPeter WemmSTATICMETHOD int link_preload { 17354823af2SPeter Wemm linker_class_t cls; 17454823af2SPeter Wemm const char* filename; 17554823af2SPeter Wemm linker_file_t* result; 17654823af2SPeter Wemm}; 177ab7a2646SDoug RabsonMETHOD int link_preload_finish { 17854823af2SPeter Wemm linker_file_t file; 17954823af2SPeter Wemm}; 180110113bcSZhenlei Huang 181110113bcSZhenlei Huang#ifdef VIMAGE 182110113bcSZhenlei Huang# 183110113bcSZhenlei Huang# Propagate system tunable values to all vnets. 184110113bcSZhenlei Huang# 185110113bcSZhenlei HuangMETHOD void propagate_vnets { 186110113bcSZhenlei Huang linker_file_t file; 187110113bcSZhenlei Huang}; 188110113bcSZhenlei Huang#endif 189