aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2025-03-13 14:29:06 +0100
committerRichard Biener <rguenth@gcc.gnu.org>2025-03-17 08:43:15 +0100
commit8912313df87679e202f2897ec25c924a67ee8117 (patch)
tree6d6f040dc5522e0b86e2f3fd07376611c58bc752 /gcc
parenta3ead22b42de8ddeeb869df2fa9cbdae7af5204d (diff)
downloadgcc-8912313df87679e202f2897ec25c924a67ee8117.zip
gcc-8912313df87679e202f2897ec25c924a67ee8117.tar.gz
gcc-8912313df87679e202f2897ec25c924a67ee8117.tar.bz2
Add -[DU]_FORTIFY_SOURCE[=n] to DW_AT_producer
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/opts.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/gcc/opts.cc b/gcc/opts.cc
index 23900c7..80c7a97 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -3831,9 +3831,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:
@@ -3869,6 +3867,18 @@ gen_command_line_string (cl_decoded_option *options,
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";