This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: GCC plugin to find encrypted function pointer calls in glibc


Sorry, I thought I had already responded to this.

On 05/05/2016 08:47 AM, Mikhail Maltsev wrote:
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);
   ...
}


Sounds good. I can certainly provide a pre-processor macro if it works for y'all.

Also, what attribute name would folks prefer?

1. function_pointer_demangle{r}
2. pointer_demangle{r}
3. pointer_decrypt

??

I have no preference, but if no one has strong opinions, I'm arbitrarily choosing "pointer_demangler".

Aldy


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]