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
728728 break;
729729 case R_X86_64_GOTPCREL:
730730 *(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+ }
731735 break;
732736 case R_X86_64_GOTTPOFF:
733737 *(int *)ptr += val - s1->got->sh_addr;
@@ -779,6 +783,7 @@ static int prepare_dynamic_rel(TCCState *s1, Section *sr) · 45 unmodified lines
779783 #elif defined(TCC_TARGET_X86_64)
780784 case R_X86_64_32:
781785 case R_X86_64_32S:
786+ case R_X86_64_64:
782787 #endif
783788 count++;
784789 break;
@@ -1079,11 +1084,12 @@ static void build_got_entries(TCCState *s1) · 294 unmodified lines
10791084 case R_X86_64_PLT32:
10801085 if (!s1->got)
10811086 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) {
10831089 sym_index = ELFW(R_SYM)(rel->r_info);
10841090 sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
10851091 /* 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)
10871093 reloc_type = R_X86_64_GLOB_DAT;
10881094 else
10891095 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