From d348a9a51d32cece842b7885d27a411436d7887b Mon Sep 17 00:00:00 2001 From: grischka Date: Tue, 12 Dec 2017 17:57:20 +0100 Subject: final update for 0.9.27 tccgen.c: - fix ldouble asm hack - fix a VLA problem on Win64 (also x86_64-gen.c) - patch_type(): make sure that no symbol ever changes from global to static tcc.c: - tcc -vv: print libtcc1.a path also on win32 tccpe.c, tcctools.c: - use unix LF mode to for .def output files (that is for creating reproducible output trees) Makefile: - suppress some warnings when makeinfo is missing - call 'which install' only on win32 tests/Makefile: - change PATH only on WINNT systems (i.e. not if cross-compiling on linux for win32) - asm-c-connect.test: slim output and do diff tccrun.c tccpe.c *-link.c: - integrate former 'pe_relocate_rva()' into normal relocation This also fixes linkage of the unwind data on WIN64 for -run (reported by Janus Lynggaard Thorborg) tccasm.c, tests/tcctest.c: - fix dot (sym_index of -1 crashed in put_elf_reloc) - massage .set a bit (see test) other: - #define SECTION_ABS removed - ST_DATA Section *strtab_section: removed - put_extern_sym2(): take int section number Conflicts: tccelf.c tccpe.c Conflicts: tccelf.c --- tccpe.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'tccpe.c') diff --git a/tccpe.c b/tccpe.c index 7e7150c..a7266c9 100644 --- a/tccpe.c +++ b/tccpe.c @@ -954,7 +954,7 @@ static void pe_build_exports(struct pe_info *pe) /* automatically write exports to .def */ pstrcpy(buf, sizeof buf, pe->filename); strcpy(tcc_fileextension(buf), ".def"); - op = fopen(buf, "w"); + op = fopen(buf, "wb"); if (NULL == op) { tcc_error_noabort("could not create '%s': %s", buf, strerror(errno)); } else { @@ -967,7 +967,7 @@ static void pe_build_exports(struct pe_info *pe) for (ord = 0; ord < sym_count; ++ord) { p = sorted[ord], sym_index = p->index, name = p->name; - /* insert actual address later in pe_relocate_rva */ + /* insert actual address later in relocate_section() */ put_elf_reloc(symtab_section, pe->thunk, func_o, R_XXX_RELATIVE, sym_index); *(DWORD*)(pe->thunk->data + name_o) @@ -1181,26 +1181,6 @@ static int pe_assign_addresses (struct pe_info *pe) return 0; } -/* ------------------------------------------------------------- */ -static void pe_relocate_rva (struct pe_info *pe, Section *s) -{ - Section *sr = s->reloc; - ElfW_Rel *rel, *rel_end; - rel_end = (ElfW_Rel *)(sr->data + sr->data_offset); - for(rel = (ElfW_Rel *)sr->data; rel < rel_end; rel++) { - if (ELFW(R_TYPE)(rel->r_info) == R_XXX_RELATIVE) { - int sym_index = ELFW(R_SYM)(rel->r_info); - DWORD addr = s->sh_addr; - if (sym_index) { - ElfW(Sym) *sym = (ElfW(Sym) *)symtab_section->data + sym_index; - addr = sym->st_value; - } - // printf("reloc rva %08x %08x %s\n", (DWORD)rel->r_offset, addr, s->name); - *(DWORD*)(s->data + rel->r_offset) += addr - pe->imagebase; - } - } -} - /*----------------------------------------------------------------------------*/ static int pe_isafunc(int sym_index) @@ -1830,7 +1810,7 @@ ST_FUNC void pe_add_unwind_data(unsigned start, unsigned end, unsigned stack) /* put relocations on it */ for (n = o + sizeof *p; o < n; o += sizeof p->BeginAddress) - put_elf_reloc(symtab_section, pd, o, R_X86_64_RELATIVE, s1->uw_sym); + put_elf_reloc(symtab_section, pd, o, R_XXX_RELATIVE, s1->uw_sym); } #endif /* ------------------------------------------------------------- */ @@ -1979,11 +1959,11 @@ ST_FUNC int pe_output_file(TCCState *s1, const char *filename) else if (filename) { pe_assign_addresses(&pe); relocate_syms(s1, s1->symtab, 0); + s1->pe_imagebase = pe.imagebase; for (i = 1; i < s1->nb_sections; ++i) { Section *s = s1->sections[i]; if (s->reloc) { relocate_section(s1, s); - pe_relocate_rva(&pe, s); } } pe.start_addr = (DWORD) @@ -1999,6 +1979,9 @@ ST_FUNC int pe_output_file(TCCState *s1, const char *filename) pe.thunk = data_section; pe_build_imports(&pe); s1->runtime_main = pe.start_symbol; +#ifdef TCC_TARGET_X86_64 + s1->uw_pdata = find_section(s1, ".pdata"); +#endif #endif } -- cgit v1.3.1