History

tcc.h: define TCC_IS_NATIVE

- disable tccrun feature for non-native (cross-) compilers - define uplong for target adress size - fix using -Wl,-Ttext=... for Win64 (tccpe: ADDR3264 imagebase)

grischka committed 14 years ago

Commit a35b3051 parent a0db7164 files · +34 −20Browse files

Unified · Split

4 files
  1. tcc.c +4 −0
  2. tcc.h +22 −12
  3. tccpe.c +3 −8
  4. tccrun.c +5 −0
tcc.c+4−0
@@ -578,7 +578,11 @@ int main(int argc, char **argv) · 577 unmodified lines
578 tcc_print_stats(s, getclock_us() - start_time);578 tcc_print_stats(s, getclock_us() - start_time);
579 579
580 if (s->output_type == TCC_OUTPUT_MEMORY) {580 if (s->output_type == TCC_OUTPUT_MEMORY) {
581#ifdef TCC_IS_NATIVE
581 ret = tcc_run(s, argc - optind, argv + optind);582 ret = tcc_run(s, argc - optind, argv + optind);
583#else
584 tcc_error_noabort("-run is not available in a cross compiler");
585#endif
582 } else if (s->output_type == TCC_OUTPUT_PREPROCESS) {586 } else if (s->output_type == TCC_OUTPUT_PREPROCESS) {
583 if (s->outfile)587 if (s->outfile)
584 fclose(s->outfile);588 fclose(s->outfile);
tcc.h+22−12
@@ -49,9 +49,6 @@ · 48 unmodified lines
49#include <direct.h> /* getcwd */49#include <direct.h> /* getcwd */
50#define inline __inline50#define inline __inline
51#define inp next_inp51#define inp next_inp
52#ifdef _WIN64
53# define uplong unsigned long long
54#endif
55#ifdef LIBTCC_AS_DLL52#ifdef LIBTCC_AS_DLL
56# define LIBTCCAPI __declspec(dllexport)53# define LIBTCCAPI __declspec(dllexport)
57#endif54#endif
@@ -67,17 +64,10 @@ · 9 unmodified lines
67 64
68#endif /* !CONFIG_TCCBOOT */65#endif /* !CONFIG_TCCBOOT */
69 66
70#ifndef uplong
71#define uplong unsigned long
72#endif
73
74#ifndef PAGESIZE67#ifndef PAGESIZE
75#define PAGESIZE 409668#define PAGESIZE 4096
76#endif69#endif
77 70
78#include "elf.h"
79#include "stab.h"
80
81#ifndef O_BINARY71#ifndef O_BINARY
82#define O_BINARY 072#define O_BINARY 0
83#endif73#endif
@@ -86,6 +76,8 @@ · 2 unmodified lines
86#define SA_SIGINFO 0x00000004u76#define SA_SIGINFO 0x00000004u
87#endif77#endif
88 78
79#include "elf.h"
80#include "stab.h"
89#include "libtcc.h"81#include "libtcc.h"
90 82
91/* parser debug */83/* parser debug */
@@ -131,8 +123,26 @@ · 39 unmodified lines
131#define TCC_TARGET_COFF123#define TCC_TARGET_COFF
132#endif124#endif
133 125
134#if !defined(CONFIG_TCCBOOT)126/* only native compiler supports -run */
135#define CONFIG_TCC_BACKTRACE127#if defined _WIN32 == defined TCC_TARGET_PE
128# if (defined __i386__ || defined _X86_) && defined TCC_TARGET_I386
129# define TCC_IS_NATIVE
130# elif (defined __x86_64__ || defined _AMD64_) && defined TCC_TARGET_X86_64
131# define TCC_IS_NATIVE
132# elif defined __arm__ && defined TCC_TARGET_ARM
133# define TCC_IS_NATIVE
134# endif
135#endif
136
137#if defined TCC_IS_NATIVE && !defined CONFIG_TCCBOOT
138# define CONFIG_TCC_BACKTRACE
139#endif
140
141/* target address type */
142#if defined TCC_TARGET_X86_64 && (!defined __x86_64__ || defined _WIN32)
143# define uplong unsigned long long
144#else
145# define uplong unsigned long
136#endif146#endif
137 147
138/* ------------ path configuration ------------ */148/* ------------ path configuration ------------ */
tccpe.c+3−8
@@ -38,10 +38,6 @@ · 37 unmodified lines
38# define ADDR3264 DWORD38# define ADDR3264 DWORD
39#endif39#endif
40 40
41#if defined _WIN32 && (defined _WIN64) == (defined TCC_TARGET_X86_64)
42#define TCC_IS_NATIVE
43#endif
44
45#ifdef _WIN3241#ifdef _WIN32
46void dbg_printf (const char *fmt, ...)42void dbg_printf (const char *fmt, ...)
47{43{
@@ -339,7 +335,7 @@ struct pe_info { · 291 unmodified lines
339 const char *filename;335 const char *filename;
340 int type;336 int type;
341 DWORD sizeofheaders;337 DWORD sizeofheaders;
342 DWORD imagebase;338 ADDR3264 imagebase;
343 DWORD start_addr;339 DWORD start_addr;
344 DWORD imp_offs;340 DWORD imp_offs;
345 DWORD imp_size;341 DWORD imp_size;
@@ -1870,11 +1866,10 @@ ST_FUNC int pe_output_file(TCCState * s1, const char *filename) · 1524 unmodified lines
1870 ret = pe_write(&pe);1866 ret = pe_write(&pe);
1871 tcc_free(pe.sec_info);1867 tcc_free(pe.sec_info);
1872 } else {1868 } else {
1873#ifndef TCC_IS_NATIVE1869#ifdef TCC_IS_NATIVE
1874 tcc_error_noabort("-run supported only on native platform");
1875#endif
1876 pe.thunk = data_section;1870 pe.thunk = data_section;
1877 pe_build_imports(&pe);1871 pe_build_imports(&pe);
1872#endif
1878 }1873 }
1879 1874
1880#ifdef PE_PRINT_SECTIONS1875#ifdef PE_PRINT_SECTIONS
tccrun.c+5−0
@@ -20,6 +20,9 @@ · 19 unmodified lines
20 20
21#include "tcc.h"21#include "tcc.h"
22 22
23/* only native compiler supports -run */
24#ifdef TCC_IS_NATIVE
25
23#ifdef CONFIG_TCC_BACKTRACE26#ifdef CONFIG_TCC_BACKTRACE
24ST_DATA int rt_num_callers = 6;27ST_DATA int rt_num_callers = 6;
25ST_DATA const char **rt_bound_error_msg;28ST_DATA const char **rt_bound_error_msg;
@@ -217,6 +220,8 @@ static void set_pages_executable(void *ptr, unsigned long length) · 191 unmodified lines
217}220}
218 221
219/* ------------------------------------------------------------- */222/* ------------------------------------------------------------- */
223#endif /* TCC_IS_NATIVE */
224
220#ifdef CONFIG_TCC_BACKTRACE225#ifdef CONFIG_TCC_BACKTRACE
221 226
222PUB_FUNC void tcc_set_num_callers(int n)227PUB_FUNC void tcc_set_num_callers(int n)

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