Fix commit aa561d70119accb59a17f10f9ba69076fb0ab516 by setting has_plt_entry once the plt has been created, not before.
Unified · Split
| @@ -1031,7 +1031,7 @@ static void put_got_entry(TCCState *s1, · 1030 unmodified lines | |||
| 1031 | /* if a got entry already exists for that symbol, no need to add one */ | 1031 | /* if a got entry already exists for that symbol, no need to add one */ |
| 1032 | if (sym_index < s1->nb_sym_attrs && | 1032 | if (sym_index < s1->nb_sym_attrs && |
| 1033 | s1->sym_attrs[sym_index].got_offset) { | 1033 | s1->sym_attrs[sym_index].got_offset) { |
| 1034 | if (!need_plt_entry) | 1034 | if (!need_plt_entry || s1->sym_attrs[sym_index].has_plt_entry) |
| 1035 | return; | 1035 | return; |
| 1036 | else | 1036 | else |
| 1037 | got_entry_present = 1; | 1037 | got_entry_present = 1; |
| @@ -1042,9 +1042,6 @@ static void put_got_entry(TCCState *s1, · 4 unmodified lines | |||
| 1042 | if (s1->dynsym) { | 1042 | if (s1->dynsym) { |
| 1043 | sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; | 1043 | sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; |
| 1044 | name = (char *) symtab_section->link->data + sym->st_name; | 1044 | name = (char *) symtab_section->link->data + sym->st_name; |
| 1045 | if (s1->sym_attrs[sym_index].has_plt_entry) | ||
| 1046 | return; | ||
| 1047 | s1->sym_attrs[sym_index].has_plt_entry = 1; | ||
| 1048 | offset = sym->st_value; | 1045 | offset = sym->st_value; |
| 1049 | #if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64) | 1046 | #if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64) |
| 1050 | if (need_plt_entry) { | 1047 | if (need_plt_entry) { |
| @@ -1090,6 +1087,7 @@ static void put_got_entry(TCCState *s1, · 39 unmodified lines | |||
| 1090 | if (s1->output_type == TCC_OUTPUT_EXE) | 1087 | if (s1->output_type == TCC_OUTPUT_EXE) |
| 1091 | #endif | 1088 | #endif |
| 1092 | offset = plt->data_offset - 16; | 1089 | offset = plt->data_offset - 16; |
| 1090 | s1->sym_attrs[sym_index].has_plt_entry = 1; | ||
| 1093 | } | 1091 | } |
| 1094 | #elif defined(TCC_TARGET_ARM) | 1092 | #elif defined(TCC_TARGET_ARM) |
| 1095 | if (need_plt_entry) { | 1093 | if (need_plt_entry) { |
| @@ -1127,6 +1125,7 @@ static void put_got_entry(TCCState *s1, · 31 unmodified lines | |||
| 1127 | the PLT */ | 1125 | the PLT */ |
| 1128 | if (s1->output_type == TCC_OUTPUT_EXE) | 1126 | if (s1->output_type == TCC_OUTPUT_EXE) |
| 1129 | offset = plt->data_offset - 16; | 1127 | offset = plt->data_offset - 16; |
| 1128 | s1->sym_attrs[sym_index].has_plt_entry = 1; | ||
| 1130 | } | 1129 | } |
| 1131 | #elif defined(TCC_TARGET_C67) | 1130 | #elif defined(TCC_TARGET_C67) |
| 1132 | tcc_error("C67 got not implemented"); | 1131 | tcc_error("C67 got not implemented"); |