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
72I386_CROSS = i386-tcc$(EXESUF)72I386_CROSS = i386-tcc$(EXESUF)
73WIN32_CROSS = i386-win32-tcc$(EXESUF)73WIN32_CROSS = i386-win32-tcc$(EXESUF)
74WIN64_CROSS = x86_64-win32-tcc$(EXESUF)74WIN64_CROSS = x86_64-win32-tcc$(EXESUF)
75WINCE_CROSS = arm-win32-tcc$(EXESUF)
75X64_CROSS = x86_64-tcc$(EXESUF)76X64_CROSS = x86_64-tcc$(EXESUF)
76ARM_CROSS = arm-tcc-fpa$(EXESUF) arm-tcc-fpa-ld$(EXESUF) \77ARM_CROSS = arm-tcc-fpa$(EXESUF) arm-tcc-fpa-ld$(EXESUF) \
77 arm-tcc-vfp$(EXESUF) arm-tcc-vfp-eabi$(EXESUF)78 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
82I386_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h i386-tok.h83I386_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h i386-tok.h
83WIN32_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h i386-tok.h tccpe.c84WIN32_FILES = $(CORE_FILES) i386-gen.c i386-asm.c i386-asm.h i386-tok.h tccpe.c
84WIN64_FILES = $(CORE_FILES) x86_64-gen.c x86_64-asm.c x86_64-asm.h x86_64-tok.h tccpe.c85WIN64_FILES = $(CORE_FILES) x86_64-gen.c x86_64-asm.c x86_64-asm.h x86_64-tok.h tccpe.c
86WINCE_FILES = $(CORE_FILES) arm-gen.c tccpe.c
85X86_64_FILES = $(CORE_FILES) x86_64-gen.c x86_64-asm.c x86_64-asm.h x86_64-tok.h87X86_64_FILES = $(CORE_FILES) x86_64-gen.c x86_64-asm.c x86_64-asm.h x86_64-tok.h
86ARM_FILES = $(CORE_FILES) arm-gen.c88ARM_FILES = $(CORE_FILES) arm-gen.c
87C67_FILES = $(CORE_FILES) c67-gen.c tcccoff.c89C67_FILES = $(CORE_FILES) c67-gen.c tcccoff.c
@@ -133,6 +135,9 @@ x86_64-tcc$(EXESUF): $(X86_64_FILES) · 45 unmodified lines
133c67-tcc$(EXESUF): $(C67_FILES)135c67-tcc$(EXESUF): $(C67_FILES)
134 $(CC) -o $@ $< -DTCC_TARGET_C67 $(CFLAGS) $(LIBS)136 $(CC) -o $@ $< -DTCC_TARGET_C67 $(CFLAGS) $(LIBS)
135 137
138arm-win32-tcc$(EXESUF): $(WIN32_FILES)
139 $(CC) -o $@ $< -DTCC_TARGET_PE -DTCC_TARGET_ARM $(CFLAGS) $(LIBS)
140
136arm-tcc-fpa$(EXESUF): $(ARM_FILES)141arm-tcc-fpa$(EXESUF): $(ARM_FILES)
137 $(CC) -o $@ $< -DTCC_TARGET_ARM $(CFLAGS) $(LIBS)142 $(CC) -o $@ $< -DTCC_TARGET_ARM $(CFLAGS) $(LIBS)
138 143
tcc.c+3−0
@@ -412,6 +412,9 @@ int parse_args(TCCState *s, int argc, char **argv) · 411 unmodified lines
412 s->pe_subsystem = 12;412 s->pe_subsystem = 12;
413 else if (!strcmp(p, "efirom"))413 else if (!strcmp(p, "efirom"))
414 s->pe_subsystem = 13;414 s->pe_subsystem = 13;
415#elif defined(TCC_TARGET_ARM)
416 if (!strcmp(p, "wince"))
417 s->pe_subsystem = 9;
415#endif418#endif
416 else {419 else {
417 error("invalid subsystem '%s'", p);420 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
503 0x00004550, /* DWORD nt_sig = IMAGE_NT_SIGNATURE */503 0x00004550, /* DWORD nt_sig = IMAGE_NT_SIGNATURE */
504 {504 {
505 /* IMAGE_FILE_HEADER filehdr */505 /* IMAGE_FILE_HEADER filehdr */
506#ifdef TCC_TARGET_X86_64506#if defined(TCC_TARGET_I386)
507 0x8664, /*WORD Machine; */507 0x014C, /*WORD Machine; */
508#else508#elif defined(TCC_TARGET_X86_64)
509 0x014C, /*WORD Machine; */509 0x8664, /*WORD Machine; */
510#elif defined(TCC_TARGET_ARM)
511 0x01C0, /*WORD Machine; */
510#endif512#endif
511 0x0003, /*WORD NumberOfSections; */513 0x0003, /*WORD NumberOfSections; */
512 0x00000000, /*DWORD TimeDateStamp; */514 0x00000000, /*DWORD TimeDateStamp; */
513 0x00000000, /*DWORD PointerToSymbolTable; */515 0x00000000, /*DWORD PointerToSymbolTable; */
514 0x00000000, /*DWORD NumberOfSymbols; */516 0x00000000, /*DWORD NumberOfSymbols; */
515#ifdef TCC_TARGET_X86_64517#if defined(TCC_TARGET_X86_64)
516 0x00F0, /*WORD SizeOfOptionalHeader; */518 0x00F0, /*WORD SizeOfOptionalHeader; */
517 0x022F /*WORD Characteristics; */519 0x022F /*WORD Characteristics; */
518#define CHARACTERISTICS_DLL 0x222E520#define CHARACTERISTICS_DLL 0x222E
519#else521#elif defined(TCC_TARGET_I386)
520 0x00E0, /*WORD SizeOfOptionalHeader; */522 0x00E0, /*WORD SizeOfOptionalHeader; */
521 0x030F /*WORD Characteristics; */523 0x030F /*WORD Characteristics; */
522#define CHARACTERISTICS_DLL 0x230E524#define CHARACTERISTICS_DLL 0x230E
525#elif defined(TCC_TARGET_ARM)
526 0x00E0, /*WORD SizeOfOptionalHeader; */
527 0x010F, /*WORD Characteristics; */
528#define CHARACTERISTICS_DLL 0x230F
523#endif529#endif
524},{530},{
525 /* IMAGE_OPTIONAL_HEADER opthdr */531 /* IMAGE_OPTIONAL_HEADER opthdr */
@@ -540,7 +546,11 @@ ST_FN int pe_write(struct pe_info *pe) · 14 unmodified lines
540 0x00000000, /*DWORD BaseOfData; */546 0x00000000, /*DWORD BaseOfData; */
541#endif547#endif
542 /* NT additional fields. */548 /* 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
544 0x00001000, /*DWORD SectionAlignment; */554 0x00001000, /*DWORD SectionAlignment; */
545 0x00000200, /*DWORD FileAlignment; */555 0x00000200, /*DWORD FileAlignment; */
546 0x0004, /*WORD MajorOperatingSystemVersion; */556 0x0004, /*WORD MajorOperatingSystemVersion; */
@@ -699,7 +709,7 @@ ST_FN int pe_write(struct pe_info *pe) · 152 unmodified lines
699 709
700/*----------------------------------------------------------------------------*/710/*----------------------------------------------------------------------------*/
701 711
702#ifdef TCC_TARGET_X86_64712#if defined(TCC_TARGET_X86_64)
703#define ELFW_R_(type) ELF64_R_##type713#define ELFW_R_(type) ELF64_R_##type
704#define ElfW_Rel ElfW(Rela)714#define ElfW_Rel ElfW(Rela)
705 715
@@ -710,7 +720,7 @@ ST_FN int pe_write(struct pe_info *pe) · 4 unmodified lines
710#define ELFW_ST_BIND ELF64_ST_BIND720#define ELFW_ST_BIND ELF64_ST_BIND
711#define ELFW_ST_TYPE ELF64_ST_TYPE721#define ELFW_ST_TYPE ELF64_ST_TYPE
712#define ELFW_ST_INFO ELF64_ST_INFO722#define ELFW_ST_INFO ELF64_ST_INFO
713#else723#elif defined(TCC_TARGET_I386)
714#define ELFW_R_(type) ELF32_R_##type724#define ELFW_R_(type) ELF32_R_##type
715#define ElfW_Rel ElfW(Rel)725#define ElfW_Rel ElfW(Rel)
716 726
@@ -718,6 +728,17 @@ ST_FN int pe_write(struct pe_info *pe) · 1 unmodified line
718#define R_XXX_THUNKFIX R_386_32728#define R_XXX_THUNKFIX R_386_32
719#define R_XXX_RELATIVE R_386_RELATIVE729#define R_XXX_RELATIVE R_386_RELATIVE
720 730
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
721#define ELFW_ST_BIND ELF32_ST_BIND742#define ELFW_ST_BIND ELF32_ST_BIND
722#define ELFW_ST_TYPE ELF32_ST_TYPE743#define ELFW_ST_TYPE ELF32_ST_TYPE
723#define ELFW_ST_INFO ELF32_ST_INFO744#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
1648 if (filename) {1669 if (filename) {
1649 if (PE_DLL == pe.type) {1670 if (PE_DLL == pe.type) {
1650 pe.reloc = new_section(pe.s1, ".reloc", SHT_PROGBITS, 0);1671 pe.reloc = new_section(pe.s1, ".reloc", SHT_PROGBITS, 0);
1672 /* XXX: check if is correct for arm-pe target */
1651 pe.imagebase = 0x10000000;1673 pe.imagebase = 0x10000000;
1652 } else {1674 } else {
1675#if defined(TCC_TARGET_ARM)
1676 pe.imagebase = 0x00010000;
1677#else
1653 pe.imagebase = 0x00400000;1678 pe.imagebase = 0x00400000;
1679#endif
1654 }1680 }
1655 1681
1656 /* if no subsystem specified, we use "console" subsystem by default */1682 /* if no subsystem specified, we use "console" subsystem by default */
1657 if (s1->pe_subsystem != 0)1683 if (s1->pe_subsystem != 0)
1658 pe.subsystem = s1->pe_subsystem;1684 pe.subsystem = s1->pe_subsystem;
1659 else1685 else
1686#if defined(TCC_TARGET_ARM)
1660 pe.subsystem = 3;1687 pe.subsystem = 3;
1661 1688#else
1689 pe.subsystem = 9;
1690#endif
1662 /* set default file/section alignment */1691 /* set default file/section alignment */
1663 if (pe.subsystem == 1) {1692 if (pe.subsystem == 1) {
1664 pe.section_align = 0x20;1693 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