#include <sys/mman.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
#include <stdio.h>
#include <fcntl.h>

int main(int argc, char **argv) {
    int fd = open("test.dat", O_RDWR | O_CREAT, 0644);
    if (fd < 0) {
        perror("open()");
        return EXIT_FAILURE;
    }
    if (ftruncate(fd, 0x1000 * 4) != 0) {
        perror("ftruncate()");
        return EXIT_FAILURE;
    }
    void *data;
    if ((data = mmap(NULL, 0x1000 * 4, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0)) == MAP_FAILED) {
        perror("mmap()");
        return EXIT_FAILURE;
    }

    memset(data + 0x1000 * 0, 'a', 0x1000);
    memset(data + 0x1000 * 1, 'b', 0x1000);
    memset(data + 0x1000 * 2, 'c', 0x1000);
    memset(data + 0x1000 * 3, 'd', 0x1000);

    close(fd);

    return EXIT_SUCCESS;
}
