Hi Guys,

  With the annobin plugin for gcc I have a problem accessing some of the
  fields in the global_options structure.  Although the plugin can use
  the macros defined in options.h, this only works if the plugin is in
  sync with gcc.  If the plugin was built for one version of gcc, but
  run from another version, then the access can become invalid if the
  fields in struct gcc_options have changed.  (This does seem to happen
  quite a lot).

  Whilst forcing the plugin to stay in sync with gcc is one possible
  solution, it does have its own problems.  So I am looking for another
  solution.  Using the cl_options array and the flag_var_offset field
  does help.  But cl_options only has entries for some of the fields in
  global_options, not all of them.  (Eg: main_input_filename,
  flag_sanitize, optimize).

  One method that would work would be to enhance the optc-gen.awk and
  opth-gen.awk scripts so that they create a set of accessor functions.
  eg get_main_input_filename() or get_flag_sanitize().  These would not
  have to be used by the current gcc code, but their presence in the
  executable would allow them to be accessed from plugins.
  Alternatively a single accessor function which takes a parameter
  indicating the desired field and which returns its current value would
  also work.

  What do people think ?  Is this idea practical, or is there a better
  solution ?

Cheers
  Nick

Reply via email to