The following makes sure to record -D_FORTIFY_SOURCE=n and
-U_FORTIFY_SOURCE in the DW_AT_producer debuginfo attribute when
present on the compiler command line.
* opts.cc (gen_producer_string): Record -D and -U
with _FORTIFY_SOURCE prefix.
case OPT_v:
case OPT_w:
case OPT_L:
- case OPT_D:
case OPT_I:
- case OPT_U:
case OPT_SPECIAL_unknown:
case OPT_SPECIAL_ignore:
case OPT_SPECIAL_warn_removed:
case OPT_fchecking_:
/* Ignore these. */
continue;
+ case OPT_D:
+ case OPT_U:
+ if (startswith (options[i].arg, "_FORTIFY_SOURCE")
+ && (options[i].arg[sizeof ("_FORTIFY_SOURCE") - 1] == '\0'
+ || (options[i].opt_index == OPT_D
+ && options[i].arg[sizeof ("_FORTIFY_SOURCE") - 1] == '=')))
+ {
+ switches.safe_push (options[i].orig_option_with_args_text);
+ len += strlen (options[i].orig_option_with_args_text) + 1;
+ }
+ /* Otherwise ignore these. */
+ continue;
case OPT_flto_:
{
const char *lto_canonical = "-flto";