History

x86-64: Now TCC can create healthy shared objects from object files generated by GCC

- Handle R_X86_64_GOTPCREL. - Output R_X86_64_RELATIVE reloc generated from R_X86_64_64.

Shinichiro Hamaji committed 17 years ago

Commit 97072b31 parent 754b0be1 file · +8 −2Browse files

Unified · Split

tccelf.c+8−2
@@ -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#endif787#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 else1094 else
1089 reloc_type = R_X86_64_JUMP_SLOT;1095 reloc_type = R_X86_64_JUMP_SLOT;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t