History

ARM: first support for arm-pe target

Frederic Feret committed 17 years ago

Commit b7d7af41 parent 2f73e423 files · +47 −10Browse files

Unified · Split

3 files
  1. Makefile +5 −0
  2. tcc.c +3 −0
  3. tccpe.c +39 −10
Makefile+5−0
@@ -72,6 +72,7 @@ PROGS=tcc$(EXESUF) · 71 unmodified lines
7272 I386_CROSS = i386-tcc$(EXESUF)
7373 WIN32_CROSS = i386-win32-tcc$(EXESUF)
7474 WIN64_CROSS = x86_64-win32-tcc$(EXESUF)
75+WINCE_CROSS = arm-win32-tcc$(EXESUF)
7576 X64_CROSS = x86_64-tcc$(EXESUF)
7677 ARM_CROSS = arm-tcc-fpa$(EXESUF) arm-tcc-fpa-ld$(EXESUF) \
7778 arm-tcc-vfp$(EXESUF) arm-tcc-vfp-eabi$(EXESUF)
@@ -82,6 +83,7 @@ CORE_FILES = tcc.c libtcc.c tccpp.c tccgen.c tccelf.c tccasm.c \ · 4 unmodified lines
8283 I386_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h i386-tok.h
8384 WIN32_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h i386-tok.h tccpe.c
8485 WIN64_FILES = $(CORE_FILES) x86_64-gen.c x86_64-asm.c x86_64-asm.h x86_64-tok.h tccpe.c
86+WINCE_FILES = $(CORE_FILES) arm-gen.c tccpe.c
8587 X86_64_FILES = $(CORE_FILES) x86_64-gen.c x86_64-asm.c x86_64-asm.h x86_64-tok.h
8688 ARM_FILES = $(CORE_FILES) arm-gen.c
8789 C67_FILES = $(CORE_FILES) c67-gen.c tcccoff.c
@@ -133,6 +135,9 @@ x86_64-tcc$(EXESUF): $(X86_64_FILES) · 45 unmodified lines
133135 c67-tcc$(EXESUF): $(C67_FILES)
134136 $(CC) -o $@ $< -DTCC_TARGET_C67 $(CFLAGS) $(LIBS)
135137
138+arm-win32-tcc$(EXESUF): $(WIN32_FILES)
139+ $(CC) -o $@ $< -DTCC_TARGET_PE -DTCC_TARGET_ARM $(CFLAGS) $(LIBS)
140+
136141 arm-tcc-fpa$(EXESUF): $(ARM_FILES)
137142 $(CC) -o $@ $< -DTCC_TARGET_ARM $(CFLAGS) $(LIBS)
138143
tcc.c+3−0
@@ -412,6 +412,9 @@ int parse_args(TCCState *s, int argc, char **argv) · 411 unmodified lines
412412 s->pe_subsystem = 12;
413413 else if (!strcmp(p, "efirom"))
414414 s->pe_subsystem = 13;
415+#elif defined(TCC_TARGET_ARM)
416+ if (!strcmp(p, "wince"))
417+ s->pe_subsystem = 9;
415418 #endif
416419 else {
417420 error("invalid subsystem '%s'", p);
tccpe.c+39−10
@@ -503,23 +503,29 @@ ST_FN int pe_write(struct pe_info *pe) · 502 unmodified lines
503503 0x00004550, /* DWORD nt_sig = IMAGE_NT_SIGNATURE */
504504 {
505505 /* IMAGE_FILE_HEADER filehdr */
506−#ifdef TCC_TARGET_X86_64
507− 0x8664, /*WORD Machine; */
508−#else
509− 0x014C, /*WORD Machine; */
506+#if defined(TCC_TARGET_I386)
507+ 0x014C, /*WORD Machine; */
508+#elif defined(TCC_TARGET_X86_64)
509+ 0x8664, /*WORD Machine; */
510+#elif defined(TCC_TARGET_ARM)
511+ 0x01C0, /*WORD Machine; */
510512 #endif
511513 0x0003, /*WORD NumberOfSections; */
512514 0x00000000, /*DWORD TimeDateStamp; */
513515 0x00000000, /*DWORD PointerToSymbolTable; */
514516 0x00000000, /*DWORD NumberOfSymbols; */
515−#ifdef TCC_TARGET_X86_64
517+#if defined(TCC_TARGET_X86_64)
516518 0x00F0, /*WORD SizeOfOptionalHeader; */
517519 0x022F /*WORD Characteristics; */
518520 #define CHARACTERISTICS_DLL 0x222E
519−#else
521+#elif defined(TCC_TARGET_I386)
520522 0x00E0, /*WORD SizeOfOptionalHeader; */
521523 0x030F /*WORD Characteristics; */
522524 #define CHARACTERISTICS_DLL 0x230E
525+#elif defined(TCC_TARGET_ARM)
526+ 0x00E0, /*WORD SizeOfOptionalHeader; */
527+ 0x010F, /*WORD Characteristics; */
528+#define CHARACTERISTICS_DLL 0x230F
523529 #endif
524530 },{
525531 /* IMAGE_OPTIONAL_HEADER opthdr */
@@ -540,7 +546,11 @@ ST_FN int pe_write(struct pe_info *pe) · 14 unmodified lines
540546 0x00000000, /*DWORD BaseOfData; */
541547 #endif
542548 /* NT additional fields. */
543− 0x00400000, /*DWORD ImageBase; */
549+#if defined(TCC_TARGET_ARM)
550+ 0x00100000, /*DWORD ImageBase; */
551+#else
552+ 0x00400000, /*DWORD ImageBase; */
553+#endif
544554 0x00001000, /*DWORD SectionAlignment; */
545555 0x00000200, /*DWORD FileAlignment; */
546556 0x0004, /*WORD MajorOperatingSystemVersion; */
@@ -699,7 +709,7 @@ ST_FN int pe_write(struct pe_info *pe) · 152 unmodified lines
699709
700710 /*----------------------------------------------------------------------------*/
701711
702−#ifdef TCC_TARGET_X86_64
712+#if defined(TCC_TARGET_X86_64)
703713 #define ELFW_R_(type) ELF64_R_##type
704714 #define ElfW_Rel ElfW(Rela)
705715
@@ -710,7 +720,7 @@ ST_FN int pe_write(struct pe_info *pe) · 4 unmodified lines
710720 #define ELFW_ST_BIND ELF64_ST_BIND
711721 #define ELFW_ST_TYPE ELF64_ST_TYPE
712722 #define ELFW_ST_INFO ELF64_ST_INFO
713−#else
723+#elif defined(TCC_TARGET_I386)
714724 #define ELFW_R_(type) ELF32_R_##type
715725 #define ElfW_Rel ElfW(Rel)
716726
@@ -718,6 +728,17 @@ ST_FN int pe_write(struct pe_info *pe) · 1 unmodified line
718728 #define R_XXX_THUNKFIX R_386_32
719729 #define R_XXX_RELATIVE R_386_RELATIVE
720730
731+#define ELFW_ST_BIND ELF32_ST_BIND
732+#define ELFW_ST_TYPE ELF32_ST_TYPE
733+#define ELFW_ST_INFO ELF32_ST_INFO
734+#elif defined(TCC_TARGET_ARM)
735+#define ELFW_R_(type) ELF32_R_##type
736+#define ElfW_Rel ElfW(Rel)
737+
738+#define REL_TYPE_DIRECT R_ARM_ABS32
739+#define R_XXX_THUNKFIX R_ARM_ABS32
740+#define R_XXX_RELATIVE R_ARM_RELATIVE
741+
721742 #define ELFW_ST_BIND ELF32_ST_BIND
722743 #define ELFW_ST_TYPE ELF32_ST_TYPE
723744 #define ELFW_ST_INFO ELF32_ST_INFO
@@ -1648,17 +1669,25 @@ PUB_FN int pe_output_file(TCCState * s1, const char *filename) · 924 unmodified lines
16481669 if (filename) {
16491670 if (PE_DLL == pe.type) {
16501671 pe.reloc = new_section(pe.s1, ".reloc", SHT_PROGBITS, 0);
1672+ /* XXX: check if is correct for arm-pe target */
16511673 pe.imagebase = 0x10000000;
16521674 } else {
1675+#if defined(TCC_TARGET_ARM)
1676+ pe.imagebase = 0x00010000;
1677+#else
16531678 pe.imagebase = 0x00400000;
1679+#endif
16541680 }
16551681
16561682 /* if no subsystem specified, we use "console" subsystem by default */
16571683 if (s1->pe_subsystem != 0)
16581684 pe.subsystem = s1->pe_subsystem;
16591685 else
1686+#if defined(TCC_TARGET_ARM)
16601687 pe.subsystem = 3;
1661−
1688+#else
1689+ pe.subsystem = 9;
1690+#endif
16621691 /* set default file/section alignment */
16631692 if (pe.subsystem == 1) {
16641693 pe.section_align = 0x20;

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