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