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