History

pe32+ target: add in various #define's

grischka committed 17 years ago

Commit 3ea4acb1 parent 719ba914 files · +18 −2Browse files

Unified · Split

4 files
  1. libtcc.c +7 −0
  2. tcc.h +2 −0
  3. tccelf.c +8 −1
  4. tccgen.c +1 −1
libtcc.c+7−0
@@ -1689,12 +1689,14 @@ int tcc_relocate(TCCState *s1, void *ptr) · 1688 unmodified lines
16891689 if (s1->nb_errors)
16901690 return -1;
16911691
1692+#ifndef TCC_TARGET_PE
16921693 #ifdef TCC_TARGET_X86_64
16931694 s1->runtime_plt_and_got_offset = 0;
16941695 s1->runtime_plt_and_got = (char *)(mem + offset);
16951696 /* double the size of the buffer for got and plt entries
16961697 XXX: calculate exact size for them? */
16971698 offset *= 2;
1699+#endif
16981700 #endif
16991701
17001702 if (0 == mem)
@@ -1722,9 +1724,11 @@ int tcc_relocate(TCCState *s1, void *ptr) · 21 unmodified lines
17221724 if (s->sh_flags & SHF_EXECINSTR)
17231725 set_pages_executable(ptr, length);
17241726 }
1727+#ifndef TCC_TARGET_PE
17251728 #ifdef TCC_TARGET_X86_64
17261729 set_pages_executable(s1->runtime_plt_and_got,
17271730 s1->runtime_plt_and_got_offset);
1731+#endif
17281732 #endif
17291733 return 0;
17301734 }
@@ -1859,6 +1863,9 @@ TCCState *tcc_new(void) · 128 unmodified lines
18591863 #endif
18601864 #ifdef TCC_TARGET_PE
18611865 tcc_define_symbol(s, "_WIN32", NULL);
1866+#ifdef TCC_TARGET_X86_64
1867+ tcc_define_symbol(s, "_WIN64", NULL);
1868+#endif
18621869 #else
18631870 tcc_define_symbol(s, "__unix__", NULL);
18641871 tcc_define_symbol(s, "__unix", NULL);
tcc.h+2−0
@@ -491,11 +491,13 @@ struct TCCState { · 490 unmodified lines
491491 struct InlineFunc **inline_fns;
492492 int nb_inline_fns;
493493
494+#ifndef TCC_TARGET_PE
494495 #ifdef TCC_TARGET_X86_64
495496 /* write PLT and GOT here */
496497 char *runtime_plt_and_got;
497498 unsigned int runtime_plt_and_got_offset;
498499 #endif
500+#endif
499501 };
500502
501503 /* The current value can be: */
tccelf.c+8−1
@@ -479,6 +479,7 @@ static void relocate_syms(TCCState *s1, int do_resolve) · 478 unmodified lines
479479 }
480480 }
481481
482+#ifndef TCC_TARGET_PE
482483 #ifdef TCC_TARGET_X86_64
483484 #define JMP_TABLE_ENTRY_SIZE 14
484485 static unsigned long add_jmp_table(TCCState *s1, unsigned long val)
@@ -502,6 +503,7 @@ static unsigned long add_got_table(TCCState *s1, unsigned long val) · 17 unmodified lines
502503 return (unsigned long)p;
503504 }
504505 #endif
506+#endif
505507
506508 /* relocate a given section (CPU dependent) */
507509 static void relocate_section(TCCState *s1, Section *s)
@@ -679,6 +681,7 @@ static void relocate_section(TCCState *s1, Section *s) · 171 unmodified lines
679681 *(int *)ptr += val;
680682 break;
681683 case R_X86_64_PC32: {
684+ long long diff;
682685 if (s1->output_type == TCC_OUTPUT_DLL) {
683686 /* DLL relocation */
684687 esym_index = s1->symtab_to_dynsym[sym_index];
@@ -690,13 +693,15 @@ static void relocate_section(TCCState *s1, Section *s) · 5 unmodified lines
690693 break;
691694 }
692695 }
693− long diff = val - addr;
696+ diff = (long long)val - addr;
694697 if (diff <= -2147483647 || diff > 2147483647) {
698+#ifndef TCC_TARGET_PE
695699 /* XXX: naive support for over 32bit jump */
696700 if (s1->output_type == TCC_OUTPUT_MEMORY) {
697701 val = add_jmp_table(s1, val);
698702 diff = val - addr;
699703 }
704+#endif
700705 if (diff <= -2147483647 || diff > 2147483647) {
701706 error("internal error: relocation failed");
702707 }
@@ -712,11 +717,13 @@ static void relocate_section(TCCState *s1, Section *s) · 9 unmodified lines
712717 *(int *)ptr = val;
713718 break;
714719 case R_X86_64_GOTPCREL:
720+#ifndef TCC_TARGET_PE
715721 if (s1->output_type == TCC_OUTPUT_MEMORY) {
716722 val = add_got_table(s1, val - rel->r_addend) + rel->r_addend;
717723 *(int *)ptr += val - addr;
718724 break;
719725 }
726+#endif
720727 *(int *)ptr += (s1->got->sh_addr - addr +
721728 s1->got_offsets[sym_index] - 4);
722729 break;
tccgen.c+1−1
@@ -2652,7 +2652,7 @@ the_end: · 2651 unmodified lines
26522652
26532653 /* long is never used as type */
26542654 if ((t & VT_BTYPE) == VT_LONG)
2655−#ifndef TCC_TARGET_X86_64
2655+#if !defined TCC_TARGET_X86_64 || defined TCC_TARGET_PE
26562656 t = (t & ~VT_BTYPE) | VT_INT;
26572657 #else
26582658 t = (t & ~VT_BTYPE) | VT_LLONG;

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