mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-04 06:30:10 +08:00
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)
This commit is contained in:
parent
a0db7162af
commit
a35b3059bb
4
tcc.c
4
tcc.c
@ -578,7 +578,11 @@ int main(int argc, char **argv)
|
|||||||
tcc_print_stats(s, getclock_us() - start_time);
|
tcc_print_stats(s, getclock_us() - start_time);
|
||||||
|
|
||||||
if (s->output_type == TCC_OUTPUT_MEMORY) {
|
if (s->output_type == TCC_OUTPUT_MEMORY) {
|
||||||
|
#ifdef TCC_IS_NATIVE
|
||||||
ret = tcc_run(s, argc - optind, argv + optind);
|
ret = tcc_run(s, argc - optind, argv + optind);
|
||||||
|
#else
|
||||||
|
tcc_error_noabort("-run is not available in a cross compiler");
|
||||||
|
#endif
|
||||||
} else if (s->output_type == TCC_OUTPUT_PREPROCESS) {
|
} else if (s->output_type == TCC_OUTPUT_PREPROCESS) {
|
||||||
if (s->outfile)
|
if (s->outfile)
|
||||||
fclose(s->outfile);
|
fclose(s->outfile);
|
||||||
|
34
tcc.h
34
tcc.h
@ -49,9 +49,6 @@
|
|||||||
#include <direct.h> /* getcwd */
|
#include <direct.h> /* getcwd */
|
||||||
#define inline __inline
|
#define inline __inline
|
||||||
#define inp next_inp
|
#define inp next_inp
|
||||||
#ifdef _WIN64
|
|
||||||
# define uplong unsigned long long
|
|
||||||
#endif
|
|
||||||
#ifdef LIBTCC_AS_DLL
|
#ifdef LIBTCC_AS_DLL
|
||||||
# define LIBTCCAPI __declspec(dllexport)
|
# define LIBTCCAPI __declspec(dllexport)
|
||||||
#endif
|
#endif
|
||||||
@ -67,17 +64,10 @@
|
|||||||
|
|
||||||
#endif /* !CONFIG_TCCBOOT */
|
#endif /* !CONFIG_TCCBOOT */
|
||||||
|
|
||||||
#ifndef uplong
|
|
||||||
#define uplong unsigned long
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef PAGESIZE
|
#ifndef PAGESIZE
|
||||||
#define PAGESIZE 4096
|
#define PAGESIZE 4096
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "elf.h"
|
|
||||||
#include "stab.h"
|
|
||||||
|
|
||||||
#ifndef O_BINARY
|
#ifndef O_BINARY
|
||||||
#define O_BINARY 0
|
#define O_BINARY 0
|
||||||
#endif
|
#endif
|
||||||
@ -86,6 +76,8 @@
|
|||||||
#define SA_SIGINFO 0x00000004u
|
#define SA_SIGINFO 0x00000004u
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "elf.h"
|
||||||
|
#include "stab.h"
|
||||||
#include "libtcc.h"
|
#include "libtcc.h"
|
||||||
|
|
||||||
/* parser debug */
|
/* parser debug */
|
||||||
@ -131,8 +123,26 @@
|
|||||||
#define TCC_TARGET_COFF
|
#define TCC_TARGET_COFF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(CONFIG_TCCBOOT)
|
/* only native compiler supports -run */
|
||||||
#define CONFIG_TCC_BACKTRACE
|
#if defined _WIN32 == defined TCC_TARGET_PE
|
||||||
|
# if (defined __i386__ || defined _X86_) && defined TCC_TARGET_I386
|
||||||
|
# define TCC_IS_NATIVE
|
||||||
|
# elif (defined __x86_64__ || defined _AMD64_) && defined TCC_TARGET_X86_64
|
||||||
|
# define TCC_IS_NATIVE
|
||||||
|
# elif defined __arm__ && defined TCC_TARGET_ARM
|
||||||
|
# define TCC_IS_NATIVE
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined TCC_IS_NATIVE && !defined CONFIG_TCCBOOT
|
||||||
|
# define CONFIG_TCC_BACKTRACE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* target address type */
|
||||||
|
#if defined TCC_TARGET_X86_64 && (!defined __x86_64__ || defined _WIN32)
|
||||||
|
# define uplong unsigned long long
|
||||||
|
#else
|
||||||
|
# define uplong unsigned long
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ------------ path configuration ------------ */
|
/* ------------ path configuration ------------ */
|
||||||
|
11
tccpe.c
11
tccpe.c
@ -38,10 +38,6 @@
|
|||||||
# define ADDR3264 DWORD
|
# define ADDR3264 DWORD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined _WIN32 && (defined _WIN64) == (defined TCC_TARGET_X86_64)
|
|
||||||
#define TCC_IS_NATIVE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void dbg_printf (const char *fmt, ...)
|
void dbg_printf (const char *fmt, ...)
|
||||||
{
|
{
|
||||||
@ -339,7 +335,7 @@ struct pe_info {
|
|||||||
const char *filename;
|
const char *filename;
|
||||||
int type;
|
int type;
|
||||||
DWORD sizeofheaders;
|
DWORD sizeofheaders;
|
||||||
DWORD imagebase;
|
ADDR3264 imagebase;
|
||||||
DWORD start_addr;
|
DWORD start_addr;
|
||||||
DWORD imp_offs;
|
DWORD imp_offs;
|
||||||
DWORD imp_size;
|
DWORD imp_size;
|
||||||
@ -1870,11 +1866,10 @@ ST_FUNC int pe_output_file(TCCState * s1, const char *filename)
|
|||||||
ret = pe_write(&pe);
|
ret = pe_write(&pe);
|
||||||
tcc_free(pe.sec_info);
|
tcc_free(pe.sec_info);
|
||||||
} else {
|
} else {
|
||||||
#ifndef TCC_IS_NATIVE
|
#ifdef TCC_IS_NATIVE
|
||||||
tcc_error_noabort("-run supported only on native platform");
|
|
||||||
#endif
|
|
||||||
pe.thunk = data_section;
|
pe.thunk = data_section;
|
||||||
pe_build_imports(&pe);
|
pe_build_imports(&pe);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PE_PRINT_SECTIONS
|
#ifdef PE_PRINT_SECTIONS
|
||||||
|
5
tccrun.c
5
tccrun.c
@ -20,6 +20,9 @@
|
|||||||
|
|
||||||
#include "tcc.h"
|
#include "tcc.h"
|
||||||
|
|
||||||
|
/* only native compiler supports -run */
|
||||||
|
#ifdef TCC_IS_NATIVE
|
||||||
|
|
||||||
#ifdef CONFIG_TCC_BACKTRACE
|
#ifdef CONFIG_TCC_BACKTRACE
|
||||||
ST_DATA int rt_num_callers = 6;
|
ST_DATA int rt_num_callers = 6;
|
||||||
ST_DATA const char **rt_bound_error_msg;
|
ST_DATA const char **rt_bound_error_msg;
|
||||||
@ -217,6 +220,8 @@ static void set_pages_executable(void *ptr, unsigned long length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
#endif /* TCC_IS_NATIVE */
|
||||||
|
|
||||||
#ifdef CONFIG_TCC_BACKTRACE
|
#ifdef CONFIG_TCC_BACKTRACE
|
||||||
|
|
||||||
PUB_FUNC void tcc_set_num_callers(int n)
|
PUB_FUNC void tcc_set_num_callers(int n)
|
||||||
|
Loading…
Reference in New Issue
Block a user