44 lines
842 B
C
44 lines
842 B
C
#include <stdint.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
|
|
void* malloc(size_t size);
|
|
|
|
int main(void)
|
|
{
|
|
char* a = malloc(50);
|
|
char* b = malloc(160);
|
|
|
|
// asm volatile("fence rw, rw"); // make sure store completes
|
|
|
|
// volatile uint64_t* marker = (uint64_t*)0x80001000;
|
|
|
|
// *marker = 0xCAFEBABECAFED00D; // UNIQUE SIGNATURE
|
|
|
|
|
|
// if (!a || !b) return;
|
|
|
|
a[0] = 'A';
|
|
|
|
// // a[1] = 'C';
|
|
// // b[0] = 'B';
|
|
|
|
// // This will fault (out-of-bounds)
|
|
// // a[20] = 'X';
|
|
|
|
if (a[0] != 'A') {
|
|
while (1);
|
|
}
|
|
// // char* a = malloc(100);
|
|
// // char* b = malloc(200);
|
|
|
|
// a[0] = 'A'; // triggers page fault if unmapped
|
|
// b[19] = 'Z';
|
|
|
|
// for (int i = 0; i < 1000; i++) {
|
|
// a[i * 64] = i; // each write new cache line
|
|
// }
|
|
|
|
// while(1);
|
|
return 0;
|
|
} |