This reverts commit d7a7c3769d0a1dcb8400258cd8adf78a8566de61.
Unified · Split
| @@ -318,12 +318,9 @@ install: $(PROGS) $(TCCLIBS) $(TCCDOCS) · 317 unmodified lines | |||
| 318 | ifdef CONFIG_CROSS | 318 | ifdef CONFIG_CROSS |
| 319 | mkdir -p "$(tccdir)/lib/32" | 319 | mkdir -p "$(tccdir)/lib/32" |
| 320 | mkdir -p "$(tccdir)/lib/64" | 320 | mkdir -p "$(tccdir)/lib/64" |
| 321 | ifeq ($(ARCH),x86-64) | ||
| 322 | -$(INSTALL) -m644 lib/i386-win32/libtcc1.a "$(tccdir)/lib/32" | 321 | -$(INSTALL) -m644 lib/i386-win32/libtcc1.a "$(tccdir)/lib/32" |
| 323 | else | ||
| 324 | -$(INSTALL) -m644 lib/x86_64-win32/libtcc1.a "$(tccdir)/lib/64" | 322 | -$(INSTALL) -m644 lib/x86_64-win32/libtcc1.a "$(tccdir)/lib/64" |
| 325 | endif | 323 | endif |
| 326 | endif | ||
| 327 | 324 | ||
| 328 | uninstall: | 325 | uninstall: |
| 329 | rm -rfv "$(tccdir)/*" | 326 | rm -rfv "$(tccdir)/*" |
| @@ -154,8 +154,6 @@ for opt do · 153 unmodified lines | |||
| 154 | ;; | 154 | ;; |
| 155 | --enable-cygwin) mingw32="yes" ; cygwin="yes" ; cross_prefix="mingw32-" ; cpu=x86 | 155 | --enable-cygwin) mingw32="yes" ; cygwin="yes" ; cross_prefix="mingw32-" ; cpu=x86 |
| 156 | ;; | 156 | ;; |
| 157 | --enable-cygwin64) mingw32="yes" ; cygwin="yes" ; cross_prefix="x86_64-w64-mingw32-" ; cpu="x86-64" | ||
| 158 | ;; | ||
| 159 | --enable-cross) build_cross="yes" | 157 | --enable-cross) build_cross="yes" |
| 160 | ;; | 158 | ;; |
| 161 | --disable-static) disable_static="yes" | 159 | --disable-static) disable_static="yes" |
| @@ -433,18 +431,14 @@ if test "$noldl" = "yes" ; then · 271 unmodified lines | |||
| 433 | echo "CONFIG_NOLDL=yes" >> config.mak | 431 | echo "CONFIG_NOLDL=yes" >> config.mak |
| 434 | fi | 432 | fi |
| 435 | if test "$mingw32" = "yes" ; then | 433 | if test "$mingw32" = "yes" ; then |
| 436 | if test "$cpu" = "x86-64" ; then | 434 | echo "CONFIG_WIN32=yes" >> config.mak |
| 437 | echo "CONFIG_WIN64=yes" >> config.mak | 435 | echo "#define CONFIG_WIN32 1" >> $TMPH |
| 438 | echo "#define CONFIG_WIN64 1" >> $TMPH | ||
| 439 | else | ||
| 440 | echo "CONFIG_WIN32=yes" >> config.mak | ||
| 441 | echo "#define CONFIG_WIN32 1" >> $TMPH | ||
| 442 | fi | ||
| 443 | fi | 436 | fi |
| 444 | if test "$cygwin" = "yes" ; then | 437 | if test "$cygwin" = "yes" ; then |
| 445 | echo "#ifndef _WIN32" >> $TMPH | 438 | echo "#ifndef _WIN32" >> $TMPH |
| 446 | echo "#define _WIN32" >> $TMPH | 439 | echo "#define _WIN32" >> $TMPH |
| 447 | echo "#endif" >> $TMPH | 440 | echo "#endif" >> $TMPH |
| 441 | echo "AR=ar" >> config.mak | ||
| 448 | fi | 442 | fi |
| 449 | if test "$bigendian" = "yes" ; then | 443 | if test "$bigendian" = "yes" ; then |
| 450 | echo "WORDS_BIGENDIAN=yes" >> config.mak | 444 | echo "WORDS_BIGENDIAN=yes" >> config.mak |
| @@ -425,7 +425,7 @@ ST_FUNC Section *find_section(TCCState *s1, const char *name) · 424 unmodified lines | |||
| 425 | /* update sym->c so that it points to an external symbol in section | 425 | /* update sym->c so that it points to an external symbol in section |
| 426 | 'section' with value 'value' */ | 426 | 'section' with value 'value' */ |
| 427 | ST_FUNC void put_extern_sym2(Sym *sym, Section *section, | 427 | ST_FUNC void put_extern_sym2(Sym *sym, Section *section, |
| 428 | uplong value, unsigned long size, | 428 | unsigned long value, unsigned long size, |
| 429 | int can_add_underscore) | 429 | int can_add_underscore) |
| 430 | { | 430 | { |
| 431 | int sym_type, sym_bind, sh_num, info, other; | 431 | int sym_type, sym_bind, sh_num, info, other; |
| @@ -529,7 +529,7 @@ ST_FUNC void put_extern_sym2(Sym *sym, Section *section, · 97 unmodified lines | |||
| 529 | } | 529 | } |
| 530 | 530 | ||
| 531 | ST_FUNC void put_extern_sym(Sym *sym, Section *section, | 531 | ST_FUNC void put_extern_sym(Sym *sym, Section *section, |
| 532 | uplong value, unsigned long size) | 532 | unsigned long value, unsigned long size) |
| 533 | { | 533 | { |
| 534 | put_extern_sym2(sym, section, value, size, 1); | 534 | put_extern_sym2(sym, section, value, size, 1); |
| 535 | } | 535 | } |
| @@ -1494,7 +1494,7 @@ PUB_FUNC const char * tcc_set_linker(TCCState *s, char *option, int multi) · 958 unmodified lines | |||
| 1494 | if (s->warn_unsupported) | 1494 | if (s->warn_unsupported) |
| 1495 | tcc_warning("ignoring -fini %s", p); | 1495 | tcc_warning("ignoring -fini %s", p); |
| 1496 | } else if (link_option(option, "image-base=", &p)) { | 1496 | } else if (link_option(option, "image-base=", &p)) { |
| 1497 | s->text_addr = strtoull(p, &end, 16); | 1497 | s->text_addr = strtoul(p, &end, 16); |
| 1498 | s->has_text_addr = 1; | 1498 | s->has_text_addr = 1; |
| 1499 | } else if (link_option(option, "init=", &p)) { | 1499 | } else if (link_option(option, "init=", &p)) { |
| 1500 | s->init_symbol = p; | 1500 | s->init_symbol = p; |
| @@ -1563,8 +1563,9 @@ PUB_FUNC const char * tcc_set_linker(TCCState *s, char *option, int multi) · 62 unmodified lines | |||
| 1563 | #endif | 1563 | #endif |
| 1564 | 1564 | ||
| 1565 | } else if (link_option(option, "Ttext=", &p)) { | 1565 | } else if (link_option(option, "Ttext=", &p)) { |
| 1566 | s->text_addr = strtoull(p, &end, 16); | 1566 | s->text_addr = strtoul(p, &end, 16); |
| 1567 | s->has_text_addr = 1; | 1567 | s->has_text_addr = 1; |
| 1568 | |||
| 1568 | } else { | 1569 | } else { |
| 1569 | return option; | 1570 | return option; |
| 1570 | } | 1571 | } |
| @@ -313,8 +313,8 @@ typedef struct Section { · 312 unmodified lines | |||
| 313 | int sh_addralign; /* elf section alignment */ | 313 | int sh_addralign; /* elf section alignment */ |
| 314 | int sh_entsize; /* elf entry size */ | 314 | int sh_entsize; /* elf entry size */ |
| 315 | unsigned long sh_size; /* section size (only used during output) */ | 315 | unsigned long sh_size; /* section size (only used during output) */ |
| 316 | uplong sh_addr; /* address at which the section is relocated */ | 316 | unsigned long sh_addr; /* address at which the section is relocated */ |
| 317 | unsigned long sh_offset; /* file offset */ | 317 | unsigned long sh_offset; /* file offset */ |
| 318 | int nb_hashed_syms; /* used to resize the hash table */ | 318 | int nb_hashed_syms; /* used to resize the hash table */ |
| 319 | struct Section *link; /* link to another section */ | 319 | struct Section *link; /* link to another section */ |
| 320 | struct Section *reloc; /* corresponding section for relocation, if any */ | 320 | struct Section *reloc; /* corresponding section for relocation, if any */ |
| @@ -531,7 +531,7 @@ struct TCCState { · 210 unmodified lines | |||
| 531 | int alacarte_link; | 531 | int alacarte_link; |
| 532 | 532 | ||
| 533 | /* address of text section */ | 533 | /* address of text section */ |
| 534 | uplong text_addr; | 534 | unsigned long text_addr; |
| 535 | int has_text_addr; | 535 | int has_text_addr; |
| 536 | 536 | ||
| 537 | /* symbols to call at load-time / unload-time */ | 537 | /* symbols to call at load-time / unload-time */ |
| @@ -872,7 +872,6 @@ enum tcc_token { · 334 unmodified lines | |||
| 872 | #define strtold (long double)strtod | 872 | #define strtold (long double)strtod |
| 873 | #define strtof (float)strtod | 873 | #define strtof (float)strtod |
| 874 | #define strtoll (long long)strtol | 874 | #define strtoll (long long)strtol |
| 875 | #define strtoull (unsigned long long)strtoull | ||
| 876 | #endif | 875 | #endif |
| 877 | #else | 876 | #else |
| 878 | /* XXX: need to define this to use them in non ISOC99 context */ | 877 | /* XXX: need to define this to use them in non ISOC99 context */ |
| @@ -993,8 +992,8 @@ ST_FUNC void *section_ptr_add(Section *sec, unsigned long size); · 114 unmodified lines | |||
| 993 | ST_FUNC void section_reserve(Section *sec, unsigned long size); | 992 | ST_FUNC void section_reserve(Section *sec, unsigned long size); |
| 994 | ST_FUNC Section *find_section(TCCState *s1, const char *name); | 993 | ST_FUNC Section *find_section(TCCState *s1, const char *name); |
| 995 | 994 | ||
| 996 | ST_FUNC void put_extern_sym2(Sym *sym, Section *section, uplong value, unsigned long size, int can_add_underscore); | 995 | ST_FUNC void put_extern_sym2(Sym *sym, Section *section, unsigned long value, unsigned long size, int can_add_underscore); |
| 997 | ST_FUNC void put_extern_sym(Sym *sym, Section *section, uplong value, unsigned long size); | 996 | ST_FUNC void put_extern_sym(Sym *sym, Section *section, unsigned long value, unsigned long size); |
| 998 | ST_FUNC void greloc(Section *s, Sym *sym, unsigned long offset, int type); | 997 | ST_FUNC void greloc(Section *s, Sym *sym, unsigned long offset, int type); |
| 999 | 998 | ||
| 1000 | ST_INLN void sym_free(Sym *sym); | 999 | ST_INLN void sym_free(Sym *sym); |
| @@ -1153,7 +1153,7 @@ ST_FUNC Section *new_symtab(TCCState *s1, · 1152 unmodified lines | |||
| 1153 | } | 1153 | } |
| 1154 | 1154 | ||
| 1155 | /* put dynamic tag */ | 1155 | /* put dynamic tag */ |
| 1156 | static void put_dt(Section *dynamic, int dt, uplong val) | 1156 | static void put_dt(Section *dynamic, int dt, unsigned long val) |
| 1157 | { | 1157 | { |
| 1158 | ElfW(Dyn) *dyn; | 1158 | ElfW(Dyn) *dyn; |
| 1159 | dyn = section_ptr_add(dynamic, sizeof(ElfW(Dyn))); | 1159 | dyn = section_ptr_add(dynamic, sizeof(ElfW(Dyn))); |
| @@ -1381,7 +1381,7 @@ ST_FUNC void fill_got_entry(TCCState *s1, ElfW_Rel *rel) · 221 unmodified lines | |||
| 1381 | section_reserve(s1->got, offset + PTR_SIZE); | 1381 | section_reserve(s1->got, offset + PTR_SIZE); |
| 1382 | #ifdef TCC_TARGET_X86_64 | 1382 | #ifdef TCC_TARGET_X86_64 |
| 1383 | /* only works for x86-64 */ | 1383 | /* only works for x86-64 */ |
| 1384 | put32(s1->got->data + offset + 4, sym->st_value >> 32); | 1384 | put32(s1->got->data + offset, sym->st_value >> 32); |
| 1385 | #endif | 1385 | #endif |
| 1386 | put32(s1->got->data + offset, sym->st_value & 0xffffffff); | 1386 | put32(s1->got->data + offset, sym->st_value & 0xffffffff); |
| 1387 | } | 1387 | } |
| @@ -1421,9 +1421,8 @@ static int elf_output_file(TCCState *s1, const char *filename) · 33 unmodified lines | |||
| 1421 | FILE *f; | 1421 | FILE *f; |
| 1422 | int fd, mode, ret; | 1422 | int fd, mode, ret; |
| 1423 | int *section_order; | 1423 | int *section_order; |
| 1424 | int shnum, i, phnum, file_offset, offset, size, j, sh_order_index, k; | 1424 | int shnum, i, phnum, file_offset, offset, size, j, tmp, sh_order_index, k; |
| 1425 | long long tmp; | 1425 | unsigned long addr; |
| 1426 | uplong addr; | ||
| 1427 | Section *strsec, *s; | 1426 | Section *strsec, *s; |
| 1428 | ElfW(Shdr) shdr, *sh; | 1427 | ElfW(Shdr) shdr, *sh; |
| 1429 | ElfW(Phdr) *phdr, *ph; | 1428 | ElfW(Phdr) *phdr, *ph; |
| @@ -1431,9 +1430,9 @@ static int elf_output_file(TCCState *s1, const char *filename) · 1 unmodified line | |||
| 1431 | unsigned long saved_dynamic_data_offset; | 1430 | unsigned long saved_dynamic_data_offset; |
| 1432 | ElfW(Sym) *sym; | 1431 | ElfW(Sym) *sym; |
| 1433 | int type, file_type; | 1432 | int type, file_type; |
| 1434 | uplong rel_addr, rel_size; | 1433 | unsigned long rel_addr, rel_size; |
| 1435 | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) | 1434 | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) |
| 1436 | uplong bss_addr, bss_size; | 1435 | unsigned long bss_addr, bss_size; |
| 1437 | #endif | 1436 | #endif |
| 1438 | 1437 | ||
| 1439 | file_type = s1->output_type; | 1438 | file_type = s1->output_type; |
| @@ -1748,7 +1747,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 308 unmodified lines | |||
| 1748 | addr = s1->text_addr; | 1747 | addr = s1->text_addr; |
| 1749 | /* we ensure that (addr % ELF_PAGE_SIZE) == file_offset % | 1748 | /* we ensure that (addr % ELF_PAGE_SIZE) == file_offset % |
| 1750 | ELF_PAGE_SIZE */ | 1749 | ELF_PAGE_SIZE */ |
| 1751 | a_offset = ((int) addr) & (s1->section_align - 1); | 1750 | a_offset = addr & (s1->section_align - 1); |
| 1752 | p_offset = file_offset & (s1->section_align - 1); | 1751 | p_offset = file_offset & (s1->section_align - 1); |
| 1753 | if (a_offset < p_offset) | 1752 | if (a_offset < p_offset) |
| 1754 | a_offset += s1->section_align; | 1753 | a_offset += s1->section_align; |
| @@ -1822,7 +1821,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 67 unmodified lines | |||
| 1822 | tmp = addr; | 1821 | tmp = addr; |
| 1823 | addr = (addr + s->sh_addralign - 1) & | 1822 | addr = (addr + s->sh_addralign - 1) & |
| 1824 | ~(s->sh_addralign - 1); | 1823 | ~(s->sh_addralign - 1); |
| 1825 | file_offset += (int) ( addr - tmp ); | 1824 | file_offset += addr - tmp; |
| 1826 | s->sh_offset = file_offset; | 1825 | s->sh_offset = file_offset; |
| 1827 | s->sh_addr = addr; | 1826 | s->sh_addr = addr; |
| 1828 | 1827 | ||
| @@ -1916,12 +1915,8 @@ static int elf_output_file(TCCState *s1, const char *filename) · 87 unmodified lines | |||
| 1916 | ph->p_align = dynamic->sh_addralign; | 1915 | ph->p_align = dynamic->sh_addralign; |
| 1917 | 1916 | ||
| 1918 | /* put GOT dynamic section address */ | 1917 | /* put GOT dynamic section address */ |
| 1919 | #if defined(TCC_TARGET_X86_64) | ||
| 1920 | put32(s1->got->data + 4, dynamic->sh_addr >> 32 ); | ||
| 1921 | #endif | ||
| 1922 | put32(s1->got->data, dynamic->sh_addr); | 1918 | put32(s1->got->data, dynamic->sh_addr); |
| 1923 | 1919 | ||
| 1924 | |||
| 1925 | /* relocate the PLT */ | 1920 | /* relocate the PLT */ |
| 1926 | if (file_type == TCC_OUTPUT_EXE | 1921 | if (file_type == TCC_OUTPUT_EXE |
| 1927 | #if defined(TCC_OUTPUT_DLL_WITH_PLT) | 1922 | #if defined(TCC_OUTPUT_DLL_WITH_PLT) |
| @@ -36,11 +36,10 @@ static int rt_get_caller_pc(uplong *paddr, ucontext_t *uc, int level); · 35 unmodified lines | |||
| 36 | static void rt_error(ucontext_t *uc, const char *fmt, ...); | 36 | static void rt_error(ucontext_t *uc, const char *fmt, ...); |
| 37 | static int tcc_relocate_ex(TCCState *s1, void *ptr); | 37 | static int tcc_relocate_ex(TCCState *s1, void *ptr); |
| 38 | 38 | ||
| 39 | #if defined TCC_TARGET_X86_64 && defined TCC_TARGET_PE | 39 | #ifdef _WIN64 |
| 40 | static void win64_add_function_table(TCCState *s1); | 40 | static void win64_add_function_table(TCCState *s1); |
| 41 | #endif | 41 | #endif |
| 42 | 42 | ||
| 43 | |||
| 44 | /* ------------------------------------------------------------- */ | 43 | /* ------------------------------------------------------------- */ |
| 45 | /* Do all relocations (needed before using tcc_get_symbol()) | 44 | /* Do all relocations (needed before using tcc_get_symbol()) |
| 46 | Returns -1 on error. */ | 45 | Returns -1 on error. */ |
| @@ -194,7 +193,7 @@ static int tcc_relocate_ex(TCCState *s1, void *ptr) · 147 unmodified lines | |||
| 194 | s1->runtime_plt_and_got_offset); | 193 | s1->runtime_plt_and_got_offset); |
| 195 | #endif | 194 | #endif |
| 196 | 195 | ||
| 197 | #if defined TCC_TARGET_X86_64 && defined TCC_TARGET_PE | 196 | #ifdef _WIN64 |
| 198 | win64_add_function_table(s1); | 197 | win64_add_function_table(s1); |
| 199 | #endif | 198 | #endif |
| 200 | return 0; | 199 | return 0; |
| @@ -622,8 +621,7 @@ static void set_exception_handler(void) · 421 unmodified lines | |||
| 622 | SetUnhandledExceptionFilter(cpu_exception_handler); | 621 | SetUnhandledExceptionFilter(cpu_exception_handler); |
| 623 | } | 622 | } |
| 624 | 623 | ||
| 625 | #ifdef TCC_TARGET_PE | 624 | #ifdef _WIN64 |
| 626 | #ifdef TCC_TARGET_X86_64 | ||
| 627 | static void win64_add_function_table(TCCState *s1) | 625 | static void win64_add_function_table(TCCState *s1) |
| 628 | { | 626 | { |
| 629 | RtlAddFunctionTable( | 627 | RtlAddFunctionTable( |
| @@ -633,7 +631,6 @@ static void win64_add_function_table(TCCState *s1) · 3 unmodified lines | |||
| 633 | ); | 631 | ); |
| 634 | } | 632 | } |
| 635 | #endif | 633 | #endif |
| 636 | #endif | ||
| 637 | 634 | ||
| 638 | /* return the PC at frame level 'level'. Return non zero if not found */ | 635 | /* return the PC at frame level 'level'. Return non zero if not found */ |
| 639 | static int rt_get_caller_pc(uplong *paddr, CONTEXT *uc, int level) | 636 | static int rt_get_caller_pc(uplong *paddr, CONTEXT *uc, int level) |