diff --git a/tccelf.c b/tccelf.c index 0d372e0f..9f242b85 100644 --- a/tccelf.c +++ b/tccelf.c @@ -1084,8 +1084,10 @@ ST_FUNC void build_got_entries(TCCState *s1) #ifdef TCC_TARGET_X86_64 if ((type == R_X86_64_PLT32 || type == R_X86_64_PC32) && + sym->st_shndx != SHN_UNDEF && (ELFW(ST_VISIBILITY)(sym->st_other) != STV_DEFAULT || - ELFW(ST_BIND)(sym->st_info) == STB_LOCAL)) { + ELFW(ST_BIND)(sym->st_info) == STB_LOCAL || + s1->output_type == TCC_OUTPUT_EXE)) { rel->r_info = ELFW(R_INFO)(sym_index, R_X86_64_PC32); continue; } @@ -1841,7 +1843,7 @@ static int final_sections_reloc(TCCState *s1) /* XXX: ignore sections with allocated relocations ? */ for(i = 1; i < s1->nb_sections; i++) { s = s1->sections[i]; - if (s->reloc && s != s1->got) + if (s->reloc && (s != s1->got || s1->static_link)) relocate_section(s1, s); }