- disable tccrun feature for non-native (cross-) compilers - define uplong for target adress size - fix using -Wl,-Ttext=... for Win64 (tccpe: ADDR3264 imagebase)
Unified · Split
| @@ -578,7 +578,11 @@ int main(int argc, char **argv) · 577 unmodified lines | |||
| 578 | tcc_print_stats(s, getclock_us() - start_time); | 578 | tcc_print_stats(s, getclock_us() - start_time); |
| 579 | 579 | ||
| 580 | if (s->output_type == TCC_OUTPUT_MEMORY) { | 580 | if (s->output_type == TCC_OUTPUT_MEMORY) { |
| 581 | #ifdef TCC_IS_NATIVE | ||
| 581 | ret = tcc_run(s, argc - optind, argv + optind); | 582 | ret = tcc_run(s, argc - optind, argv + optind); |
| 583 | #else | ||
| 584 | tcc_error_noabort("-run is not available in a cross compiler"); | ||
| 585 | #endif | ||
| 582 | } else if (s->output_type == TCC_OUTPUT_PREPROCESS) { | 586 | } else if (s->output_type == TCC_OUTPUT_PREPROCESS) { |
| 583 | if (s->outfile) | 587 | if (s->outfile) |
| 584 | fclose(s->outfile); | 588 | fclose(s->outfile); |
| @@ -49,9 +49,6 @@ · 48 unmodified lines | |||
| 49 | #include <direct.h> /* getcwd */ | 49 | #include <direct.h> /* getcwd */ |
| 50 | #define inline __inline | 50 | #define inline __inline |
| 51 | #define inp next_inp | 51 | #define inp next_inp |
| 52 | #ifdef _WIN64 | ||
| 53 | # define uplong unsigned long long | ||
| 54 | #endif | ||
| 55 | #ifdef LIBTCC_AS_DLL | 52 | #ifdef LIBTCC_AS_DLL |
| 56 | # define LIBTCCAPI __declspec(dllexport) | 53 | # define LIBTCCAPI __declspec(dllexport) |
| 57 | #endif | 54 | #endif |
| @@ -67,17 +64,10 @@ · 9 unmodified lines | |||
| 67 | 64 | ||
| 68 | #endif /* !CONFIG_TCCBOOT */ | 65 | #endif /* !CONFIG_TCCBOOT */ |
| 69 | 66 | ||
| 70 | #ifndef uplong | ||
| 71 | #define uplong unsigned long | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #ifndef PAGESIZE | 67 | #ifndef PAGESIZE |
| 75 | #define PAGESIZE 4096 | 68 | #define PAGESIZE 4096 |
| 76 | #endif | 69 | #endif |
| 77 | 70 | ||
| 78 | #include "elf.h" | ||
| 79 | #include "stab.h" | ||
| 80 | |||
| 81 | #ifndef O_BINARY | 71 | #ifndef O_BINARY |
| 82 | #define O_BINARY 0 | 72 | #define O_BINARY 0 |
| 83 | #endif | 73 | #endif |
| @@ -86,6 +76,8 @@ · 2 unmodified lines | |||
| 86 | #define SA_SIGINFO 0x00000004u | 76 | #define SA_SIGINFO 0x00000004u |
| 87 | #endif | 77 | #endif |
| 88 | 78 | ||
| 79 | #include "elf.h" | ||
| 80 | #include "stab.h" | ||
| 89 | #include "libtcc.h" | 81 | #include "libtcc.h" |
| 90 | 82 | ||
| 91 | /* parser debug */ | 83 | /* parser debug */ |
| @@ -131,8 +123,26 @@ · 39 unmodified lines | |||
| 131 | #define TCC_TARGET_COFF | 123 | #define TCC_TARGET_COFF |
| 132 | #endif | 124 | #endif |
| 133 | 125 | ||
| 134 | #if !defined(CONFIG_TCCBOOT) | 126 | /* only native compiler supports -run */ |
| 135 | #define CONFIG_TCC_BACKTRACE | 127 | #if defined _WIN32 == defined TCC_TARGET_PE |
| 128 | # if (defined __i386__ || defined _X86_) && defined TCC_TARGET_I386 | ||
| 129 | # define TCC_IS_NATIVE | ||
| 130 | # elif (defined __x86_64__ || defined _AMD64_) && defined TCC_TARGET_X86_64 | ||
| 131 | # define TCC_IS_NATIVE | ||
| 132 | # elif defined __arm__ && defined TCC_TARGET_ARM | ||
| 133 | # define TCC_IS_NATIVE | ||
| 134 | # endif | ||
| 135 | #endif | ||
| 136 | |||
| 137 | #if defined TCC_IS_NATIVE && !defined CONFIG_TCCBOOT | ||
| 138 | # define CONFIG_TCC_BACKTRACE | ||
| 139 | #endif | ||
| 140 | |||
| 141 | /* target address type */ | ||
| 142 | #if defined TCC_TARGET_X86_64 && (!defined __x86_64__ || defined _WIN32) | ||
| 143 | # define uplong unsigned long long | ||
| 144 | #else | ||
| 145 | # define uplong unsigned long | ||
| 136 | #endif | 146 | #endif |
| 137 | 147 | ||
| 138 | /* ------------ path configuration ------------ */ | 148 | /* ------------ path configuration ------------ */ |
| @@ -38,10 +38,6 @@ · 37 unmodified lines | |||
| 38 | # define ADDR3264 DWORD | 38 | # define ADDR3264 DWORD |
| 39 | #endif | 39 | #endif |
| 40 | 40 | ||
| 41 | #if defined _WIN32 && (defined _WIN64) == (defined TCC_TARGET_X86_64) | ||
| 42 | #define TCC_IS_NATIVE | ||
| 43 | #endif | ||
| 44 | |||
| 45 | #ifdef _WIN32 | 41 | #ifdef _WIN32 |
| 46 | void dbg_printf (const char *fmt, ...) | 42 | void dbg_printf (const char *fmt, ...) |
| 47 | { | 43 | { |
| @@ -339,7 +335,7 @@ struct pe_info { · 291 unmodified lines | |||
| 339 | const char *filename; | 335 | const char *filename; |
| 340 | int type; | 336 | int type; |
| 341 | DWORD sizeofheaders; | 337 | DWORD sizeofheaders; |
| 342 | DWORD imagebase; | 338 | ADDR3264 imagebase; |
| 343 | DWORD start_addr; | 339 | DWORD start_addr; |
| 344 | DWORD imp_offs; | 340 | DWORD imp_offs; |
| 345 | DWORD imp_size; | 341 | DWORD imp_size; |
| @@ -1870,11 +1866,10 @@ ST_FUNC int pe_output_file(TCCState * s1, const char *filename) · 1524 unmodified lines | |||
| 1870 | ret = pe_write(&pe); | 1866 | ret = pe_write(&pe); |
| 1871 | tcc_free(pe.sec_info); | 1867 | tcc_free(pe.sec_info); |
| 1872 | } else { | 1868 | } else { |
| 1873 | #ifndef TCC_IS_NATIVE | 1869 | #ifdef TCC_IS_NATIVE |
| 1874 | tcc_error_noabort("-run supported only on native platform"); | ||
| 1875 | #endif | ||
| 1876 | pe.thunk = data_section; | 1870 | pe.thunk = data_section; |
| 1877 | pe_build_imports(&pe); | 1871 | pe_build_imports(&pe); |
| 1872 | #endif | ||
| 1878 | } | 1873 | } |
| 1879 | 1874 | ||
| 1880 | #ifdef PE_PRINT_SECTIONS | 1875 | #ifdef PE_PRINT_SECTIONS |
| @@ -20,6 +20,9 @@ · 19 unmodified lines | |||
| 20 | 20 | ||
| 21 | #include "tcc.h" | 21 | #include "tcc.h" |
| 22 | 22 | ||
| 23 | /* only native compiler supports -run */ | ||
| 24 | #ifdef TCC_IS_NATIVE | ||
| 25 | |||
| 23 | #ifdef CONFIG_TCC_BACKTRACE | 26 | #ifdef CONFIG_TCC_BACKTRACE |
| 24 | ST_DATA int rt_num_callers = 6; | 27 | ST_DATA int rt_num_callers = 6; |
| 25 | ST_DATA const char **rt_bound_error_msg; | 28 | ST_DATA const char **rt_bound_error_msg; |
| @@ -217,6 +220,8 @@ static void set_pages_executable(void *ptr, unsigned long length) · 191 unmodified lines | |||
| 217 | } | 220 | } |
| 218 | 221 | ||
| 219 | /* ------------------------------------------------------------- */ | 222 | /* ------------------------------------------------------------- */ |
| 223 | #endif /* TCC_IS_NATIVE */ | ||
| 224 | |||
| 220 | #ifdef CONFIG_TCC_BACKTRACE | 225 | #ifdef CONFIG_TCC_BACKTRACE |
| 221 | 226 | ||
| 222 | PUB_FUNC void tcc_set_num_callers(int n) | 227 | PUB_FUNC void tcc_set_num_callers(int n) |