latent_entropy: make builtin_frame_address implicit
PATCH 1/1 latent_entropy: make builtin_frame_address implicit
From: Sahara <[email protected]>
When Android toolchain for aarch64 is used to build this plugin, builtin_decl_implicit(BUILT_IN_FRAME_ADDRESS) returns NULL_TREE. Due to this issue, the returned NULL_TREE from builtin_decl_implicit causes compiler's unexpected fault in the next gimple_build_call. To avoid this problem, let's make it implicit before calling builtin_decl_implicit() for the frame address.
--- scripts/gcc-plugins/latent_entropy_plugin.c | 2 ++ 1 file changed, 2 insertions(+)
scripts/gcc-plugins/latent_entropy_plugin.c +2 -0
@@ -446,6 +446,8 @@ static void init_local_entropy(basic_block bb, tree local_entropy) frame_addr =create_var (ptr_type_node,"local_entropy_frameaddr" );/* 2. local_entropy_frameaddr = __builtin_frame_address() */ +if (!builtin_decl_implicit_p (BUILT_IN_FRAME_ADDRESS )) +set_builtin_decl_implicit_p (BUILT_IN_FRAME_ADDRESS , true); fndecl =builtin_decl_implicit (BUILT_IN_FRAME_ADDRESS ); call =gimple_build_call (fndecl,1 , integer_zero_node);gimple_call_set_lhs (call, frame_addr);
Signature · 1 line
2.7.4
Quoted 19 lines · On Tue, Aug 20, 2019 at 08:47:38AM +0400, [email protected] wrote:
From: Sahara <[email protected]>
When Android toolchain for aarch64 is used to build this plugin,
builtin_decl_implicit(BUILT_IN_FRAME_ADDRESS)returnsNULL_TREE. Due to this issue, the returnedNULL_TREEfrombuiltin_decl_implicitcauses compiler's unexpected fault in the nextgimple_build_call. To avoid this problem, let's make it implicit before callingbuiltin_decl_implicit()for the frame address.Signed-off-by Sahara <[email protected]>--- scripts/gcc-plugins/latent_entropy_plugin.c | 2 ++ 1 file changed, 2 insertions(+)scripts/gcc-plugins/latent_entropy_plugin.c +0
-0
scripts/gcc-plugins/latent_entropy_plugin.c static void init_local_entropy(basic_block bb, tree local_entropy) · line 450
Quoted 5 lines
scripts/gcc-plugins/latent_entropy_plugin.c +2
-0@@ -446,6 +446,8 @@ static void init_local_entropy(basic_block bb, tree local_entropy) frame_addr =create_var (ptr_type_node,"local_entropy_frameaddr" );/* 2. local_entropy_frameaddr = __builtin_frame_address() */ +if (!builtin_decl_implicit_p (BUILT_IN_FRAME_ADDRESS )) +set_builtin_decl_implicit_p (BUILT_IN_FRAME_ADDRESS , true);
Interesting! Is this aarch64-specific or something that has changed in more recent GCC versions?
Thanks!
-Kees
Quoted 6 lines
scripts/gcc-plugins/latent_entropy_plugin.c +0
-0fndecl =builtin_decl_implicit (BUILT_IN_FRAME_ADDRESS ); call =gimple_build_call (fndecl,1 , integer_zero_node);gimple_call_set_lhs (call, frame_addr);Signature · 1 line
2.7.4
Signature · 1 line
Kees Cook