Introduce a new attribute to check the existence of a PLT entry for a given symbol has the presence of an entry for that symbol in the dynsym section is not proof that a PLT entry exists. This fixes commit dc8ea93b13faefb565fb937f8b8c08c40c063549.
Unified · Split
| @@ -522,6 +522,7 @@ typedef struct ASMOperand { · 521 unmodified lines | |||
| 522 | 522 | ||
| 523 | struct sym_attr { | 523 | struct sym_attr { |
| 524 | unsigned long got_offset; | 524 | unsigned long got_offset; |
| 525 | unsigned char has_plt_entry:1; | ||
| 525 | #ifdef TCC_TARGET_ARM | 526 | #ifdef TCC_TARGET_ARM |
| 526 | unsigned char plt_thumb_stub:1; | 527 | unsigned char plt_thumb_stub:1; |
| 527 | #endif | 528 | #endif |
| @@ -1042,10 +1042,9 @@ static void put_got_entry(TCCState *s1, · 1041 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 (!find_elf_sym(s1->dynsym, name)) | 1045 | if (s1->sym_attrs[sym_index].has_plt_entry) |
| 1046 | need_plt_entry = 1; | ||
| 1047 | else | ||
| 1048 | return; | 1046 | return; |
| 1047 | s1->sym_attrs[sym_index].has_plt_entry = 1; | ||
| 1049 | offset = sym->st_value; | 1048 | offset = sym->st_value; |
| 1050 | #if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64) | 1049 | #if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64) |
| 1051 | if (need_plt_entry) { | 1050 | if (need_plt_entry) { |