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
12441244
12451245 offset = text_section->data_offset;
12461246 /* 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
12471252 p = section_ptr_add(text_section, 8);
12481253 *p = 0x25FF;
12491254 #ifdef TCC_TARGET_X86_64
12501255 *(DWORD*)(p+1) = (DWORD)-4;
1256+#endif
12511257 #endif
12521258 /* add a helper symbol, will be patched later in
12531259 pe_build_imports */
@@ -1256,8 +1262,13 @@ static int pe_check_symbols(struct pe_info *pe) · 2 unmodified lines
12561262 symtab_section, 0, sizeof(DWORD),
12571263 ELFW_ST_INFO(STB_GLOBAL, STT_OBJECT),
12581264 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
12591269 put_elf_reloc(symtab_section, text_section,
12601270 offset + 2, R_XXX_THUNKFIX, is->iat_index);
1271+#endif
12611272 is->thk_offset = offset;
12621273 }
12631274
@@ -1822,9 +1833,9 @@ ST_FUNC int pe_output_file(TCCState * s1, const char *filename) · 558 unmodified lines
18221833 pe.subsystem = s1->pe_subsystem;
18231834 else
18241835 #if defined(TCC_TARGET_ARM)
1825− pe.subsystem = 3;
1826−#else
18271836 pe.subsystem = 9;
1837+#else
1838+ pe.subsystem = 3;
18281839 #endif
18291840 /* set default file/section alignment */
18301841 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