Home | History | Annotate | Download | only in tests
      1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include <android/log.h>
      6 #include <stdio.h>
      7 #include <stdlib.h>
      8 
      9 // This is a large table that contains pointers to ensure that it
     10 // gets put inside the RELRO section.
     11 #define LINE "some example string",
     12 #define LINE8 LINE LINE LINE LINE LINE LINE LINE LINE
     13 #define LINE64 LINE8 LINE8 LINE8 LINE8 LINE8 LINE8 LINE8 LINE8
     14 #define LINE512 LINE64 LINE64 LINE64 LINE64 LINE64 LINE64 LINE64 LINE64
     15 #define LINE4096 LINE512 LINE512 LINE512 LINE512 LINE512 LINE512 LINE512 LINE512
     16 
     17 const char* const kStrings[] = {LINE4096 LINE4096 LINE4096 LINE4096};
     18 
     19 extern "C" void Foo() {
     20   printf("%s: Entering\n", __FUNCTION__);
     21   for (size_t n = 0; n < sizeof(kStrings) / sizeof(kStrings[0]); ++n) {
     22     const char* ptr = kStrings[n];
     23     if (strcmp(ptr, "some example string")) {
     24       printf("%s: Bad string at offset=%zu\n", __FUNCTION__, n);
     25       exit(1);
     26     }
     27   }
     28   printf("%s: Exiting\n", __FUNCTION__);
     29 }
     30