- 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 | 578 | tcc_print_stats(s, getclock_us() - start_time); |
| 579 | 579 | |
| 580 | 580 | if (s->output_type == TCC_OUTPUT_MEMORY) { |
| 581 | +#ifdef TCC_IS_NATIVE | |
| 581 | 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 | 586 | } else if (s->output_type == TCC_OUTPUT_PREPROCESS) { |
| 583 | 587 | if (s->outfile) |
| 584 | 588 | fclose(s->outfile); |
| @@ -49,9 +49,6 @@ · 48 unmodified lines | ||
| 49 | 49 | #include <direct.h> /* getcwd */ |
| 50 | 50 | #define inline __inline |
| 51 | 51 | #define inp next_inp |
| 52 | −#ifdef _WIN64 | |
| 53 | −# define uplong unsigned long long | |
| 54 | −#endif | |
| 55 | 52 | #ifdef LIBTCC_AS_DLL |
| 56 | 53 | # define LIBTCCAPI __declspec(dllexport) |
| 57 | 54 | #endif |
| @@ -67,17 +64,10 @@ · 9 unmodified lines | ||
| 67 | 64 | |
| 68 | 65 | #endif /* !CONFIG_TCCBOOT */ |
| 69 | 66 | |
| 70 | −#ifndef uplong | |
| 71 | −#define uplong unsigned long | |
| 72 | −#endif | |
| 73 | − | |
| 74 | 67 | #ifndef PAGESIZE |
| 75 | 68 | #define PAGESIZE 4096 |
| 76 | 69 | #endif |
| 77 | 70 | |
| 78 | −#include "elf.h" | |
| 79 | −#include "stab.h" | |
| 80 | − | |
| 81 | 71 | #ifndef O_BINARY |
| 82 | 72 | #define O_BINARY 0 |
| 83 | 73 | #endif |
| @@ -86,6 +76,8 @@ · 2 unmodified lines | ||
| 86 | 76 | #define SA_SIGINFO 0x00000004u |
| 87 | 77 | #endif |
| 88 | 78 | |
| 79 | +#include "elf.h" | |
| 80 | +#include "stab.h" | |
| 89 | 81 | #include "libtcc.h" |
| 90 | 82 | |
| 91 | 83 | /* parser debug */ |
| @@ -131,8 +123,26 @@ · 39 unmodified lines | ||
| 131 | 123 | #define TCC_TARGET_COFF |
| 132 | 124 | #endif |
| 133 | 125 | |
| 134 | −#if !defined(CONFIG_TCCBOOT) | |
| 135 | −#define CONFIG_TCC_BACKTRACE | |
| 126 | +/* only native compiler supports -run */ | |
| 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 | 146 | #endif |
| 137 | 147 | |
| 138 | 148 | /* ------------ path configuration ------------ */ |
| @@ -38,10 +38,6 @@ · 37 unmodified lines | ||
| 38 | 38 | # define ADDR3264 DWORD |
| 39 | 39 | #endif |
| 40 | 40 | |
| 41 | −#if defined _WIN32 && (defined _WIN64) == (defined TCC_TARGET_X86_64) | |
| 42 | −#define TCC_IS_NATIVE | |
| 43 | −#endif | |
| 44 | − | |
| 45 | 41 | #ifdef _WIN32 |
| 46 | 42 | void dbg_printf (const char *fmt, ...) |
| 47 | 43 | { |
| @@ -339,7 +335,7 @@ struct pe_info { · 291 unmodified lines | ||
| 339 | 335 | const char *filename; |
| 340 | 336 | int type; |
| 341 | 337 | DWORD sizeofheaders; |
| 342 | − DWORD imagebase; | |
| 338 | + ADDR3264 imagebase; | |
| 343 | 339 | DWORD start_addr; |
| 344 | 340 | DWORD imp_offs; |
| 345 | 341 | DWORD imp_size; |
| @@ -1870,11 +1866,10 @@ ST_FUNC int pe_output_file(TCCState * s1, const char *filename) · 1524 unmodified lines | ||
| 1870 | 1866 | ret = pe_write(&pe); |
| 1871 | 1867 | tcc_free(pe.sec_info); |
| 1872 | 1868 | } else { |
| 1873 | −#ifndef TCC_IS_NATIVE | |
| 1874 | − tcc_error_noabort("-run supported only on native platform"); | |
| 1875 | −#endif | |
| 1869 | +#ifdef TCC_IS_NATIVE | |
| 1876 | 1870 | pe.thunk = data_section; |
| 1877 | 1871 | pe_build_imports(&pe); |
| 1872 | +#endif | |
| 1878 | 1873 | } |
| 1879 | 1874 | |
| 1880 | 1875 | #ifdef PE_PRINT_SECTIONS |
| @@ -20,6 +20,9 @@ · 19 unmodified lines | ||
| 20 | 20 | |
| 21 | 21 | #include "tcc.h" |
| 22 | 22 | |
| 23 | +/* only native compiler supports -run */ | |
| 24 | +#ifdef TCC_IS_NATIVE | |
| 25 | + | |
| 23 | 26 | #ifdef CONFIG_TCC_BACKTRACE |
| 24 | 27 | ST_DATA int rt_num_callers = 6; |
| 25 | 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 | 225 | #ifdef CONFIG_TCC_BACKTRACE |
| 221 | 226 | |
| 222 | 227 | PUB_FUNC void tcc_set_num_callers(int n) |