]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-bionic.git/commitdiff
make stack_protector_DeathTest work for gcc4.9
authorYabin Cui <yabinc@google.com>
Thu, 11 Dec 2014 22:35:05 +0000 (14:35 -0800)
committerYabin Cui <yabinc@google.com>
Fri, 12 Dec 2014 01:24:55 +0000 (17:24 -0800)
Bug: 18721888
Change-Id: I5f0b5c84319f56dbc4efb88e9d828138944667ae

tests/stack_protector_test.cpp

index aad51ecff37f1842652d202c878f6d7396a6c4e6..80077113be3859b97e4acb6a6e333ab272ee95cf 100644 (file)
@@ -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) {