Warn when @option{-fhardened} did not enable an option from its set (for
which see @option{-fhardened}). For instance, using @option{-fhardened}
and @option{-fstack-protector} at the same time on the command line causes
-@option{-Whardened} to warn because @option{-fstack-protector-strong} is
-not enabled by @option{-fhardened}.
+@option{-Whardened} to warn because @option{-fstack-protector-strong} will
+not be enabled by @option{-fhardened}.
This warning is enabled by default and has effect only when @option{-fhardened}
is enabled.
driver added to dumpdir after dumpbase or linker output name. */
static bool dumpdir_trailing_dash_added = false;
-/* True if -r, -shared, -pie, or -no-pie were specified on the command
- line. */
-static bool any_link_options_p;
+/* True if -r, -shared, -pie, -no-pie, -z lazy, or -z norelro were
+ specified on the command line, and therefore -fhardened should not
+ add -z now/relro. */
+static bool avoid_linker_hardening_p;
/* True if -static was specified on the command line. */
static bool static_p;
}
/* Record the part after the last comma. */
add_infile (arg + prev, "*");
+ if (strcmp (arg, "-z,lazy") == 0 || strcmp (arg, "-z,norelro") == 0)
+ avoid_linker_hardening_p = true;
}
do_save = false;
break;
+ case OPT_z:
+ if (strcmp (arg, "lazy") == 0 || strcmp (arg, "norelro") == 0)
+ avoid_linker_hardening_p = true;
+ break;
+
case OPT_Xlinker:
add_infile (arg, "*");
do_save = false;
case OPT_r:
case OPT_shared:
case OPT_no_pie:
- any_link_options_p = true;
+ avoid_linker_hardening_p = true;
break;
case OPT_static:
/* TODO: check if -static -pie works and maybe use it. */
if (flag_hardened)
{
- if (!any_link_options_p && !static_p)
+ if (!avoid_linker_hardening_p && !static_p)
{
#if defined HAVE_LD_PIE && defined LD_PIE_SPEC
save_switch (LD_PIE_SPEC, 0, NULL, /*validated=*/true, /*known=*/false);
}
}
/* We can't use OPT_Whardened yet. Sigh. */
- else if (warn_hardened)
+ else
warning_at (UNKNOWN_LOCATION, 0,
"linker hardening options not enabled by %<-fhardened%> "
"because other link options were specified on the command "