1 /* plugin-api.h -- External linker plugin API. */
3 /* Copyright 2008 Free Software Foundation, Inc.
4 Written by Cary Coutant <ccoutant@google.com>.
6 This file is part of binutils.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 MA 02110-1301, USA. */
23 /* This file defines the interface for writing a linker plugin, which is
24 described at < http://gcc.gnu.org/wiki/whopr/driver >. */
30 #include <sys/types.h>
37 /* Status code returned by most API routines. */
42 LDPS_NO_SYMS, /* Attempt to get symbols that haven't been added. */
44 /* Additional Error codes TBD. */
47 /* The version of the API specification. */
49 enum ld_plugin_api_version
51 LD_PLUGIN_API_VERSION = 1
54 /* The type of output file being generated by the linker. */
56 enum ld_plugin_output_file_type
63 /* An input file managed by the plugin library. */
65 struct ld_plugin_input_file
74 /* A symbol belonging to an input file managed by the plugin library. */
76 struct ld_plugin_symbol
87 /* Whether the symbol is a definition, reference, or common, weak or not. */
89 enum ld_plugin_symbol_kind
98 /* The visibility of the symbol. */
100 enum ld_plugin_symbol_visibility
108 /* How a symbol is resolved. */
110 enum ld_plugin_symbol_resolution
115 LDPR_PREVAILING_DEF_IRONLY,
123 /* The plugin library's "claim file" handler. */
126 enum ld_plugin_status
127 (*ld_plugin_claim_file_handler) (
128 const struct ld_plugin_input_file *file, int *claimed);
130 /* The plugin library's "all symbols read" handler. */
133 enum ld_plugin_status
134 (*ld_plugin_all_symbols_read_handler) (void);
136 /* The plugin library's cleanup handler. */
139 enum ld_plugin_status
140 (*ld_plugin_cleanup_handler) (void);
142 /* The linker's interface for registering the "claim file" handler. */
145 enum ld_plugin_status
146 (*ld_plugin_register_claim_file) (ld_plugin_claim_file_handler handler);
148 /* The linker's interface for registering the "all symbols read" handler. */
151 enum ld_plugin_status
152 (*ld_plugin_register_all_symbols_read) (
153 ld_plugin_all_symbols_read_handler handler);
155 /* The linker's interface for registering the cleanup handler. */
158 enum ld_plugin_status
159 (*ld_plugin_register_cleanup) (ld_plugin_cleanup_handler handler);
161 /* The linker's interface for adding symbols from a claimed input file. */
164 enum ld_plugin_status
165 (*ld_plugin_add_symbols) (void *handle, int nsyms,
166 const struct ld_plugin_symbol *syms);
168 /* The linker's interface for retrieving symbol resolution information. */
171 enum ld_plugin_status
172 (*ld_plugin_get_symbols) (const void *handle, int nsyms,
173 struct ld_plugin_symbol *syms);
175 /* The linker's interface for adding a compiled input file. */
178 enum ld_plugin_status
179 (*ld_plugin_add_input_file) (char *pathname);
181 /* The linker's interface for issuing a warning or error message. */
184 enum ld_plugin_status
185 (*ld_plugin_message) (int level, char *format, ...);
195 /* Values for the tv_tag field of the transfer vector. */
204 LDPT_REGISTER_CLAIM_FILE_HOOK,
205 LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK,
206 LDPT_REGISTER_CLEANUP_HOOK,
213 /* The plugin transfer vector. */
217 enum ld_plugin_tag tv_tag;
221 const char *tv_string;
222 ld_plugin_register_claim_file tv_register_claim_file;
223 ld_plugin_register_all_symbols_read tv_register_all_symbols_read;
224 ld_plugin_register_cleanup tv_register_cleanup;
225 ld_plugin_add_symbols tv_add_symbols;
226 ld_plugin_get_symbols tv_get_symbols;
227 ld_plugin_add_input_file tv_add_input_file;
228 ld_plugin_message tv_message;
232 /* The plugin library's "onload" entry point. */
235 enum ld_plugin_status
236 (*ld_plugin_onload) (struct ld_plugin_tv *tv);
242 #endif /* !defined(PLUGIN_API_H) */