aboutsummaryrefslogtreecommitdiff
path: root/tccpe.c
diff options
context:
space:
mode:
authorTimo VJ Lahde <timovj.lahde@gmail.com>2010-04-19 15:50:22 +0300
committerTimo VJ Lahde <timovj.lahde@gmail.com>2010-04-19 15:50:22 +0300
commit2cb1fd6a10796476c4f785de3c03d749427e24d2 (patch)
tree4a0cc860ddcc85db2c74b9503468ea00540b94f4 /tccpe.c
parent83b0bd3095ac755a79aa1314424f9dc6a01bd0ff (diff)
downloadtinycc-2cb1fd6a10796476c4f785de3c03d749427e24d2.tar.gz
tinycc-2cb1fd6a10796476c4f785de3c03d749427e24d2.tar.bz2
PE ARM: jump IAT arm code
Diffstat (limited to 'tccpe.c')
-rw-r--r--tccpe.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/tccpe.c b/tccpe.c
index e8321dc..4497e77 100644
--- a/tccpe.c
+++ b/tccpe.c
@@ -1244,11 +1244,17 @@ static int pe_check_symbols(struct pe_info *pe)
offset = text_section->data_offset;
/* add the 'jmp IAT[x]' instruction */
+#ifdef TCC_TARGET_ARM
+ p = section_ptr_add(text_section, 8+4); // room for code and address
+ (*(DWORD*)(p)) = 0xE59FC000; // arm code ldr ip, [pc] ; PC+8+0 = 0001xxxx
+ (*(DWORD*)(p+2)) = 0xE59CF000; // arm code ldr pc, [ip]
+#else
p = section_ptr_add(text_section, 8);
*p = 0x25FF;
#ifdef TCC_TARGET_X86_64
*(DWORD*)(p+1) = (DWORD)-4;
#endif
+#endif
/* add a helper symbol, will be patched later in
pe_build_imports */
sprintf(buffer, "IAT.%s", name);
@@ -1256,8 +1262,13 @@ static int pe_check_symbols(struct pe_info *pe)
symtab_section, 0, sizeof(DWORD),
ELFW_ST_INFO(STB_GLOBAL, STT_OBJECT),
0, SHN_UNDEF, buffer);
+#ifdef TCC_TARGET_ARM
+ put_elf_reloc(symtab_section, text_section,
+ offset + 8, R_XXX_THUNKFIX, is->iat_index); // offset to IAT position
+#else
put_elf_reloc(symtab_section, text_section,
offset + 2, R_XXX_THUNKFIX, is->iat_index);
+#endif
is->thk_offset = offset;
}
@@ -1822,9 +1833,9 @@ ST_FUNC int pe_output_file(TCCState * s1, const char *filename)
pe.subsystem = s1->pe_subsystem;
else
#if defined(TCC_TARGET_ARM)
- pe.subsystem = 3;
-#else
pe.subsystem = 9;
+#else
+ pe.subsystem = 3;
#endif
/* set default file/section alignment */
if (pe.subsystem == 1) {