From: Justin Seyster Date: Wed, 3 Feb 2010 23:08:38 +0000 (-0500) Subject: Linker magic to make compiling against InterAspect easy. X-Git-Tag: release-v1.0~126 X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=27f89e721f19ce74915014168ce74ce318f7ac9b;p=interaspect.git Linker magic to make compiling against InterAspect easy. --- diff --git a/src/Makefile.am b/src/Makefile.am index 3d327f8..57fb874 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,5 @@ lib_LTLIBRARIES = libinteraspect.la libinteraspect_la_SOURCES = aop-main.c -libinteraspect_la_LDFLAGS = -version-info 1:0:0 +libinteraspect_la_CFLAGS = -Wall -Werror -fvisibility=hidden -prefer-pic +libinteraspect_la_LDFLAGS = -static -prefer-pic -version-info 1:0:0 libinteraspect_la_CPPFLAGS = -DHAVE_CONFIG_H -DIN_GCC -I$(gcc_includes) diff --git a/src/aop-main.c b/src/aop-main.c index 547dc38..c7d3bd7 100644 --- a/src/aop-main.c +++ b/src/aop-main.c @@ -75,7 +75,8 @@ static struct opt_pass template_pass = { .todo_flags_finish = TODO_update_ssa, }; -void aop_register_pass (const char *pass_name, pass_callback callback) +void +aop_register_pass (const char *pass_name, pass_callback callback) { struct opt_pass *pass_aop; struct register_pass_info pass_info; @@ -100,7 +101,8 @@ void aop_register_pass (const char *pass_name, pass_callback callback) /* Free memory taken up by struct opt_pass objects saved in the aop_pass_list vector as well as the vector itself. */ -static void cleanup_passes () +static void +cleanup_passes () { int i; struct opt_pass *pass; @@ -116,16 +118,25 @@ static void cleanup_passes () /* This is the last plug-in function called before GCC exits. Clean up all the memory we allocated. */ -static void aop_cleanup (void *event_date, void *data) +static void +aop_cleanup (void *event_date, void *data) { cleanup_passes(); } /* GCC calls this to initialize a plug-in. Once InterAspect initializes, it calls down into its client plug-in's - initialization. */ -int plugin_init (struct plugin_name_args *plugin_info, - struct plugin_gcc_version *version) + initialization. + + By design, this function should be the _only_ exported (externally + visible) function in the compbined InterAspect/client package. + + Note that the compiler is set to automatically mark function + definitions with "hidden" visibility. We override that behavior + here. */ +__attribute__((visibility("default"))) int +plugin_init (struct plugin_name_args *plugin_info, + struct plugin_gcc_version *version) { fprintf (stderr, "InterAspect init.\n"); diff --git a/src/aop.h b/src/aop.h index 4e74025..bc7857b 100644 --- a/src/aop.h +++ b/src/aop.h @@ -29,6 +29,15 @@ calls can pass values from the running program to the advice function. */ +/* Client plug-in _must_ include this line to indicate that it is + GPLv3 compatible.*/ +#define AOP_I_AM_GPL_COMPATIBLE() \ + __attribute__((visibility("default"))) int plugin_is_GPL_compatible; + +/* Define aop_main using the AOP_MAIN_PROTO macro. Absolutely do not + just declare it as a void function! */ +#define AOP_MAIN_PROTO __attribute__((visibility("hidden"))) void + typedef unsigned int (*pass_callback)(); void aop_register_pass(const char *pass_name, pass_callback callback);