From 1a4d4b76e803a32db1168e66ad8f8b26c29c8ea0 Mon Sep 17 00:00:00 2001 From: grischka Date: Tue, 12 Dec 2017 17:33:37 +0100 Subject: tccgen_begin/end_file This is supposed to make compilation and linking with multiple source files (tcc f1.c f2.S ...) behave just the same as linking object files. tccgen.c:put_extern_sym2(): - use put_elf_sym to enter new symbols unconditionally tccelf.c: - save section state before compilation - disable symbol hashing during compilation - merge symbols and update relocations after compilation tccpe.c: - re-create s1->uw_sym for each compilation (because it may change) --- tccpe.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tccpe.c') diff --git a/tccpe.c b/tccpe.c index af4438d..7e7150c 100644 --- a/tccpe.c +++ b/tccpe.c @@ -1633,7 +1633,7 @@ static int pe_load_res(TCCState *s1, int fd) { struct pe_rsrc_header hdr; Section *rsrc_section; - int i, ret = -1; + int i, ret = -1, sym_index; BYTE *ptr; unsigned offs; @@ -1651,8 +1651,8 @@ static int pe_load_res(TCCState *s1, int fd) if (!read_mem(fd, offs, ptr, hdr.sectionhdr.SizeOfRawData)) goto quit; offs = hdr.sectionhdr.PointerToRelocations; - for (i = 0; i < hdr.sectionhdr.NumberOfRelocations; ++i) - { + sym_index = put_elf_sym(symtab_section, 0, 0, 0, 0, rsrc_section->sh_num, ".rsrc"); + for (i = 0; i < hdr.sectionhdr.NumberOfRelocations; ++i) { struct pe_rsrc_reloc rel; if (!read_mem(fd, offs, &rel, sizeof rel)) goto quit; @@ -1660,7 +1660,7 @@ static int pe_load_res(TCCState *s1, int fd) if (rel.type != RSRC_RELTYPE) goto quit; put_elf_reloc(symtab_section, rsrc_section, - rel.offset, R_XXX_RELATIVE, 0); + rel.offset, R_XXX_RELATIVE, sym_index); offs += sizeof rel; } ret = 0; @@ -1779,9 +1779,9 @@ static unsigned pe_add_uwwind_info(TCCState *s1) if (NULL == s1->uw_pdata) { s1->uw_pdata = find_section(tcc_state, ".pdata"); s1->uw_pdata->sh_addralign = 4; - s1->uw_sym = put_elf_sym(symtab_section, 0, 0, 0, 0, text_section->sh_num, NULL); } - + if (0 == s1->uw_sym) + s1->uw_sym = put_elf_sym(symtab_section, 0, 0, 0, 0, text_section->sh_num, ".uw_base"); if (0 == s1->uw_offs) { /* As our functions all have the same stackframe, we use one entry for all */ static const unsigned char uw_info[] = { @@ -1970,7 +1970,7 @@ ST_FUNC int pe_output_file(TCCState *s1, const char *filename) tcc_add_bcheck(s1); pe_add_runtime(s1, &pe); - resolve_regular_syms(); + resolve_common_syms(s1); pe_set_options(s1, &pe); ret = pe_check_symbols(&pe); -- cgit v1.3.1