From 8294285d8f8400b435a59b4913dcf5617c999b0f Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Mon, 1 Jan 2018 05:29:46 +0100 Subject: [PATCH] Don't emit applied .rel sections for a final link we shouldn't emit relocation sections that are applied already. For now we need to emit ALLOCed .rel sections as they contain dynamic relocs, they should be put into their own (new) section instead. --- tccelf.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tccelf.c b/tccelf.c index 4b35fa1..c0cbe42 100644 --- a/tccelf.c +++ b/tccelf.c @@ -1531,7 +1531,7 @@ static int alloc_sec_names(TCCState *s1, int file_type, Section *strsec) prepare_dynamic_rel(s1, s)) { if (s1->sections[s->sh_info]->sh_flags & SHF_EXECINSTR) textrel = 1; - } else if (s1->do_debug || + } else if ((s1->do_debug && s->sh_type != SHT_RELX) || file_type == TCC_OUTPUT_OBJ || (s->sh_flags & SHF_ALLOC) || i == (s1->nb_sections - 1)) { @@ -1832,14 +1832,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 defined(TCC_TARGET_I386) - if (s->reloc && s != s1->got && (s->sh_flags & SHF_ALLOC)) //gr - /* On X86 gdb 7.3 works in any case but gdb 6.6 will crash if SHF_ALLOC - checking is removed */ -#else if (s->reloc && s != s1->got) - /* On X86_64 gdb 7.3 will crash if SHF_ALLOC checking is present */ -#endif relocate_section(s1, s); }