1 |
On śro, 2017-06-14 at 18:15 -0500, Matthias Maier wrote: |
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 | 71 +++++++++++++++++++++++++++++++++++++++++++ |
11 |
> 1 file changed, 71 insertions(+) |
12 |
> |
13 |
> diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass |
14 |
> index a0c359a950..3658c40518 100644 |
15 |
> --- a/eclass/toolchain-funcs.eclass |
16 |
> +++ b/eclass/toolchain-funcs.eclass |
17 |
> @@ -792,6 +792,77 @@ gcc-specs-stack-check() { |
18 |
> } |
19 |
> |
20 |
> |
21 |
> +# @FUNCTION: tc-enables-pie |
22 |
> +# @RETURN: Truth if the current compiler generates position-independent code (PIC) which can be linked into executables |
23 |
> +# @DESCRIPTION: |
24 |
> +# Return truth if the current compiler generates position-independent code (PIC) |
25 |
> +# which can be linked into executables. |
26 |
> +tc-enables-pie() { |
27 |
> + $($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null |
28 |
> + #if defined(__PIE__) |
29 |
> + true |
30 |
> + #else |
31 |
> + false |
32 |
> + #endif |
33 |
> + EOF |
34 |
> + ) |
35 |
|
36 |
Looks quite horrible. Why can't you just compare the output against |
37 |
a value instead of randomly executing it? |
38 |
|
39 |
> +} |
40 |
> + |
41 |
> +# @FUNCTION: tc-enables-ssp |
42 |
> +# @RETURN: Truth if the current compiler enables stack smashing protection (SSP) on at least minimal level |
43 |
> +# @DESCRIPTION: |
44 |
> +# Return truth if the current compiler enables stack smashing protection (SSP) |
45 |
> +# on level corresponding to any of the following options: |
46 |
> +# -fstack-protector |
47 |
> +# -fstack-protector-strong |
48 |
> +# -fstack-protector-all |
49 |
> +tc-enables-ssp() { |
50 |
> + $($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null |
51 |
> + #if defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__) |
52 |
> + true |
53 |
> + #else |
54 |
> + false |
55 |
> + #endif |
56 |
> + EOF |
57 |
> + ) |
58 |
> +} |
59 |
> + |
60 |
> +# @FUNCTION: tc-enables-ssp-strong |
61 |
> +# @RETURN: Truth if the current compiler enables stack smashing protection (SSP) on at least middle level |
62 |
> +# @DESCRIPTION: |
63 |
> +# Return truth if the current compiler enables stack smashing protection (SSP) |
64 |
> +# on level corresponding to any of the following options: |
65 |
> +# -fstack-protector-strong |
66 |
> +# -fstack-protector-all |
67 |
> +tc-enables-ssp-strong() { |
68 |
> + $($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null |
69 |
> + #if defined(__SSP_STRONG__) || defined(__SSP_ALL__) |
70 |
> + true |
71 |
> + #else |
72 |
> + false |
73 |
> + #endif |
74 |
> + EOF |
75 |
> + ) |
76 |
> +} |
77 |
> + |
78 |
> +# @FUNCTION: tc-enables-ssp-all |
79 |
> +# @RETURN: Truth if the current compiler enables stack smashing protection (SSP) on maximal level |
80 |
> +# @DESCRIPTION: |
81 |
> +# Return truth if the current compiler enables stack smashing protection (SSP) |
82 |
> +# on level corresponding to any of the following options: |
83 |
> +# -fstack-protector-all |
84 |
> +tc-enables-ssp-all() { |
85 |
> + $($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> /dev/null |
86 |
> + #if defined(__SSP_ALL__) |
87 |
> + true |
88 |
> + #else |
89 |
> + false |
90 |
> + #endif |
91 |
> + EOF |
92 |
> + ) |
93 |
> +} |
94 |
> + |
95 |
> + |
96 |
> # @FUNCTION: gen_usr_ldscript |
97 |
> # @USAGE: [-a] <list of libs to create linker scripts for> |
98 |
> # @DESCRIPTION: |
99 |
|
100 |
-- |
101 |
Best regards, |
102 |
Michał Górny |