From 5775911dadef7c10eee8ee44db41c6aeb6b11e07 Mon Sep 17 00:00:00 2001 From: Andrew Mulbrook Date: Sat, 3 Mar 2012 10:12:06 -0600 Subject: [PATCH] Revert "Multiple fixes for 64 bit sections" This reverts commit d7a7c3769d0a1dcb8400258cd8adf78a8566de61. --- Makefile | 3 --- configure | 12 +++--------- libtcc.c | 9 +++++---- tcc.h | 11 +++++------ tccelf.c | 21 ++++++++------------- tccrun.c | 9 +++------ 6 files changed, 24 insertions(+), 41 deletions(-) diff --git a/Makefile b/Makefile index fb2f7216..ab9a698c 100644 --- a/Makefile +++ b/Makefile @@ -318,12 +318,9 @@ install: $(PROGS) $(TCCLIBS) $(TCCDOCS) ifdef CONFIG_CROSS mkdir -p "$(tccdir)/lib/32" mkdir -p "$(tccdir)/lib/64" -ifeq ($(ARCH),x86-64) -$(INSTALL) -m644 lib/i386-win32/libtcc1.a "$(tccdir)/lib/32" -else -$(INSTALL) -m644 lib/x86_64-win32/libtcc1.a "$(tccdir)/lib/64" endif -endif uninstall: rm -rfv "$(tccdir)/*" diff --git a/configure b/configure index ed6ca6f3..188c3609 100755 --- a/configure +++ b/configure @@ -154,8 +154,6 @@ for opt do ;; --enable-cygwin) mingw32="yes" ; cygwin="yes" ; cross_prefix="mingw32-" ; cpu=x86 ;; - --enable-cygwin64) mingw32="yes" ; cygwin="yes" ; cross_prefix="x86_64-w64-mingw32-" ; cpu="x86-64" - ;; --enable-cross) build_cross="yes" ;; --disable-static) disable_static="yes" @@ -433,18 +431,14 @@ if test "$noldl" = "yes" ; then echo "CONFIG_NOLDL=yes" >> config.mak fi if test "$mingw32" = "yes" ; then - if test "$cpu" = "x86-64" ; then - echo "CONFIG_WIN64=yes" >> config.mak - echo "#define CONFIG_WIN64 1" >> $TMPH - else - echo "CONFIG_WIN32=yes" >> config.mak - echo "#define CONFIG_WIN32 1" >> $TMPH - fi + echo "CONFIG_WIN32=yes" >> config.mak + echo "#define CONFIG_WIN32 1" >> $TMPH fi if test "$cygwin" = "yes" ; then echo "#ifndef _WIN32" >> $TMPH echo "#define _WIN32" >> $TMPH echo "#endif" >> $TMPH + echo "AR=ar" >> config.mak fi if test "$bigendian" = "yes" ; then echo "WORDS_BIGENDIAN=yes" >> config.mak diff --git a/libtcc.c b/libtcc.c index 5e497c92..93493481 100644 --- a/libtcc.c +++ b/libtcc.c @@ -425,7 +425,7 @@ ST_FUNC Section *find_section(TCCState *s1, const char *name) /* update sym->c so that it points to an external symbol in section 'section' with value 'value' */ ST_FUNC void put_extern_sym2(Sym *sym, Section *section, - uplong value, unsigned long size, + unsigned long value, unsigned long size, int can_add_underscore) { int sym_type, sym_bind, sh_num, info, other; @@ -529,7 +529,7 @@ ST_FUNC void put_extern_sym2(Sym *sym, Section *section, } ST_FUNC void put_extern_sym(Sym *sym, Section *section, - uplong value, unsigned long size) + unsigned long value, unsigned long size) { put_extern_sym2(sym, section, value, size, 1); } @@ -1494,7 +1494,7 @@ PUB_FUNC const char * tcc_set_linker(TCCState *s, char *option, int multi) if (s->warn_unsupported) tcc_warning("ignoring -fini %s", p); } else if (link_option(option, "image-base=", &p)) { - s->text_addr = strtoull(p, &end, 16); + s->text_addr = strtoul(p, &end, 16); s->has_text_addr = 1; } else if (link_option(option, "init=", &p)) { s->init_symbol = p; @@ -1563,8 +1563,9 @@ PUB_FUNC const char * tcc_set_linker(TCCState *s, char *option, int multi) #endif } else if (link_option(option, "Ttext=", &p)) { - s->text_addr = strtoull(p, &end, 16); + s->text_addr = strtoul(p, &end, 16); s->has_text_addr = 1; + } else { return option; } diff --git a/tcc.h b/tcc.h index 18a6b91c..d158829a 100644 --- a/tcc.h +++ b/tcc.h @@ -313,8 +313,8 @@ typedef struct Section { int sh_addralign; /* elf section alignment */ int sh_entsize; /* elf entry size */ unsigned long sh_size; /* section size (only used during output) */ - uplong sh_addr; /* address at which the section is relocated */ - unsigned long sh_offset; /* file offset */ + unsigned long sh_addr; /* address at which the section is relocated */ + unsigned long sh_offset; /* file offset */ int nb_hashed_syms; /* used to resize the hash table */ struct Section *link; /* link to another section */ struct Section *reloc; /* corresponding section for relocation, if any */ @@ -531,7 +531,7 @@ struct TCCState { int alacarte_link; /* address of text section */ - uplong text_addr; + unsigned long text_addr; int has_text_addr; /* symbols to call at load-time / unload-time */ @@ -872,7 +872,6 @@ enum tcc_token { #define strtold (long double)strtod #define strtof (float)strtod #define strtoll (long long)strtol - #define strtoull (unsigned long long)strtoull #endif #else /* 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); ST_FUNC void section_reserve(Section *sec, unsigned long size); ST_FUNC Section *find_section(TCCState *s1, const char *name); -ST_FUNC void put_extern_sym2(Sym *sym, Section *section, uplong value, unsigned long size, int can_add_underscore); -ST_FUNC void put_extern_sym(Sym *sym, Section *section, uplong value, unsigned long size); +ST_FUNC void put_extern_sym2(Sym *sym, Section *section, unsigned long value, unsigned long size, int can_add_underscore); +ST_FUNC void put_extern_sym(Sym *sym, Section *section, unsigned long value, unsigned long size); ST_FUNC void greloc(Section *s, Sym *sym, unsigned long offset, int type); ST_INLN void sym_free(Sym *sym); diff --git a/tccelf.c b/tccelf.c index 2b4b0ab3..40c88ab1 100644 --- a/tccelf.c +++ b/tccelf.c @@ -1153,7 +1153,7 @@ ST_FUNC Section *new_symtab(TCCState *s1, } /* put dynamic tag */ -static void put_dt(Section *dynamic, int dt, uplong val) +static void put_dt(Section *dynamic, int dt, unsigned long val) { ElfW(Dyn) *dyn; dyn = section_ptr_add(dynamic, sizeof(ElfW(Dyn))); @@ -1381,7 +1381,7 @@ ST_FUNC void fill_got_entry(TCCState *s1, ElfW_Rel *rel) section_reserve(s1->got, offset + PTR_SIZE); #ifdef TCC_TARGET_X86_64 /* only works for x86-64 */ - put32(s1->got->data + offset + 4, sym->st_value >> 32); + put32(s1->got->data + offset, sym->st_value >> 32); #endif put32(s1->got->data + offset, sym->st_value & 0xffffffff); } @@ -1421,9 +1421,8 @@ static int elf_output_file(TCCState *s1, const char *filename) FILE *f; int fd, mode, ret; int *section_order; - int shnum, i, phnum, file_offset, offset, size, j, sh_order_index, k; - long long tmp; - uplong addr; + int shnum, i, phnum, file_offset, offset, size, j, tmp, sh_order_index, k; + unsigned long addr; Section *strsec, *s; ElfW(Shdr) shdr, *sh; ElfW(Phdr) *phdr, *ph; @@ -1431,9 +1430,9 @@ static int elf_output_file(TCCState *s1, const char *filename) unsigned long saved_dynamic_data_offset; ElfW(Sym) *sym; int type, file_type; - uplong rel_addr, rel_size; + unsigned long rel_addr, rel_size; #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - uplong bss_addr, bss_size; + unsigned long bss_addr, bss_size; #endif file_type = s1->output_type; @@ -1748,7 +1747,7 @@ static int elf_output_file(TCCState *s1, const char *filename) addr = s1->text_addr; /* we ensure that (addr % ELF_PAGE_SIZE) == file_offset % ELF_PAGE_SIZE */ - a_offset = ((int) addr) & (s1->section_align - 1); + a_offset = addr & (s1->section_align - 1); p_offset = file_offset & (s1->section_align - 1); if (a_offset < p_offset) a_offset += s1->section_align; @@ -1822,7 +1821,7 @@ static int elf_output_file(TCCState *s1, const char *filename) tmp = addr; addr = (addr + s->sh_addralign - 1) & ~(s->sh_addralign - 1); - file_offset += (int) ( addr - tmp ); + file_offset += addr - tmp; s->sh_offset = file_offset; s->sh_addr = addr; @@ -1916,12 +1915,8 @@ static int elf_output_file(TCCState *s1, const char *filename) ph->p_align = dynamic->sh_addralign; /* put GOT dynamic section address */ -#if defined(TCC_TARGET_X86_64) - put32(s1->got->data + 4, dynamic->sh_addr >> 32 ); -#endif put32(s1->got->data, dynamic->sh_addr); - /* relocate the PLT */ if (file_type == TCC_OUTPUT_EXE #if defined(TCC_OUTPUT_DLL_WITH_PLT) diff --git a/tccrun.c b/tccrun.c index 2ea3c491..de0ef891 100644 --- a/tccrun.c +++ b/tccrun.c @@ -36,11 +36,10 @@ static int rt_get_caller_pc(uplong *paddr, ucontext_t *uc, int level); static void rt_error(ucontext_t *uc, const char *fmt, ...); static int tcc_relocate_ex(TCCState *s1, void *ptr); -#if defined TCC_TARGET_X86_64 && defined TCC_TARGET_PE +#ifdef _WIN64 static void win64_add_function_table(TCCState *s1); #endif - /* ------------------------------------------------------------- */ /* Do all relocations (needed before using tcc_get_symbol()) Returns -1 on error. */ @@ -194,7 +193,7 @@ static int tcc_relocate_ex(TCCState *s1, void *ptr) s1->runtime_plt_and_got_offset); #endif -#if defined TCC_TARGET_X86_64 && defined TCC_TARGET_PE +#ifdef _WIN64 win64_add_function_table(s1); #endif return 0; @@ -622,8 +621,7 @@ static void set_exception_handler(void) SetUnhandledExceptionFilter(cpu_exception_handler); } -#ifdef TCC_TARGET_PE -#ifdef TCC_TARGET_X86_64 +#ifdef _WIN64 static void win64_add_function_table(TCCState *s1) { RtlAddFunctionTable( @@ -633,7 +631,6 @@ static void win64_add_function_table(TCCState *s1) ); } #endif -#endif /* return the PC at frame level 'level'. Return non zero if not found */ static int rt_get_caller_pc(uplong *paddr, CONTEXT *uc, int level) -- 2.11.4.GIT