mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-27 06:10:06 +08:00
tcc.h: declare CValue.tab[LDOUBLE_SIZE/4]
Should fix some warnings wrt. access out of array bounds. tccelf.c: fix "static function unused" warning x86_64-gen.c: fix "ctype.ref uninitialzed" warning and cleanup tcc-win32.txt: remove obsolete limitation notes.
This commit is contained in:
parent
4b8e7f1f39
commit
d6d7686b60
4
Makefile
4
Makefile
@ -215,9 +215,9 @@ tiny_libmaker$(EXESUF): win32/tools/tiny_libmaker.c
|
|||||||
|
|
||||||
# TinyCC runtime libraries
|
# TinyCC runtime libraries
|
||||||
libtcc1.a : FORCE
|
libtcc1.a : FORCE
|
||||||
@$(MAKE) -C lib native
|
$(MAKE) -C lib native
|
||||||
lib/%/libtcc1.a : FORCE $(PROGS_CROSS)
|
lib/%/libtcc1.a : FORCE $(PROGS_CROSS)
|
||||||
@$(MAKE) -C lib cross TARGET=$*
|
$(MAKE) -C lib cross TARGET=$*
|
||||||
|
|
||||||
FORCE:
|
FORCE:
|
||||||
|
|
||||||
|
32
arm-gen.c
32
arm-gen.c
@ -106,15 +106,6 @@ enum {
|
|||||||
are directly pushed on stack. */
|
are directly pushed on stack. */
|
||||||
//#define FUNC_STRUCT_PARAM_AS_PTR
|
//#define FUNC_STRUCT_PARAM_AS_PTR
|
||||||
|
|
||||||
#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP)
|
|
||||||
ST_DATA CType float_type, double_type, func_float_type, func_double_type;
|
|
||||||
#define func_ldouble_type func_double_type
|
|
||||||
#else
|
|
||||||
#define func_float_type func_old_type
|
|
||||||
#define func_double_type func_old_type
|
|
||||||
#define func_ldouble_type func_old_type
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* pointer size, in bytes */
|
/* pointer size, in bytes */
|
||||||
#define PTR_SIZE 4
|
#define PTR_SIZE 4
|
||||||
|
|
||||||
@ -175,14 +166,27 @@ ST_DATA const int reg_classes[NB_REGS] = {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* keep in sync with line 104 above */
|
|
||||||
#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP)
|
|
||||||
ST_DATA CType float_type, double_type, func_float_type, func_double_type;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int func_sub_sp_offset, last_itod_magic;
|
static int func_sub_sp_offset, last_itod_magic;
|
||||||
static int leaffunc;
|
static int leaffunc;
|
||||||
|
|
||||||
|
#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP)
|
||||||
|
static CType float_type, double_type, func_float_type, func_double_type;
|
||||||
|
ST_FUNC void arm_init_types(void)
|
||||||
|
{
|
||||||
|
float_type.t = VT_FLOAT;
|
||||||
|
double_type.t = VT_DOUBLE;
|
||||||
|
func_float_type.t = VT_FUNC;
|
||||||
|
func_float_type.ref = sym_push(SYM_FIELD, &float_type, FUNC_CDECL, FUNC_OLD);
|
||||||
|
func_double_type.t = VT_FUNC;
|
||||||
|
func_double_type.ref = sym_push(SYM_FIELD, &double_type, FUNC_CDECL, FUNC_OLD);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define func_float_type func_old_type
|
||||||
|
#define func_double_type func_old_type
|
||||||
|
#define func_ldouble_type func_old_type
|
||||||
|
ST_FUNC void arm_init_types(void) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int two2mask(int a,int b) {
|
static int two2mask(int a,int b) {
|
||||||
return (reg_classes[a]|reg_classes[b])&~(RC_INT|RC_FLOAT);
|
return (reg_classes[a]|reg_classes[b])&~(RC_INT|RC_FLOAT);
|
||||||
}
|
}
|
||||||
|
12
c67-gen.c
12
c67-gen.c
@ -92,12 +92,6 @@ enum {
|
|||||||
#define REG_LRET TREG_C67_A5 /* second word return register (for long long) */
|
#define REG_LRET TREG_C67_A5 /* second word return register (for long long) */
|
||||||
#define REG_FRET TREG_C67_A4 /* float return register */
|
#define REG_FRET TREG_C67_A4 /* float return register */
|
||||||
|
|
||||||
#define ALWAYS_ASSERT(x) \
|
|
||||||
do {\
|
|
||||||
if (!(x))\
|
|
||||||
tcc_error("internal compiler error file at %s:%d", __FILE__, __LINE__);\
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
/* defined if function parameters must be evaluated in reverse order */
|
/* defined if function parameters must be evaluated in reverse order */
|
||||||
//#define INVERT_FUNC_PARAMS
|
//#define INVERT_FUNC_PARAMS
|
||||||
|
|
||||||
@ -182,6 +176,12 @@ int TotalBytesPushedOnStack;
|
|||||||
#undef BOOL
|
#undef BOOL
|
||||||
#define BOOL int
|
#define BOOL int
|
||||||
|
|
||||||
|
#define ALWAYS_ASSERT(x) \
|
||||||
|
do {\
|
||||||
|
if (!(x))\
|
||||||
|
tcc_error("internal compiler error file at %s:%d", __FILE__, __LINE__);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/******************************************************/
|
/******************************************************/
|
||||||
static unsigned long func_sub_sp_offset;
|
static unsigned long func_sub_sp_offset;
|
||||||
static int func_ret_sub;
|
static int func_ret_sub;
|
||||||
|
@ -28,6 +28,7 @@ ifndef TARGET
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
BCHECK_O = bcheck.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
DIR = $(TARGET)
|
DIR = $(TARGET)
|
||||||
@ -38,8 +39,6 @@ cross : $(DIR)/libtcc1.a
|
|||||||
native : TCC = $(TOP)/tcc$(EXESUF)
|
native : TCC = $(TOP)/tcc$(EXESUF)
|
||||||
cross : TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
|
cross : TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
|
||||||
|
|
||||||
BCHECK_O = bcheck.o
|
|
||||||
|
|
||||||
I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)
|
I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)
|
||||||
X86_64_O = libtcc1.o alloca86_64.o
|
X86_64_O = libtcc1.o alloca86_64.o
|
||||||
WIN32_O = $(I386_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
|
WIN32_O = $(I386_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
|
||||||
|
11
libtcc.c
11
libtcc.c
@ -755,15 +755,8 @@ static int tcc_compile(TCCState *s1)
|
|||||||
|
|
||||||
func_old_type.t = VT_FUNC;
|
func_old_type.t = VT_FUNC;
|
||||||
func_old_type.ref = sym_push(SYM_FIELD, &int_type, FUNC_CDECL, FUNC_OLD);
|
func_old_type.ref = sym_push(SYM_FIELD, &int_type, FUNC_CDECL, FUNC_OLD);
|
||||||
|
#ifdef TCC_TARGET_ARM
|
||||||
#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP)
|
arm_init_types();
|
||||||
float_type.t = VT_FLOAT;
|
|
||||||
double_type.t = VT_DOUBLE;
|
|
||||||
|
|
||||||
func_float_type.t = VT_FUNC;
|
|
||||||
func_float_type.ref = sym_push(SYM_FIELD, &float_type, FUNC_CDECL, FUNC_OLD);
|
|
||||||
func_double_type.t = VT_FUNC;
|
|
||||||
func_double_type.ref = sym_push(SYM_FIELD, &double_type, FUNC_CDECL, FUNC_OLD);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -68,7 +68,7 @@ ports for the ARM (@code{arm-tcc}) and the TMS320C67xx targets
|
|||||||
(@code{c67-tcc}). More information about the ARM port is available at
|
(@code{c67-tcc}). More information about the ARM port is available at
|
||||||
@url{http://lists.gnu.org/archive/html/tinycc-devel/2003-10/msg00044.html}.
|
@url{http://lists.gnu.org/archive/html/tinycc-devel/2003-10/msg00044.html}.
|
||||||
|
|
||||||
For usage on Windows, see also tcc-win32.txt.
|
For usage on Windows, see also @url{tcc-win32.txt}.
|
||||||
|
|
||||||
@node Invoke
|
@node Invoke
|
||||||
@chapter Command line invocation
|
@chapter Command line invocation
|
||||||
|
53
tcc.h
53
tcc.h
@ -113,9 +113,8 @@
|
|||||||
//#define PP_DEBUG
|
//#define PP_DEBUG
|
||||||
/* include file debug */
|
/* include file debug */
|
||||||
//#define INC_DEBUG
|
//#define INC_DEBUG
|
||||||
|
/* memory leak debug */
|
||||||
//#define MEM_DEBUG
|
//#define MEM_DEBUG
|
||||||
|
|
||||||
/* assembler debug */
|
/* assembler debug */
|
||||||
//#define ASM_DEBUG
|
//#define ASM_DEBUG
|
||||||
|
|
||||||
@ -235,6 +234,25 @@
|
|||||||
/* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */
|
/* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */
|
||||||
#define TCC_LIBGCC CONFIG_SYSROOT "/" CONFIG_LDDIR "/libgcc_s.so.1"
|
#define TCC_LIBGCC CONFIG_SYSROOT "/" CONFIG_LDDIR "/libgcc_s.so.1"
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
/* include the target specific definitions */
|
||||||
|
|
||||||
|
#define TARGET_DEFS_ONLY
|
||||||
|
#ifdef TCC_TARGET_I386
|
||||||
|
# include "i386-gen.c"
|
||||||
|
#endif
|
||||||
|
#ifdef TCC_TARGET_X86_64
|
||||||
|
# include "x86_64-gen.c"
|
||||||
|
#endif
|
||||||
|
#ifdef TCC_TARGET_ARM
|
||||||
|
# include "arm-gen.c"
|
||||||
|
#endif
|
||||||
|
#ifdef TCC_TARGET_C67
|
||||||
|
# include "coff.h"
|
||||||
|
# include "c67-gen.c"
|
||||||
|
#endif
|
||||||
|
#undef TARGET_DEFS_ONLY
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|
||||||
#define INCLUDE_STACK_SIZE 32
|
#define INCLUDE_STACK_SIZE 32
|
||||||
@ -290,7 +308,7 @@ typedef union CValue {
|
|||||||
unsigned long long ull;
|
unsigned long long ull;
|
||||||
struct CString *cstr;
|
struct CString *cstr;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
int tab[2];
|
int tab[LDOUBLE_SIZE/4];
|
||||||
} CValue;
|
} CValue;
|
||||||
|
|
||||||
/* value on stack */
|
/* value on stack */
|
||||||
@ -1240,6 +1258,12 @@ ST_FUNC int handle_eob(void);
|
|||||||
|
|
||||||
/* ------------ xxx-gen.c ------------ */
|
/* ------------ xxx-gen.c ------------ */
|
||||||
|
|
||||||
|
ST_DATA const int reg_classes[NB_REGS
|
||||||
|
#ifdef TCC_TARGET_X86_64
|
||||||
|
+ 7
|
||||||
|
#endif
|
||||||
|
];
|
||||||
|
|
||||||
ST_FUNC void gsym_addr(int t, int a);
|
ST_FUNC void gsym_addr(int t, int a);
|
||||||
ST_FUNC void gsym(int t);
|
ST_FUNC void gsym(int t);
|
||||||
ST_FUNC void load(int r, SValue *sv);
|
ST_FUNC void load(int r, SValue *sv);
|
||||||
@ -1280,10 +1304,12 @@ ST_FUNC void gen_bounded_ptr_deref(void);
|
|||||||
/* ------------ x86_64-gen.c ------------ */
|
/* ------------ x86_64-gen.c ------------ */
|
||||||
#ifdef TCC_TARGET_X86_64
|
#ifdef TCC_TARGET_X86_64
|
||||||
ST_FUNC void gen_addr64(int r, Sym *sym, int64_t c);
|
ST_FUNC void gen_addr64(int r, Sym *sym, int64_t c);
|
||||||
|
ST_FUNC void gen_opl(int op);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ------------ arm-gen.c ------------ */
|
/* ------------ arm-gen.c ------------ */
|
||||||
#ifdef TCC_TARGET_ARM
|
#ifdef TCC_TARGET_ARM
|
||||||
|
ST_FUNC void arm_init_types(void);
|
||||||
ST_FUNC uint32_t encbranch(int pos, int addr, int fail);
|
ST_FUNC uint32_t encbranch(int pos, int addr, int fail);
|
||||||
ST_FUNC void gen_cvt_itof1(int t);
|
ST_FUNC void gen_cvt_itof1(int t);
|
||||||
#endif
|
#endif
|
||||||
@ -1353,27 +1379,6 @@ PUB_FUNC void tcc_set_num_callers(int n);
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/********************************************************/
|
|
||||||
/* include the target specific definitions */
|
|
||||||
|
|
||||||
#define TARGET_DEFS_ONLY
|
|
||||||
#ifdef TCC_TARGET_I386
|
|
||||||
#include "i386-gen.c"
|
|
||||||
#endif
|
|
||||||
#ifdef TCC_TARGET_X86_64
|
|
||||||
#include "x86_64-gen.c"
|
|
||||||
#endif
|
|
||||||
#ifdef TCC_TARGET_ARM
|
|
||||||
#include "arm-gen.c"
|
|
||||||
#endif
|
|
||||||
#ifdef TCC_TARGET_C67
|
|
||||||
#include "coff.h"
|
|
||||||
#include "c67-gen.c"
|
|
||||||
#endif
|
|
||||||
#undef TARGET_DEFS_ONLY
|
|
||||||
|
|
||||||
ST_DATA const int reg_classes[];
|
|
||||||
|
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
#undef ST_DATA
|
#undef ST_DATA
|
||||||
#ifdef ONE_SOURCE
|
#ifdef ONE_SOURCE
|
||||||
|
14
tccelf.c
14
tccelf.c
@ -1314,13 +1314,6 @@ static void add_init_array_defines(TCCState *s1, const char *section_name)
|
|||||||
s->sh_num, sym_end);
|
s->sh_num, sym_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tcc_add_support(TCCState *s1, const char *filename)
|
|
||||||
{
|
|
||||||
char buf[1024];
|
|
||||||
snprintf(buf, sizeof(buf), "%s/%s", s1->tcc_lib_path, filename);
|
|
||||||
return tcc_add_file(s1, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
ST_FUNC void tcc_add_bcheck(TCCState *s1)
|
ST_FUNC void tcc_add_bcheck(TCCState *s1)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_TCC_BCHECK
|
#ifdef CONFIG_TCC_BCHECK
|
||||||
@ -1353,6 +1346,13 @@ ST_FUNC void tcc_add_bcheck(TCCState *s1)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int tcc_add_support(TCCState *s1, const char *filename)
|
||||||
|
{
|
||||||
|
char buf[1024];
|
||||||
|
snprintf(buf, sizeof(buf), "%s/%s", s1->tcc_lib_path, filename);
|
||||||
|
return tcc_add_file(s1, buf);
|
||||||
|
}
|
||||||
|
|
||||||
/* add tcc runtime libraries */
|
/* add tcc runtime libraries */
|
||||||
ST_FUNC void tcc_add_runtime(TCCState *s1)
|
ST_FUNC void tcc_add_runtime(TCCState *s1)
|
||||||
{
|
{
|
||||||
|
18
tccgen.c
18
tccgen.c
@ -344,27 +344,23 @@ static void vpushs(long long v)
|
|||||||
vsetc(&size_type, VT_CONST, &cval);
|
vsetc(&size_type, VT_CONST, &cval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* push long long constant */
|
|
||||||
static void vpushll(long long v)
|
|
||||||
{
|
|
||||||
CValue cval;
|
|
||||||
CType ctype;
|
|
||||||
ctype.t = VT_LLONG;
|
|
||||||
ctype.ref = 0;
|
|
||||||
cval.ull = v;
|
|
||||||
vsetc(&ctype, VT_CONST, &cval);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* push arbitrary 64bit constant */
|
/* push arbitrary 64bit constant */
|
||||||
void vpush64(int ty, unsigned long long v)
|
void vpush64(int ty, unsigned long long v)
|
||||||
{
|
{
|
||||||
CValue cval;
|
CValue cval;
|
||||||
CType ctype;
|
CType ctype;
|
||||||
ctype.t = ty;
|
ctype.t = ty;
|
||||||
|
ctype.ref = NULL;
|
||||||
cval.ull = v;
|
cval.ull = v;
|
||||||
vsetc(&ctype, VT_CONST, &cval);
|
vsetc(&ctype, VT_CONST, &cval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* push long long constant */
|
||||||
|
static inline void vpushll(long long v)
|
||||||
|
{
|
||||||
|
vpush64(VT_LLONG, v);
|
||||||
|
}
|
||||||
|
|
||||||
/* Return a static symbol pointing to a section */
|
/* Return a static symbol pointing to a section */
|
||||||
ST_FUNC Sym *get_sym_ref(CType *type, Section *sec, unsigned long offset, unsigned long size)
|
ST_FUNC Sym *get_sym_ref(CType *type, Section *sec, unsigned long offset, unsigned long size)
|
||||||
{
|
{
|
||||||
|
@ -7,35 +7,12 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Compilation from source:
|
|
||||||
------------------------
|
|
||||||
* You can use the MinGW and MSYS tools available at
|
|
||||||
|
|
||||||
http://www.mingw.org
|
|
||||||
|
|
||||||
Untar the TCC archive and type in the MSYS shell:
|
|
||||||
|
|
||||||
./configure
|
|
||||||
make
|
|
||||||
make install
|
|
||||||
|
|
||||||
The default install location is c:\Program Files\tcc
|
|
||||||
|
|
||||||
|
|
||||||
* Alternatively you can compile TCC with just GCC from MinGW using
|
|
||||||
|
|
||||||
win32\build-tcc.bat
|
|
||||||
|
|
||||||
To install, copy the entire contents of the win32 directory to
|
|
||||||
where you want.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Installation from the binary ZIP package:
|
Installation from the binary ZIP package:
|
||||||
-----------------------------------------
|
-----------------------------------------
|
||||||
Unzip the package to a directory of your choice.
|
Unzip the package to a directory of your choice.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Set the system PATH:
|
Set the system PATH:
|
||||||
--------------------
|
--------------------
|
||||||
To be able to invoke the compiler from everywhere on your computer by
|
To be able to invoke the compiler from everywhere on your computer by
|
||||||
@ -114,6 +91,30 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Compilation from source:
|
||||||
|
------------------------
|
||||||
|
* You can use the MinGW and MSYS tools available at
|
||||||
|
|
||||||
|
http://www.mingw.org
|
||||||
|
|
||||||
|
Untar the TCC archive and type in the MSYS shell:
|
||||||
|
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
|
||||||
|
The default install location is c:\Program Files\tcc
|
||||||
|
|
||||||
|
|
||||||
|
* Alternatively you can compile TCC with just GCC from MinGW using
|
||||||
|
|
||||||
|
win32\build-tcc.bat
|
||||||
|
|
||||||
|
To install, copy the entire contents of the win32 directory to
|
||||||
|
where you want.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Limitations:
|
Limitations:
|
||||||
------------
|
------------
|
||||||
- On the object file level, currently TCC supports only the ELF format,
|
- On the object file level, currently TCC supports only the ELF format,
|
||||||
@ -124,11 +125,7 @@
|
|||||||
|
|
||||||
- No leading underscore is generated in the ELF symbols.
|
- No leading underscore is generated in the ELF symbols.
|
||||||
|
|
||||||
- With DLLs, only functions (not data) can be im-/exported.
|
- Bounds checking (option -b) is not supported on 64-bit OS.
|
||||||
|
|
||||||
- Bounds checking (option -b) is not supported currently.
|
|
||||||
|
|
||||||
- 64-bit systems are not (yet) supported.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,9 +83,6 @@ enum {
|
|||||||
/* maximum alignment (for aligned attribute support) */
|
/* maximum alignment (for aligned attribute support) */
|
||||||
#define MAX_ALIGN 8
|
#define MAX_ALIGN 8
|
||||||
|
|
||||||
ST_FUNC void gen_opl(int op);
|
|
||||||
ST_FUNC void gen_le64(int64_t c);
|
|
||||||
|
|
||||||
/******************************************************/
|
/******************************************************/
|
||||||
/* ELF defines */
|
/* ELF defines */
|
||||||
|
|
||||||
@ -106,7 +103,7 @@ ST_FUNC void gen_le64(int64_t c);
|
|||||||
#include "tcc.h"
|
#include "tcc.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
ST_DATA const int reg_classes[] = {
|
ST_DATA const int reg_classes[NB_REGS+7] = {
|
||||||
/* eax */ RC_INT | RC_RAX,
|
/* eax */ RC_INT | RC_RAX,
|
||||||
/* ecx */ RC_INT | RC_RCX,
|
/* ecx */ RC_INT | RC_RCX,
|
||||||
/* edx */ RC_INT | RC_RDX,
|
/* edx */ RC_INT | RC_RDX,
|
||||||
|
Loading…
Reference in New Issue
Block a user