History

Recognize more relocations as needing GOT/PLT entry

Thomas Preud'homme committed 10 years ago

Commit 6cd23d11 parent cb273fd1 file · +41 −16Browse files

Unified · Split

tccelf.c+41−16
@@ -1034,6 +1034,8 @@ ST_FUNC void build_got_entries(TCCState *s1) · 1033 unmodified lines
10341034 type = ELFW(R_TYPE)(rel->r_info);
10351035 switch(type) {
10361036 #if defined(TCC_TARGET_I386)
1037+ case R_386_PC16:
1038+ case R_386_PC32:
10371039 case R_386_GOT32:
10381040 case R_386_GOT32X:
10391041 case R_386_GOTOFF:
@@ -1046,7 +1048,8 @@ ST_FUNC void build_got_entries(TCCState *s1) · 6 unmodified lines
10461048 sym_index = ELFW(R_SYM)(rel->r_info);
10471049 sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
10481050 /* look at the symbol got offset. If none, then add one */
1049− if (type == R_386_GOT32 || type == R_386_GOT32X)
1051+ if (type == R_386_GOT32 || type == R_386_GOT32X ||
1052+ type == R_386_16 || type == R_386_32)
10501053 reloc_type = R_386_GLOB_DAT;
10511054 else
10521055 reloc_type = R_386_JMP_SLOT;
@@ -1058,10 +1061,19 @@ ST_FUNC void build_got_entries(TCCState *s1) · 5 unmodified lines
10581061 case R_ARM_PC24:
10591062 case R_ARM_CALL:
10601063 case R_ARM_JUMP24:
1061− case R_ARM_GOT32:
1062− case R_ARM_GOTOFF:
1063− case R_ARM_GOTPC:
10641064 case R_ARM_PLT32:
1065+ case R_ARM_THM_PC22:
1066+ case R_ARM_MOVT_ABS:
1067+ case R_ARM_MOVW_ABS_NC:
1068+ case R_ARM_THM_MOVT_ABS:
1069+ case R_ARM_THM_MOVW_ABS_NC:
1070+ case R_ARM_PREL31:
1071+ case R_ARM_REL32:
1072+ case R_ARM_GOTPC:
1073+ case R_ARM_GOTOFF:
1074+ case R_ARM_GOT32:
1075+ case R_ARM_V4BX:
1076+
10651077 if (!s1->got)
10661078 build_got(s1);
10671079 sym_index = ELFW(R_SYM)(rel->r_info);
@@ -1071,7 +1083,11 @@ ST_FUNC void build_got_entries(TCCState *s1) · 3 unmodified lines
10711083 || s1->output_type == TCC_OUTPUT_MEMORY)) {
10721084 unsigned long ofs;
10731085 /* look at the symbol got offset. If none, then add one */
1074− if (type == R_ARM_GOT32)
1086+ if (type == R_ARM_GOT32 || type == R_ARM_MOVT_ABS ||
1087+ type == R_ARM_MOVW_ABS_NC ||
1088+ type == R_ARM_THM_MOVT_ABS ||
1089+ type == R_ARM_THM_MOVW_ABS_NC || type == R_ARM_ABS32 ||
1090+ type == R_ARM_REL32)
10751091 reloc_type = R_ARM_GLOB_DAT;
10761092 else
10771093 reloc_type = R_ARM_JUMP_SLOT;
@@ -1082,7 +1098,8 @@ ST_FUNC void build_got_entries(TCCState *s1) · 4 unmodified lines
10821098 (char *) symtab_section->link->data + sym->st_name,
10831099 type, sym->st_shndx, ofs);
10841100 #endif
1085− if (type != R_ARM_GOT32) {
1101+ if (type == R_ARM_PC24 || type == R_ARM_CALL ||
1102+ type == R_ARM_JUMP24 || type == R_ARM_PLT32) {
10861103 addr_t *ptr = (addr_t*)(s1->sections[s->sh_info]->data
10871104 + rel->r_offset);
10881105 /* x must be signed! */
@@ -1177,11 +1194,15 @@ ST_FUNC void build_got_entries(TCCState *s1) · 88 unmodified lines
11771194 }
11781195 break;
11791196 #elif defined(TCC_TARGET_X86_64)
1197+ case R_X86_64_32:
1198+ case R_X86_64_32S:
1199+ case R_X86_64_64:
1200+ case R_X86_64_PC32:
11801201 case R_X86_64_GOT32:
11811202 case R_X86_64_GOTTPOFF:
11821203 case R_X86_64_GOTPCREL:
1183− case R_X86_64_GOTPCRELX:
1184− case R_X86_64_REX_GOTPCRELX:
1204+ case R_X86_64_GOTPCRELX:
1205+ case R_X86_64_REX_GOTPCRELX:
11851206 case R_X86_64_PLT32:
11861207 sym_index = ELFW(R_SYM)(rel->r_info);
11871208 sym = &((ElfW(Sym) *)symtab_section->data)[sym_index];
@@ -1202,16 +1223,20 @@ ST_FUNC void build_got_entries(TCCState *s1) · 14 unmodified lines
12021223 type == R_X86_64_PLT32) {
12031224 unsigned long ofs;
12041225 /* look at the symbol got offset. If none, then add one */
1205− if (type == R_X86_64_PLT32)
1206− reloc_type = R_X86_64_JUMP_SLOT;
1207− else
1226+ if (type == R_X86_64_GOT32 || type == R_X86_64_GOTPCREL ||
1227+ type == R_X86_64_GOTPCRELX ||
1228+ type == R_X86_64_REX_GOTPCRELX ||
1229+ type == R_X86_64_32 || type == R_X86_64_32S ||
1230+ type == R_X86_64_64)
12081231 reloc_type = R_X86_64_GLOB_DAT;
1232+ else
1233+ reloc_type = R_X86_64_JUMP_SLOT;
12091234 ofs = put_got_entry(s1, reloc_type, sym->st_size,
1210− sym->st_info, sym_index);
1211− if (type == R_X86_64_PLT32)
1212− /* We store the place of the generated PLT slot
1213− in our addend. */
1214− rel->r_addend += ofs;
1235+ sym->st_info, sym_index);
1236+ if (type == R_X86_64_PLT32)
1237+ /* We store the place of the generated PLT slot
1238+ in our addend. */
1239+ rel->r_addend += ofs;
12151240 }
12161241 break;
12171242 #else

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