1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# 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);
|