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.
master
grischka 2013-02-08 19:07:11 +01:00
parent 4b8e7f1f39
commit d6d7686b60
11 changed files with 100 additions and 109 deletions

View File

@ -215,9 +215,9 @@ tiny_libmaker$(EXESUF): win32/tools/tiny_libmaker.c
# TinyCC runtime libraries
libtcc1.a : FORCE
@$(MAKE) -C lib native
$(MAKE) -C lib native
lib/%/libtcc1.a : FORCE $(PROGS_CROSS)
@$(MAKE) -C lib cross TARGET=$*
$(MAKE) -C lib cross TARGET=$*
FORCE:

View File

@ -106,15 +106,6 @@ enum {
are directly pushed on stack. */
//#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 */
#define PTR_SIZE 4
@ -175,14 +166,27 @@ ST_DATA const int reg_classes[NB_REGS] = {
#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 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) {
return (reg_classes[a]|reg_classes[b])&~(RC_INT|RC_FLOAT);
}

View File

@ -92,12 +92,6 @@ enum {
#define REG_LRET TREG_C67_A5 /* second word return register (for long long) */
#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 */
//#define INVERT_FUNC_PARAMS
@ -182,6 +176,12 @@ int TotalBytesPushedOnStack;
#undef BOOL
#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 int func_ret_sub;

View File

@ -28,6 +28,7 @@ ifndef TARGET
endif
endif
endif
BCHECK_O = bcheck.o
endif
DIR = $(TARGET)
@ -38,8 +39,6 @@ cross : $(DIR)/libtcc1.a
native : TCC = $(TOP)/tcc$(EXESUF)
cross : TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
BCHECK_O = bcheck.o
I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)
X86_64_O = libtcc1.o alloca86_64.o
WIN32_O = $(I386_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o

View File

@ -755,15 +755,8 @@ static int tcc_compile(TCCState *s1)
func_old_type.t = VT_FUNC;
func_old_type.ref = sym_push(SYM_FIELD, &int_type, FUNC_CDECL, FUNC_OLD);
#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP)
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);
#ifdef TCC_TARGET_ARM
arm_init_types();
#endif
#if 0

View File

@ -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
@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
@chapter Command line invocation

53
tcc.h
View File

@ -113,9 +113,8 @@
//#define PP_DEBUG
/* include file debug */
//#define INC_DEBUG
/* memory leak debug */
//#define MEM_DEBUG
/* assembler debug */
//#define ASM_DEBUG
@ -235,6 +234,25 @@
/* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */
#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
@ -290,7 +308,7 @@ typedef union CValue {
unsigned long long ull;
struct CString *cstr;
void *ptr;
int tab[2];
int tab[LDOUBLE_SIZE/4];
} CValue;
/* value on stack */
@ -1240,6 +1258,12 @@ ST_FUNC int handle_eob(void);
/* ------------ 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(int t);
ST_FUNC void load(int r, SValue *sv);
@ -1280,10 +1304,12 @@ ST_FUNC void gen_bounded_ptr_deref(void);
/* ------------ x86_64-gen.c ------------ */
#ifdef TCC_TARGET_X86_64
ST_FUNC void gen_addr64(int r, Sym *sym, int64_t c);
ST_FUNC void gen_opl(int op);
#endif
/* ------------ arm-gen.c ------------ */
#ifdef TCC_TARGET_ARM
ST_FUNC void arm_init_types(void);
ST_FUNC uint32_t encbranch(int pos, int addr, int fail);
ST_FUNC void gen_cvt_itof1(int t);
#endif
@ -1353,27 +1379,6 @@ PUB_FUNC void tcc_set_num_callers(int n);
#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
#ifdef ONE_SOURCE

View File

@ -1314,13 +1314,6 @@ static void add_init_array_defines(TCCState *s1, const char *section_name)
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)
{
#ifdef CONFIG_TCC_BCHECK
@ -1353,6 +1346,13 @@ ST_FUNC void tcc_add_bcheck(TCCState *s1)
#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 */
ST_FUNC void tcc_add_runtime(TCCState *s1)
{

View File

@ -344,27 +344,23 @@ static void vpushs(long long v)
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 */
void vpush64(int ty, unsigned long long v)
{
CValue cval;
CType ctype;
ctype.t = ty;
ctype.ref = NULL;
cval.ull = v;
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 */
ST_FUNC Sym *get_sym_ref(CType *type, Section *sec, unsigned long offset, unsigned long size)
{

View File

@ -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:
-----------------------------------------
Unzip the package to a directory of your choice.
Set the system PATH:
--------------------
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:
------------
- 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.
- With DLLs, only functions (not data) can be im-/exported.
- Bounds checking (option -b) is not supported currently.
- 64-bit systems are not (yet) supported.
- Bounds checking (option -b) is not supported on 64-bit OS.

View File

@ -83,9 +83,6 @@ enum {
/* maximum alignment (for aligned attribute support) */
#define MAX_ALIGN 8
ST_FUNC void gen_opl(int op);
ST_FUNC void gen_le64(int64_t c);
/******************************************************/
/* ELF defines */
@ -106,7 +103,7 @@ ST_FUNC void gen_le64(int64_t c);
#include "tcc.h"
#include <assert.h>
ST_DATA const int reg_classes[] = {
ST_DATA const int reg_classes[NB_REGS+7] = {
/* eax */ RC_INT | RC_RAX,
/* ecx */ RC_INT | RC_RCX,
/* edx */ RC_INT | RC_RDX,