[RFC] add -[DU]_FORTIFY_SOURCE[=n] to DW_AT_producer
Checks
Commit Message
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.
We seem to want this internally now, not sure whether others also
need this (I'm happily carrying this downstream).
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
Richard.
* opts.cc (gen_producer_string): Record -D and -U
with _FORTIFY_SOURCE prefix.
---
gcc/opts.cc | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
@@ -3823,9 +3823,7 @@ gen_command_line_string (cl_decoded_option *options,
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:
@@ -3861,6 +3859,16 @@ gen_command_line_string (cl_decoded_option *options,
case OPT_fchecking_:
/* Ignore these. */
continue;
+ case OPT_D:
+ case OPT_U:
+ if (strncmp (options[i].arg, "_FORTIFY_SOURCE",
+ strlen ("_FORTIFY_SOURCE")) == 0)
+ {
+ 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";