History

PE ARM: jump IAT arm code

Timo VJ Lahde committed 16 years ago

Commit 2cb1fd61 parent 83b0bd31 file · +13 −2Browse files

Unified · Split

tccpe.c+13−2
@@ -1244,10 +1244,16 @@ static int pe_check_symbols(struct pe_info *pe) · 1243 unmodified lines
1244 1244
1245 offset = text_section->data_offset;1245 offset = text_section->data_offset;
1246 /* add the 'jmp IAT[x]' instruction */1246 /* add the 'jmp IAT[x]' instruction */
1247#ifdef TCC_TARGET_ARM
1248 p = section_ptr_add(text_section, 8+4); // room for code and address
1249 (*(DWORD*)(p)) = 0xE59FC000; // arm code ldr ip, [pc] ; PC+8+0 = 0001xxxx
1250 (*(DWORD*)(p+2)) = 0xE59CF000; // arm code ldr pc, [ip]
1251#else
1247 p = section_ptr_add(text_section, 8);1252 p = section_ptr_add(text_section, 8);
1248 *p = 0x25FF;1253 *p = 0x25FF;
1249#ifdef TCC_TARGET_X86_641254#ifdef TCC_TARGET_X86_64
1250 *(DWORD*)(p+1) = (DWORD)-4;1255 *(DWORD*)(p+1) = (DWORD)-4;
1256#endif
1251#endif1257#endif
1252 /* add a helper symbol, will be patched later in1258 /* add a helper symbol, will be patched later in
1253 pe_build_imports */1259 pe_build_imports */
@@ -1256,8 +1262,13 @@ static int pe_check_symbols(struct pe_info *pe) · 2 unmodified lines
1256 symtab_section, 0, sizeof(DWORD),1262 symtab_section, 0, sizeof(DWORD),
1257 ELFW_ST_INFO(STB_GLOBAL, STT_OBJECT),1263 ELFW_ST_INFO(STB_GLOBAL, STT_OBJECT),
1258 0, SHN_UNDEF, buffer);1264 0, SHN_UNDEF, buffer);
1265#ifdef TCC_TARGET_ARM
1266 put_elf_reloc(symtab_section, text_section,
1267 offset + 8, R_XXX_THUNKFIX, is->iat_index); // offset to IAT position
1268#else
1259 put_elf_reloc(symtab_section, text_section, 1269 put_elf_reloc(symtab_section, text_section,
1260 offset + 2, R_XXX_THUNKFIX, is->iat_index);1270 offset + 2, R_XXX_THUNKFIX, is->iat_index);
1271#endif
1261 is->thk_offset = offset;1272 is->thk_offset = offset;
1262 }1273 }
1263 1274
@@ -1822,9 +1833,9 @@ ST_FUNC int pe_output_file(TCCState * s1, const char *filename) · 558 unmodified lines
1822 pe.subsystem = s1->pe_subsystem;1833 pe.subsystem = s1->pe_subsystem;
1823 else1834 else
1824#if defined(TCC_TARGET_ARM)1835#if defined(TCC_TARGET_ARM)
1825 pe.subsystem = 3;
1826#else
1827 pe.subsystem = 9;1836 pe.subsystem = 9;
1837#else
1838 pe.subsystem = 3;
1828#endif1839#endif
1829 /* set default file/section alignment */1840 /* set default file/section alignment */
1830 if (pe.subsystem == 1) {1841 if (pe.subsystem == 1) {

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