From 562ae1e6e42e83f674507d2b915deb503200befe Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Thu, 11 Dec 2014 14:35:05 -0800 Subject: [PATCH] make stack_protector_DeathTest work for gcc4.9 Bug: 18721888 Change-Id: I5f0b5c84319f56dbc4efb88e9d828138944667ae --- tests/stack_protector_test.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/stack_protector_test.cpp b/tests/stack_protector_test.cpp index aad51ecff..80077113b 100644 --- a/tests/stack_protector_test.cpp +++ b/tests/stack_protector_test.cpp @@ -106,10 +106,16 @@ extern "C" uintptr_t __stack_chk_guard; * This must be marked with "__attribute__ ((noinline))", to ensure the * compiler generates the proper stack guards around this function. */ +static char* dummy_buf; + __attribute__ ((noinline)) static void do_modify_stack_chk_guard() { + char buf[128]; + // Store local array's address to global variable to force compiler to generate stack guards. + dummy_buf = buf; __stack_chk_guard = 0x12345678; } + #endif TEST(stack_protector, global_guard) {