1
0
Files
gcc-14/debian/patches/ignore-pie-specs-when-not-enabled.diff
Konstantin Demin c2c1923c7b initial import from Debian
version: 14.3.0-5
commit: bee30ab0fff2fd6af94c62376c8aa4221bb831e0
2025-08-11 15:00:09 +03:00

57 lines
1.5 KiB
Diff

# DP: Ignore dpkg's pie specs when pie is not enabled.
Index: b/src/gcc/gcc.c
===================================================================
--- a/src/gcc/gcc.c
+++ b/src/gcc/gcc.c
@@ -3715,6 +3715,36 @@ handle_foffload_option (const char *arg)
}
}
+static bool ignore_pie_specs_when_not_enabled(const char *envvar,
+ const char *specname)
+{
+ const char *envval = secure_getenv(envvar);
+ char *hardening;
+ bool ignore;
+
+ if (strstr (specname, "/pie-compile.specs") == NULL
+ && strstr (specname, "/pie-link.specs") == NULL)
+ return false;
+ if (envval == NULL || strstr (envval, "hardening=") == NULL)
+ return true;
+ ignore = true;
+ hardening = (char *) xmalloc (strlen(envval) + 1);
+ strcpy (hardening, strstr (envval, "hardening="));
+ if (strchr (hardening, ' '))
+ *strchr (hardening, ' ') = '\0';
+ if (strstr(hardening, "+all"))
+ {
+ if (strstr(hardening, "-pie") == NULL)
+ ignore = false;
+ }
+ else if (strstr(hardening, "+pie"))
+ {
+ ignore = false;
+ }
+ free (hardening);
+ return ignore;
+}
+
/* Handle a driver option; arguments and return value as for
handle_option. */
@@ -3989,6 +4019,12 @@ driver_handle_option (struct gcc_options
break;
case OPT_specs_:
+ if (ignore_pie_specs_when_not_enabled("DEB_BUILD_MAINT_OPTIONS", arg)
+ && ignore_pie_specs_when_not_enabled("DEB_BUILD_OPTIONS", arg))
+ {
+ inform (0, "pie specs %s ignored when pie is not enabled", arg);
+ return true;
+ }
{
struct user_specs *user = XNEW (struct user_specs);