Libtcc does a different thing on dynamic libraries based on the output type and it will crash in plenty of cases since the initial type is set to 0 (not 1 which TCC_OUTPUT_MEMORY is).
Unified · Split
| @@ -60,6 +60,9 @@ int main(int argc, char **argv) · 59 unmodified lines | |||
| 60 | /* set custom error/warning printer */ | 60 | /* set custom error/warning printer */ |
| 61 | tcc_set_error_func(s, stderr, handle_error); | 61 | tcc_set_error_func(s, stderr, handle_error); |
| 62 | 62 | ||
| 63 | /* MUST BE CALLED before any compilation */ | ||
| 64 | tcc_set_output_type(s, TCC_OUTPUT_MEMORY); | ||
| 65 | |||
| 63 | /* if tcclib.h and libtcc1.a are not installed, where can we find them */ | 66 | /* if tcclib.h and libtcc1.a are not installed, where can we find them */ |
| 64 | for (i = 1; i < argc; ++i) { | 67 | for (i = 1; i < argc; ++i) { |
| 65 | char *a = argv[i]; | 68 | char *a = argv[i]; |
| @@ -73,9 +76,6 @@ int main(int argc, char **argv) · 7 unmodified lines | |||
| 73 | } | 76 | } |
| 74 | } | 77 | } |
| 75 | 78 | ||
| 76 | /* MUST BE CALLED before any compilation */ | ||
| 77 | tcc_set_output_type(s, TCC_OUTPUT_MEMORY); | ||
| 78 | |||
| 79 | if (tcc_compile_string(s, my_program) == -1) | 79 | if (tcc_compile_string(s, my_program) == -1) |
| 80 | return 1; | 80 | return 1; |
| 81 | 81 | ||