This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: RFC: GCC plugin to find encrypted function pointer calls in glibc
- From: Mikhail Maltsev <maltsevm at gmail dot com>
- To: Aldy Hernandez <aldyh at redhat dot com>, Carlos O'Donell <carlos at redhat dot com>, libc-alpha at sourceware dot org, Florian Weimer <fweimer at redhat dot com>
- Date: Thu, 5 May 2016 15:47:12 +0300
- Subject: Re: RFC: GCC plugin to find encrypted function pointer calls in glibc
- Authentication-results: sourceware.org; auth=none
- References: <57233606 dot 7050205 at redhat dot com> <57240891 dot 1000308 at redhat dot com> <5724D5E3 dot 8050600 at redhat dot com> <572A0045 dot 2050309 at redhat dot com> <572B0F58 dot 3090409 at redhat dot com>
On 05/05/2016 01:10 PM, Aldy Hernandez wrote:
> You can leave the attributes enabled unconditionally. GCC ignores unknown
> attributes, so the old compiler compiling the attributed source will behave as
> usual.
>
> However, you will get an "unknown attribute ignored" warning with -Wall, but you
> can easily silence that particular warning just for the wrapper:
>
> #pragma GCC diagnostic push
> #pragma GCC diagnostic ignored "-Wattributes"
> static inline void
> __attribute__((SOME_POSSIBLY_UNKNOWN_ATTRIBUTE))
> wrapper_function (void)
> {
> }
> #pragma GCC diagnostic pop
>
Another option is:
1. Define attribute as a macro:
#ifdef __PLUGIN_LOADED__
# define PLUGIN_ATTRIBUTE __attribute__((SOME_ATTRIBUTE))
#else
# define PLUGIN_ATTRIBUTE /* nothing */
#endif
...
static inline void
PLUGIN_ATTRIBUTE
wrapper_function (void)
{
}
2. Define __PLUGIN_LOADED__ from PLUGIN_START_UNIT event:
static void
start_unit(void* /*event_data*/, void* /*data*/)
{
gcc_assert(parse_in);
cpp_define(parse_in, "__PLUGIN_LOADED__=1");
}
int
plugin_init(plugin_name_args* plugin_info, plugin_gcc_version* version)
{
...
register_callback(plugin_name, PLUGIN_START_UNIT, start_unit, nullptr);
...
}
--
Regards,
Mikhail Maltsev