- Handle R_X86_64_GOTPCREL. - Output R_X86_64_RELATIVE reloc generated from R_X86_64_64.
Unified · Split
| @@ -728,6 +728,10 @@ static void relocate_section(TCCState *s1, Section *s) · 727 unmodified lines | ||
| 728 | 728 | break; |
| 729 | 729 | case R_X86_64_GOTPCREL: |
| 730 | 730 | *(int *)ptr += s1->got->sh_addr - addr; |
| 731 | + /* XXX: is this OK? */ | |
| 732 | + if (s1->output_type == TCC_OUTPUT_DLL) { | |
| 733 | + *(int *)ptr += s1->got_offsets[sym_index] - 4; | |
| 734 | + } | |
| 731 | 735 | break; |
| 732 | 736 | case R_X86_64_GOTTPOFF: |
| 733 | 737 | *(int *)ptr += val - s1->got->sh_addr; |
| @@ -779,6 +783,7 @@ static int prepare_dynamic_rel(TCCState *s1, Section *sr) · 45 unmodified lines | ||
| 779 | 783 | #elif defined(TCC_TARGET_X86_64) |
| 780 | 784 | case R_X86_64_32: |
| 781 | 785 | case R_X86_64_32S: |
| 786 | + case R_X86_64_64: | |
| 782 | 787 | #endif |
| 783 | 788 | count++; |
| 784 | 789 | break; |
| @@ -1079,11 +1084,12 @@ static void build_got_entries(TCCState *s1) · 294 unmodified lines | ||
| 1079 | 1084 | case R_X86_64_PLT32: |
| 1080 | 1085 | if (!s1->got) |
| 1081 | 1086 | build_got(s1); |
| 1082 | − if (type == R_X86_64_GOT32 || type == R_X86_64_PLT32) { | |
| 1087 | + if (type == R_X86_64_GOT32 || type == R_X86_64_GOTPCREL || | |
| 1088 | + type == R_X86_64_PLT32) { | |
| 1083 | 1089 | sym_index = ELFW(R_SYM)(rel->r_info); |
| 1084 | 1090 | sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; |
| 1085 | 1091 | /* look at the symbol got offset. If none, then add one */ |
| 1086 | − if (type == R_X86_64_GOT32) | |
| 1092 | + if (type == R_X86_64_GOT32 || type == R_X86_64_GOTPCREL) | |
| 1087 | 1093 | reloc_type = R_X86_64_GLOB_DAT; |
| 1088 | 1094 | else |
| 1089 | 1095 | reloc_type = R_X86_64_JUMP_SLOT; |