History

Revert "Multiple fixes for 64 bit sections"

This reverts commit d7a7c3769d0a1dcb8400258cd8adf78a8566de61.

Andrew Mulbrook committed 14 years ago

Commit 57759111 parent e343b1d6 files · +24 −41Browse files

Unified · Split

6 files
  1. Makefile +0 −3
  2. configure +3 −9
  3. libtcc.c +5 −4
  4. tcc.h +5 −6
  5. tccelf.c +8 −13
  6. tccrun.c +3 −6
Makefile+0−3
@@ -318,12 +318,9 @@ install: $(PROGS) $(TCCLIBS) $(TCCDOCS) · 317 unmodified lines
318318 ifdef CONFIG_CROSS
319319 mkdir -p "$(tccdir)/lib/32"
320320 mkdir -p "$(tccdir)/lib/64"
321−ifeq ($(ARCH),x86-64)
322321 -$(INSTALL) -m644 lib/i386-win32/libtcc1.a "$(tccdir)/lib/32"
323−else
324322 -$(INSTALL) -m644 lib/x86_64-win32/libtcc1.a "$(tccdir)/lib/64"
325323 endif
326−endif
327324
328325 uninstall:
329326 rm -rfv "$(tccdir)/*"
configure+3−9
@@ -154,8 +154,6 @@ for opt do · 153 unmodified lines
154154 ;;
155155 --enable-cygwin) mingw32="yes" ; cygwin="yes" ; cross_prefix="mingw32-" ; cpu=x86
156156 ;;
157− --enable-cygwin64) mingw32="yes" ; cygwin="yes" ; cross_prefix="x86_64-w64-mingw32-" ; cpu="x86-64"
158− ;;
159157 --enable-cross) build_cross="yes"
160158 ;;
161159 --disable-static) disable_static="yes"
@@ -433,18 +431,14 @@ if test "$noldl" = "yes" ; then · 271 unmodified lines
433431 echo "CONFIG_NOLDL=yes" >> config.mak
434432 fi
435433 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
443436 fi
444437 if test "$cygwin" = "yes" ; then
445438 echo "#ifndef _WIN32" >> $TMPH
446439 echo "#define _WIN32" >> $TMPH
447440 echo "#endif" >> $TMPH
441+ echo "AR=ar" >> config.mak
448442 fi
449443 if test "$bigendian" = "yes" ; then
450444 echo "WORDS_BIGENDIAN=yes" >> config.mak
libtcc.c+5−4
@@ -425,7 +425,7 @@ ST_FUNC Section *find_section(TCCState *s1, const char *name) · 424 unmodified lines
425425 /* update sym->c so that it points to an external symbol in section
426426 'section' with value 'value' */
427427 ST_FUNC void put_extern_sym2(Sym *sym, Section *section,
428− uplong value, unsigned long size,
428+ unsigned long value, unsigned long size,
429429 int can_add_underscore)
430430 {
431431 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
529529 }
530530
531531 ST_FUNC void put_extern_sym(Sym *sym, Section *section,
532− uplong value, unsigned long size)
532+ unsigned long value, unsigned long size)
533533 {
534534 put_extern_sym2(sym, section, value, size, 1);
535535 }
@@ -1494,7 +1494,7 @@ PUB_FUNC const char * tcc_set_linker(TCCState *s, char *option, int multi) · 958 unmodified lines
14941494 if (s->warn_unsupported)
14951495 tcc_warning("ignoring -fini %s", p);
14961496 } else if (link_option(option, "image-base=", &p)) {
1497− s->text_addr = strtoull(p, &end, 16);
1497+ s->text_addr = strtoul(p, &end, 16);
14981498 s->has_text_addr = 1;
14991499 } else if (link_option(option, "init=", &p)) {
15001500 s->init_symbol = p;
@@ -1563,8 +1563,9 @@ PUB_FUNC const char * tcc_set_linker(TCCState *s, char *option, int multi) · 62 unmodified lines
15631563 #endif
15641564
15651565 } else if (link_option(option, "Ttext=", &p)) {
1566− s->text_addr = strtoull(p, &end, 16);
1566+ s->text_addr = strtoul(p, &end, 16);
15671567 s->has_text_addr = 1;
1568+
15681569 } else {
15691570 return option;
15701571 }
tcc.h+5−6
@@ -313,8 +313,8 @@ typedef struct Section { · 312 unmodified lines
313313 int sh_addralign; /* elf section alignment */
314314 int sh_entsize; /* elf entry size */
315315 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 */
318318 int nb_hashed_syms; /* used to resize the hash table */
319319 struct Section *link; /* link to another section */
320320 struct Section *reloc; /* corresponding section for relocation, if any */
@@ -531,7 +531,7 @@ struct TCCState { · 210 unmodified lines
531531 int alacarte_link;
532532
533533 /* address of text section */
534− uplong text_addr;
534+ unsigned long text_addr;
535535 int has_text_addr;
536536
537537 /* symbols to call at load-time / unload-time */
@@ -872,7 +872,6 @@ enum tcc_token { · 334 unmodified lines
872872 #define strtold (long double)strtod
873873 #define strtof (float)strtod
874874 #define strtoll (long long)strtol
875− #define strtoull (unsigned long long)strtoull
876875 #endif
877876 #else
878877 /* 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
993992 ST_FUNC void section_reserve(Section *sec, unsigned long size);
994993 ST_FUNC Section *find_section(TCCState *s1, const char *name);
995994
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);
998997 ST_FUNC void greloc(Section *s, Sym *sym, unsigned long offset, int type);
999998
1000999 ST_INLN void sym_free(Sym *sym);
tccelf.c+8−13
@@ -1153,7 +1153,7 @@ ST_FUNC Section *new_symtab(TCCState *s1, · 1152 unmodified lines
11531153 }
11541154
11551155 /* 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)
11571157 {
11581158 ElfW(Dyn) *dyn;
11591159 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
13811381 section_reserve(s1->got, offset + PTR_SIZE);
13821382 #ifdef TCC_TARGET_X86_64
13831383 /* 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);
13851385 #endif
13861386 put32(s1->got->data + offset, sym->st_value & 0xffffffff);
13871387 }
@@ -1421,9 +1421,8 @@ static int elf_output_file(TCCState *s1, const char *filename) · 33 unmodified lines
14211421 FILE *f;
14221422 int fd, mode, ret;
14231423 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;
14271426 Section *strsec, *s;
14281427 ElfW(Shdr) shdr, *sh;
14291428 ElfW(Phdr) *phdr, *ph;
@@ -1431,9 +1430,9 @@ static int elf_output_file(TCCState *s1, const char *filename) · 1 unmodified line
14311430 unsigned long saved_dynamic_data_offset;
14321431 ElfW(Sym) *sym;
14331432 int type, file_type;
1434− uplong rel_addr, rel_size;
1433+ unsigned long rel_addr, rel_size;
14351434 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
1436− uplong bss_addr, bss_size;
1435+ unsigned long bss_addr, bss_size;
14371436 #endif
14381437
14391438 file_type = s1->output_type;
@@ -1748,7 +1747,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 308 unmodified lines
17481747 addr = s1->text_addr;
17491748 /* we ensure that (addr % ELF_PAGE_SIZE) == file_offset %
17501749 ELF_PAGE_SIZE */
1751− a_offset = ((int) addr) & (s1->section_align - 1);
1750+ a_offset = addr & (s1->section_align - 1);
17521751 p_offset = file_offset & (s1->section_align - 1);
17531752 if (a_offset < p_offset)
17541753 a_offset += s1->section_align;
@@ -1822,7 +1821,7 @@ static int elf_output_file(TCCState *s1, const char *filename) · 67 unmodified lines
18221821 tmp = addr;
18231822 addr = (addr + s->sh_addralign - 1) &
18241823 ~(s->sh_addralign - 1);
1825− file_offset += (int) ( addr - tmp );
1824+ file_offset += addr - tmp;
18261825 s->sh_offset = file_offset;
18271826 s->sh_addr = addr;
18281827
@@ -1916,12 +1915,8 @@ static int elf_output_file(TCCState *s1, const char *filename) · 87 unmodified lines
19161915 ph->p_align = dynamic->sh_addralign;
19171916
19181917 /* put GOT dynamic section address */
1919−#if defined(TCC_TARGET_X86_64)
1920− put32(s1->got->data + 4, dynamic->sh_addr >> 32 );
1921−#endif
19221918 put32(s1->got->data, dynamic->sh_addr);
19231919
1924−
19251920 /* relocate the PLT */
19261921 if (file_type == TCC_OUTPUT_EXE
19271922 #if defined(TCC_OUTPUT_DLL_WITH_PLT)
tccrun.c+3−6
@@ -36,11 +36,10 @@ static int rt_get_caller_pc(uplong *paddr, ucontext_t *uc, int level); · 35 unmodified lines
3636 static void rt_error(ucontext_t *uc, const char *fmt, ...);
3737 static int tcc_relocate_ex(TCCState *s1, void *ptr);
3838
39−#if defined TCC_TARGET_X86_64 && defined TCC_TARGET_PE
39+#ifdef _WIN64
4040 static void win64_add_function_table(TCCState *s1);
4141 #endif
4242
43−
4443 /* ------------------------------------------------------------- */
4544 /* Do all relocations (needed before using tcc_get_symbol())
4645 Returns -1 on error. */
@@ -194,7 +193,7 @@ static int tcc_relocate_ex(TCCState *s1, void *ptr) · 147 unmodified lines
194193 s1->runtime_plt_and_got_offset);
195194 #endif
196195
197−#if defined TCC_TARGET_X86_64 && defined TCC_TARGET_PE
196+#ifdef _WIN64
198197 win64_add_function_table(s1);
199198 #endif
200199 return 0;
@@ -622,8 +621,7 @@ static void set_exception_handler(void) · 421 unmodified lines
622621 SetUnhandledExceptionFilter(cpu_exception_handler);
623622 }
624623
625−#ifdef TCC_TARGET_PE
626−#ifdef TCC_TARGET_X86_64
624+#ifdef _WIN64
627625 static void win64_add_function_table(TCCState *s1)
628626 {
629627 RtlAddFunctionTable(
@@ -633,7 +631,6 @@ static void win64_add_function_table(TCCState *s1) · 3 unmodified lines
633631 );
634632 }
635633 #endif
636−#endif
637634
638635 /* return the PC at frame level 'level'. Return non zero if not found */
639636 static int rt_get_caller_pc(uplong *paddr, CONTEXT *uc, int level)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t