/* plugin-api.h -- External linker plugin API. */
-/* Copyright 2008 Free Software Foundation, Inc.
+/* Copyright 2009 Free Software Foundation, Inc.
Written by Cary Coutant <ccoutant@google.com>.
This file is part of binutils.
#ifndef PLUGIN_API_H
#define PLUGIN_API_H
+#ifdef HAVE_STDINT_H
#include <stdint.h>
+#elif defined(HAVE_INTTYPES_H)
+#include <inttypes.h>
+#endif
#include <sys/types.h>
+#if !defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H) && \
+ !defined(UINT64_MAX) && !defined(uint64_t)
+#error can not find uint64_t type
+#endif
#ifdef __cplusplus
extern "C"
enum ld_plugin_status
{
LDPS_OK = 0,
- LDPS_NO_SYMS, // Attempt to get symbols that haven't been added.
- LDPS_ERR,
+ LDPS_NO_SYMS, /* Attempt to get symbols that haven't been added. */
+ LDPS_BAD_HANDLE, /* No claimed object associated with given handle. */
+ LDPS_ERR
/* Additional Error codes TBD. */
};
enum ld_plugin_api_version
{
- LD_PLUGIN_API_VERSION = 1,
+ LD_PLUGIN_API_VERSION = 1
};
/* The type of output file being generated by the linker. */
{
LDPO_REL,
LDPO_EXEC,
- LDPO_DYN,
+ LDPO_DYN
};
/* An input file managed by the plugin library. */
LDPK_WEAKDEF,
LDPK_UNDEF,
LDPK_WEAKUNDEF,
- LDPK_COMMON,
+ LDPK_COMMON
};
/* The visibility of the symbol. */
LDPV_DEFAULT,
LDPV_PROTECTED,
LDPV_INTERNAL,
- LDPV_HIDDEN,
+ LDPV_HIDDEN
};
/* How a symbol is resolved. */
enum ld_plugin_symbol_resolution
{
LDPR_UNKNOWN = 0,
+
+ /* Symbol is still undefined at this point. */
LDPR_UNDEF,
+
+ /* This is the prevailing definition of the symbol, with references from
+ regular object code. */
LDPR_PREVAILING_DEF,
+
+ /* This is the prevailing definition of the symbol, with no
+ references from regular objects. It is only referenced from IR
+ code. */
LDPR_PREVAILING_DEF_IRONLY,
+
+ /* This definition was pre-empted by a definition in a regular
+ object file. */
LDPR_PREEMPTED_REG,
+
+ /* This definition was pre-empted by a definition in another IR file. */
LDPR_PREEMPTED_IR,
+
+ /* This symbol was resolved by a definition in another IR file. */
LDPR_RESOLVED_IR,
+
+ /* This symbol was resolved by a definition in a regular object
+ linked into the main executable. */
LDPR_RESOLVED_EXEC,
- LDPR_RESOLVED_DYN,
+
+ /* This symbol was resolved by a definition in a shared object. */
+ LDPR_RESOLVED_DYN
};
/* The plugin library's "claim file" handler. */
(*ld_plugin_add_symbols) (void *handle, int nsyms,
const struct ld_plugin_symbol *syms);
+/* The linker's interface for getting the input file information with
+ an open (possibly re-opened) file descriptor. */
+
+typedef
+enum ld_plugin_status
+(*ld_plugin_get_input_file) (const void *handle,
+ struct ld_plugin_input_file *file);
+
+/* The linker's interface for releasing the input file. */
+
+typedef
+enum ld_plugin_status
+(*ld_plugin_release_input_file) (const void *handle);
+
/* The linker's interface for retrieving symbol resolution information. */
typedef
enum ld_plugin_status
(*ld_plugin_add_input_file) (char *pathname);
+/* The linker's interface for adding a library that should be searched. */
+
+typedef
+enum ld_plugin_status
+(*ld_plugin_add_input_library) (char *libname);
+
/* The linker's interface for issuing a warning or error message. */
typedef
enum ld_plugin_status
-(*ld_plugin_message) (int level, char *format, ...);
+(*ld_plugin_message) (int level, const char *format, ...);
enum ld_plugin_level
{
LDPL_INFO,
LDPL_WARNING,
LDPL_ERROR,
- LDPL_FATAL,
+ LDPL_FATAL
};
/* Values for the tv_tag field of the transfer vector. */
LDPT_GET_SYMBOLS,
LDPT_ADD_INPUT_FILE,
LDPT_MESSAGE,
+ LDPT_GET_INPUT_FILE,
+ LDPT_RELEASE_INPUT_FILE,
+ LDPT_ADD_INPUT_LIBRARY
};
/* The plugin transfer vector. */
ld_plugin_get_symbols tv_get_symbols;
ld_plugin_add_input_file tv_add_input_file;
ld_plugin_message tv_message;
+ ld_plugin_get_input_file tv_get_input_file;
+ ld_plugin_release_input_file tv_release_input_file;
+ ld_plugin_add_input_library tv_add_input_library;
} tv_u;
};
(*ld_plugin_onload) (struct ld_plugin_tv *tv);
#ifdef __cplusplus
-};
+}
#endif
#endif /* !defined(PLUGIN_API_H) */