-
Notifications
You must be signed in to change notification settings - Fork 2
/
load.c
29 lines (25 loc) · 772 Bytes
/
load.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "bflt/bflt.h"
#include "config.h"
int main(int argc, char* argv[]) {
if (argc != 2) {
if (!config_file_already_written()) {
write_config_file();
}
return 0;
}
void *bin_mem;
int (*entry_point)(int, char*[]);
size_t bin_size;
if (bflt_load(argv[1], &bin_mem, &bin_size, &entry_point) == 0) {
clear_cache();
entry_point(1, (char*[]){ argv[1], NULL });
}else{
printf("bflt load did not return 0\n");
}
bflt_free(bin_mem);
bflt_free_cached();
return 0;
}