Chain-compile and run in continuation.

parent 0e3a67ff
Pipeline #59282975 failed with stages
in 61 minutes and 24 seconds
......@@ -2,5 +2,5 @@
#include "asmc.h"
#include "ipxe_asmc_structs.h"
downloaded_file *download_file(const char *url);
downloaded_file *download_file(const char *url, const char *dest_file);
void *compile_file(const char *code, const char *symbol, void **buffer);
......@@ -155,7 +155,7 @@ const char *sources[][2] = {
#include "ipxe_handover.h"
#include "ipxe_asmc_structs.h"
#include "asmc_api.h"
int table_comp(void *t1, void *t2) {
table_sect *s1 = t1;
......@@ -286,6 +286,27 @@ void *compile_file(const char *filename, const char *symbol, void **buffer) {
char buf[1024];
sprintf(buf, "%d", __get_handles());
tcc_define_symbol(state, "__HANDLES", buf);
tcc_add_symbol(state, "tcc_new", tcc_new);
tcc_add_symbol(state, "tcc_delete", tcc_delete);
tcc_add_symbol(state, "tcc_set_lib_path", tcc_set_lib_path);
tcc_add_symbol(state, "tcc_set_error_func", tcc_set_error_func);
tcc_add_symbol(state, "tcc_set_options", tcc_set_options);
tcc_add_symbol(state, "tcc_add_include_path", tcc_add_include_path);
tcc_add_symbol(state, "tcc_add_sysinclude_path", tcc_add_sysinclude_path);
tcc_add_symbol(state, "tcc_define_symbol", tcc_define_symbol);
tcc_add_symbol(state, "tcc_undefine_symbol", tcc_undefine_symbol);
tcc_add_symbol(state, "tcc_add_file", tcc_add_file);
tcc_add_symbol(state, "tcc_compile_string", tcc_compile_string);
tcc_add_symbol(state, "tcc_set_output_type", tcc_set_output_type);
tcc_add_symbol(state, "tcc_add_library_path", tcc_add_library_path);
tcc_add_symbol(state, "tcc_add_library", tcc_add_library);
tcc_add_symbol(state, "tcc_add_symbol", tcc_add_symbol);
tcc_add_symbol(state, "tcc_output_file", tcc_output_file);
tcc_add_symbol(state, "tcc_run", tcc_run);
tcc_add_symbol(state, "tcc_relocate", tcc_relocate);
tcc_add_symbol(state, "tcc_get_symbol", tcc_get_symbol);
tcc_add_symbol(state, "download_file", download_file);
tcc_add_symbol(state, "compile_file", compile_file);
int res;
for (int i = 0; i < sizeof(includes2) / sizeof(includes2[0]); i++) {
res = tcc_add_include_path(state, includes2[i]);
......@@ -296,7 +317,7 @@ void *compile_file(const char *filename, const char *symbol, void **buffer) {
res = tcc_add_file(state, filename);
if (res) {
printf("tcc_compile_string() failed...\n");
printf("tcc_add_file() failed...\n");
return 1;
int size = tcc_relocate(state, NULL);
#include <stdio.h>
#include <asmc_api.h>
int main() {
printf("Hello, continuing world!\n");
download_file("", "/ram/continue2.c");
void *cont2_buf;
int (*cont2_symb)(int, char*[]) = compile_file("/ram/continue2.c", "_start", &cont2_buf);
char *cont2_argv[] = {"_main"};
cont2_symb(sizeof(cont2_argv) / sizeof(cont2_argv[0]), cont2_argv);
return 0;
#include <stdio.h>
int main() {
printf("Hello, continuing second world!\n");
return 0;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment