From b018bac9c8e1e47fbcb42565ddcdf2a2965b3fcf Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Wed, 26 Mar 2014 22:13:20 +0800 Subject: [PATCH] Fix again GOT32 + PLT32 reloc commit Fix commit aa561d70119accb59a17f10f9ba69076fb0ab516 by setting has_plt_entry once the plt has been created, not before. --- tccelf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tccelf.c b/tccelf.c index f5f9eed2..932cf031 100644 --- a/tccelf.c +++ b/tccelf.c @@ -1031,7 +1031,7 @@ static void put_got_entry(TCCState *s1, /* if a got entry already exists for that symbol, no need to add one */ if (sym_index < s1->nb_sym_attrs && s1->sym_attrs[sym_index].got_offset) { - if (!need_plt_entry) + if (!need_plt_entry || s1->sym_attrs[sym_index].has_plt_entry) return; else got_entry_present = 1; @@ -1042,9 +1042,6 @@ static void put_got_entry(TCCState *s1, if (s1->dynsym) { sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; name = (char *) symtab_section->link->data + sym->st_name; - if (s1->sym_attrs[sym_index].has_plt_entry) - return; - s1->sym_attrs[sym_index].has_plt_entry = 1; offset = sym->st_value; #if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64) if (need_plt_entry) { @@ -1090,6 +1087,7 @@ static void put_got_entry(TCCState *s1, if (s1->output_type == TCC_OUTPUT_EXE) #endif offset = plt->data_offset - 16; + s1->sym_attrs[sym_index].has_plt_entry = 1; } #elif defined(TCC_TARGET_ARM) if (need_plt_entry) { @@ -1127,6 +1125,7 @@ static void put_got_entry(TCCState *s1, the PLT */ if (s1->output_type == TCC_OUTPUT_EXE) offset = plt->data_offset - 16; + s1->sym_attrs[sym_index].has_plt_entry = 1; } #elif defined(TCC_TARGET_C67) tcc_error("C67 got not implemented");