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