1 |
From: Arfrever Frehtes Taifersar Arahesis <Arfrever@××××××.Org> |
2 |
|
3 |
Newly added tc-enables-pie(), tc-enables-ssp(), tc-enables-ssp-strong() |
4 |
and tc-enables-ssp-all() check macros instead of specs. |
5 |
This solution also works with older GCC and with Clang. |
6 |
|
7 |
Signed-off-by: Matthias Maier <tamiko@g.o> |
8 |
--- |
9 |
eclass/toolchain-funcs.eclass | 71 +++++++++++++++++++++++++++++++++++++++++++ |
10 |
1 file changed, 71 insertions(+) |
11 |
|
12 |
diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass |
13 |
index a0c359a950..3658c40518 100644 |
14 |
--- a/eclass/toolchain-funcs.eclass |
15 |
+++ b/eclass/toolchain-funcs.eclass |
16 |
@@ -792,6 +792,77 @@ gcc-specs-stack-check() { |
17 |
} |
18 |
|
19 |
|
20 |
+# @FUNCTION: tc-enables-pie |
21 |
+# @RETURN: Truth if the current compiler generates position-independent code (PIC) which can be linked into executables |
22 |
+# @DESCRIPTION: |
23 |
+# Return truth if the current compiler generates position-independent code (PIC) |
24 |
+# which can be linked into executables. |
25 |
+tc-enables-pie() { |
26 |
+ $($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null |
27 |
+ #if defined(__PIE__) |
28 |
+ true |
29 |
+ #else |
30 |
+ false |
31 |
+ #endif |
32 |
+ EOF |
33 |
+ ) |
34 |
+} |
35 |
+ |
36 |
+# @FUNCTION: tc-enables-ssp |
37 |
+# @RETURN: Truth if the current compiler enables stack smashing protection (SSP) on at least minimal level |
38 |
+# @DESCRIPTION: |
39 |
+# Return truth if the current compiler enables stack smashing protection (SSP) |
40 |
+# on level corresponding to any of the following options: |
41 |
+# -fstack-protector |
42 |
+# -fstack-protector-strong |
43 |
+# -fstack-protector-all |
44 |
+tc-enables-ssp() { |
45 |
+ $($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null |
46 |
+ #if defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__) |
47 |
+ true |
48 |
+ #else |
49 |
+ false |
50 |
+ #endif |
51 |
+ EOF |
52 |
+ ) |
53 |
+} |
54 |
+ |
55 |
+# @FUNCTION: tc-enables-ssp-strong |
56 |
+# @RETURN: Truth if the current compiler enables stack smashing protection (SSP) on at least middle level |
57 |
+# @DESCRIPTION: |
58 |
+# Return truth if the current compiler enables stack smashing protection (SSP) |
59 |
+# on level corresponding to any of the following options: |
60 |
+# -fstack-protector-strong |
61 |
+# -fstack-protector-all |
62 |
+tc-enables-ssp-strong() { |
63 |
+ $($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null |
64 |
+ #if defined(__SSP_STRONG__) || defined(__SSP_ALL__) |
65 |
+ true |
66 |
+ #else |
67 |
+ false |
68 |
+ #endif |
69 |
+ EOF |
70 |
+ ) |
71 |
+} |
72 |
+ |
73 |
+# @FUNCTION: tc-enables-ssp-all |
74 |
+# @RETURN: Truth if the current compiler enables stack smashing protection (SSP) on maximal level |
75 |
+# @DESCRIPTION: |
76 |
+# Return truth if the current compiler enables stack smashing protection (SSP) |
77 |
+# on level corresponding to any of the following options: |
78 |
+# -fstack-protector-all |
79 |
+tc-enables-ssp-all() { |
80 |
+ $($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null |
81 |
+ #if defined(__SSP_ALL__) |
82 |
+ true |
83 |
+ #else |
84 |
+ false |
85 |
+ #endif |
86 |
+ EOF |
87 |
+ ) |
88 |
+} |
89 |
+ |
90 |
+ |
91 |
# @FUNCTION: gen_usr_ldscript |
92 |
# @USAGE: [-a] <list of libs to create linker scripts for> |
93 |
# @DESCRIPTION: |
94 |
-- |
95 |
2.13.0 |