Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: tests/data_not_executable/execute_data.c

Issue 12256018: [MIPS] Add remaining parts for building tests for MIPS (Closed) Base URL: http://src.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <inttypes.h> 9 #include <inttypes.h>
10 10
11 int main(void) { 11 int main(void) {
12 #if defined(__i386__) || defined(__x86_64__) 12 #if defined(__i386__) || defined(__x86_64__)
13 uint8_t code[] __attribute__((aligned(32))) = { 0xc3 /* ret */ }; 13 uint8_t code[] __attribute__((aligned(32))) = { 0xc3 /* ret */ };
14 #elif defined(__arm__) 14 #elif defined(__arm__)
15 uint32_t code[] __attribute__((aligned(32))) = { 0xe12fff1e /* BX LR */ }; 15 uint32_t code[] __attribute__((aligned(32))) = { 0xe12fff1e /* BX LR */ };
16 #elif defined(__mips__)
17 uint32_t code[] __attribute__((aligned(32)))= { 0x03e00008, /* JR RA */
Mark Seaborn 2013/02/13 22:14:09 Add a space before '='
petarj 2013/03/05 17:50:04 Done.
18 0 /* NOP */ };
16 #else 19 #else
17 # error Unknown architecture 20 # error Unknown architecture
18 #endif 21 #endif
19 22
20 void (*func)(void); 23 void (*func)(void);
21 24
22 /* Double cast required to stop gcc complaining. */ 25 /* Double cast required to stop gcc complaining. */
23 func = (void (*)(void)) (uintptr_t) code; 26 func = (void (*)(void)) (uintptr_t) code;
24 27
25 fprintf(stderr, "** intended_exit_status=untrusted_sigsegv_or_equivalent\n"); 28 fprintf(stderr, "** intended_exit_status=untrusted_sigsegv_or_equivalent\n");
26 /* This should fault because the data segment should not be executable. */ 29 /* This should fault because the data segment should not be executable. */
27 func(); 30 func();
28 fprintf(stderr, "We're still running. This is bad.\n"); 31 fprintf(stderr, "We're still running. This is bad.\n");
29 return 1; 32 return 1;
30 } 33 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698