|
From: | Christian Jullien |
Subject: | Re: [Tinycc-devel] tcc no longer compiles on Windows |
Date: | Mon, 17 Dec 2018 17:07:10 +0100 |
As nobody complained, I suppose it’s Ok so I pushed the fix on mob. C. From: Tinycc-devel [mailto:address@hidden On Behalf Of Christian Jullien It looks it is broken since Thomas commit:
Prevent dead code on !x86 in prepare_dynamic_rel I propose this patch which, at least on Windows x64 fixes compilation error. Thomas, can you please review this patch and apply it in mod if you agree? diff --git a/tccelf.c b/tccelf.c index ead8eed..d381c4f 100644 --- a/tccelf.c +++ b/tccelf.c @@ -866,12 +866,14 @@ static void relocate_rel(TCCState *s1, Section *sr) static int prepare_dynamic_rel(TCCState *s1, Section *sr) { ElfW_Rel *rel; - int sym_index, type, count; + int type, count; count = 0; for_each_elem(sr, 0, rel, ElfW_Rel) { - sym_index = ELFW(R_SYM)(rel->r_info); type = ELFW(R_TYPE)(rel->r_info); +#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64) + int sym_index = ELFW(R_SYM)(rel->r_info); +#endif switch(type) { #if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64) #if defined(TCC_TARGET_I386) From: Tinycc-devel [mailto:address@hidden On Behalf Of Christian Jullien Tccelf.c has an undefined reference to sym_index with R_X86_64_PC32 case line 897. The declaration of sym_index at line 877 is not covered by this case. static int prepare_dynamic_rel(TCCState *s1, Section *sr) { ElfW_Rel *rel; int type, count; count = 0; for_each_elem(sr, 0, rel, ElfW_Rel) { type = ELFW(R_TYPE)(rel->r_info); switch(type) { #if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64) #if defined(TCC_TARGET_I386) int sym_index = ELFW(R_SYM)(rel->r_info); <<<< definition limited to I386 case R_386_32: if (!get_sym_attr(s1, sym_index, 0)->dyn_index && ((ElfW(Sym)*)symtab_section->data + sym_index)->st_shndx == SHN_UNDEF) { /* don't fixup unresolved (weak) symbols */ rel->r_info = ELFW(R_INFO)(sym_index, R_386_RELATIVE); break; } #elif defined(TCC_TARGET_X86_64) case R_X86_64_32: case R_X86_64_32S: case R_X86_64_64: #endif count++; break; #if defined(TCC_TARGET_I386) case R_386_PC32: #elif defined(TCC_TARGET_X86_64) case R_X86_64_PC32: #endif if (get_sym_attr(s1, sym_index, 0)->dyn_index) count++; break; #endif default: break; } } if (count) { /* allocate the section */ sr->sh_flags |= SHF_ALLOC; sr->sh_size = count * sizeof(ElfW_Rel); } return count; } |
[Prev in Thread] | Current Thread | [Next in Thread] |