- 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 | break; | 728 | break; |
| 729 | case R_X86_64_GOTPCREL: | 729 | case R_X86_64_GOTPCREL: |
| 730 | *(int *)ptr += s1->got->sh_addr - addr; | 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 | break; | 735 | break; |
| 732 | case R_X86_64_GOTTPOFF: | 736 | case R_X86_64_GOTTPOFF: |
| 733 | *(int *)ptr += val - s1->got->sh_addr; | 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 | #elif defined(TCC_TARGET_X86_64) | 783 | #elif defined(TCC_TARGET_X86_64) |
| 780 | case R_X86_64_32: | 784 | case R_X86_64_32: |
| 781 | case R_X86_64_32S: | 785 | case R_X86_64_32S: |
| 786 | case R_X86_64_64: | ||
| 782 | #endif | 787 | #endif |
| 783 | count++; | 788 | count++; |
| 784 | break; | 789 | break; |
| @@ -1079,11 +1084,12 @@ static void build_got_entries(TCCState *s1) · 294 unmodified lines | |||
| 1079 | case R_X86_64_PLT32: | 1084 | case R_X86_64_PLT32: |
| 1080 | if (!s1->got) | 1085 | if (!s1->got) |
| 1081 | build_got(s1); | 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 | sym_index = ELFW(R_SYM)(rel->r_info); | 1089 | sym_index = ELFW(R_SYM)(rel->r_info); |
| 1084 | sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; | 1090 | sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; |
| 1085 | /* look at the symbol got offset. If none, then add one */ | 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 | reloc_type = R_X86_64_GLOB_DAT; | 1093 | reloc_type = R_X86_64_GLOB_DAT; |
| 1088 | else | 1094 | else |
| 1089 | reloc_type = R_X86_64_JUMP_SLOT; | 1095 | reloc_type = R_X86_64_JUMP_SLOT; |