From c634c797c5211a044bc76c4419abef7872a98918 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Sat, 4 Jan 2014 20:33:21 +0800 Subject: Update Changelog from git changelog entries --- Changelog | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) (limited to 'Changelog') diff --git a/Changelog b/Changelog index 2c03673..52f8a10 100644 --- a/Changelog +++ b/Changelog @@ -1,7 +1,69 @@ Version 0.9.27: +Licensing: + +- TinyCC partly relicensed to MIT license + +User interface: + +- define __STDC_HOSTED__ (Michael Matz, Urs Janssen) +- added support for CPATH, C_INCLUDE_PATH and LD_LIBRARY_PATH (Andrew Aladjev +and Urs Janssen) +- added option -norunsrc to control argv[0] with tcc -run (James Lyon) + +Features: + +- added ABI tests with native compiler using libtcc (James Lyon) +- added CMake build system with support for cross-compilation (James Lyon) +- improved variable length array support (James Lyon) +- add the possibility to use noname functions by ordinal (YX Hao) +- add a install-strip target to install tcc (Thomas Preud'homme) + Platforms: -- Support Debian GNU/kfreeBSD 64bit userspace (Thomas Preud'homme) +- support Debian GNU/kfreeBSD 64bit userspace (Thomas Preud'homme) +- fix GNU/Hurd interpreter path (Thomas Preud'homme) +- fix configure script for FreeBSD host (Thomas Preud'homme) +- make tcc -run work reliably on ARM by flushing caches (Thomas Preud'homme) +- many x86-64 ABI fixes incl. XMM register passing (James Lyon) +- improve compatibility with mingw's long double (James Lyon) +- avoid .stabstr section name to be truncated on win32 (Roy) +- add support for load/store of _Bool value (Thomas Preud'homme) +- detect instruction with incorrect operands on x86-64 (Thomas Preud'homme) +- improved relocations on ARM (Thomas Preud'homme) +- add va_* macro implementation for ARM (Thomas Preud'homme) +- define __ARM_EABI__, __ARMEL__ and __ARM_PCS_VFP (Thomas Preud'homme) +- provide a runtime library for ARM (Thomas Preud'homme) +- improved support for ARM hard float calling convention (Thomas Preud'homme, +Daniel Glöckner) + +Bug fixes: +- various code cleaning (Urs Janssen) +- fixes of other's patches (grischka, Ramsay Jones) +- fix documentation about __TINYC__ (Urs Janssen) +- improve build of documentation (Urs Janssen) +- improve build instructions (Jov) +- switch from texi2html to makeinfo --html to build tcc-doc.html (James Lyon) +- improve out of tree build (James Lyon) +- improved passing and returning of struct (James Lyon) +- fix CMake build on i386 and x86-64 (James Lyon) +- fix i386 calling convention issue (James Lyon) +- fix error in Windows build of tests (James Lyon) +- fix x86-64 long double passing (James Lyon) +- fix crash with undefined struct (grischka) +- normalize slashes on win32 to always use backslashes (grischka) +- use runtime function for float to int conversion on i386 (grischka) +- improved documentation for include and lib lookup on win32 (grischka) +- detect redefinition of function (Thomas Preud'homme) +- detect the use of array of functions (Thomas Preud'homme) +- detect use of enumerator with wrong enumeration (Thomas Preud'homme) +- detect redefinition of enumerator or enumeration (Thomas Preud'homme) +- set the user-defined library search paths first (Vittorio Giovara) +- detect usage of incomplete types inside struct/union (Amine Najahi) +- various macro bug fixes (Joseph Poirier) +- avoid wrong trigger of assert on x86-64 platform (Thomas Preud'homme) +- fix NaN comparison (Thomas Preud'homme) +- use libtcc for static linking with runtime library (Thomas Preud'homme) +- fix negation of 0.0 and -0.0 values (Thomas Preud'homme) version 0.9.26: -- cgit v1.3.1 From b6247d1f3c34e93e8603fddf5fc6da8dc6b81d00 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Tue, 7 Jan 2014 15:23:54 +0800 Subject: Add support for runtime selection of float ABI --- Changelog | 1 + arm-gen.c | 131 ++++++++++++++++++++++++++++++++--------------------------- libtcc.c | 23 ++++++++++- tcc-doc.texi | 3 ++ tcc.c | 2 +- tcc.h | 21 +++++++--- tccelf.c | 2 +- 7 files changed, 113 insertions(+), 70 deletions(-) (limited to 'Changelog') diff --git a/Changelog b/Changelog index 52f8a10..9a497cf 100644 --- a/Changelog +++ b/Changelog @@ -18,6 +18,7 @@ Features: - improved variable length array support (James Lyon) - add the possibility to use noname functions by ordinal (YX Hao) - add a install-strip target to install tcc (Thomas Preud'homme) +- add runtime selection of float ABI on ARM (Thomas Preud'homme) Platforms: - support Debian GNU/kfreeBSD 64bit userspace (Thomas Preud'homme) diff --git a/arm-gen.c b/arm-gen.c index 05bccb0..bc24f70 100644 --- a/arm-gen.c +++ b/arm-gen.c @@ -141,6 +141,13 @@ enum { #define ELF_START_ADDR 0x00008000 #define ELF_PAGE_SIZE 0x1000 +enum float_abi { + ARM_SOFTFP_FLOAT, + ARM_HARD_FLOAT, +}; + +enum float_abi float_abi; + /******************************************************/ #else /* ! TARGET_DEFS_ONLY */ /******************************************************/ @@ -169,7 +176,7 @@ 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) +ST_FUNC void arm_init(struct TCCState *s) { float_type.t = VT_FLOAT; double_type.t = VT_DOUBLE; @@ -177,12 +184,14 @@ ST_FUNC void arm_init_types(void) 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); + + float_abi = s->float_abi; } #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) {} +ST_FUNC void arm_init(void) {} #endif static int two2mask(int a,int b) { @@ -195,6 +204,16 @@ static int regmask(int r) { /******************************************************/ +#ifdef TCC_ARM_EABI +char *default_elfinterp(struct TCCState *s) +{ + if (s->float_abi == ARM_HARD_FLOAT) + return "/lib/ld-linux-armhf.so.3"; + else + return "/lib/ld-linux.so.3"; +} +#endif + void o(uint32_t i) { /* this is a good place to start adding big-endian support*/ @@ -841,22 +860,19 @@ ST_FUNC int gfunc_sret(CType *vt, int variadic, CType *ret, int *ret_align) { #ifdef TCC_ARM_EABI int size, align; size = type_size(vt, &align); -#ifdef TCC_ARM_HARDFLOAT - if (!variadic && (is_float(vt->t) || is_hgen_float_aggr(vt))) { + if (float_abi == ARM_HARD_FLOAT && !variadic && + (is_float(vt->t) || is_hgen_float_aggr(vt))) { *ret_align = 8; ret->ref = NULL; ret->t = VT_DOUBLE; return (size + 7) >> 3; - } else -#endif - if (size > 4) { - return 0; - } else { + } else if (size <= 4) { *ret_align = 4; ret->ref = NULL; ret->t = VT_INT; return 1; - } + } else + return 0; #else return 0; #endif @@ -1171,9 +1187,11 @@ void gfunc_call(int nb_args) int todo; struct plan plan; -#ifdef TCC_ARM_HARDFLOAT - variadic = (vtop[-nb_args].type.ref->c == FUNC_ELLIPSIS); - corefloat = variadic || floats_in_core_regs(&vtop[-nb_args]); +#ifdef TCC_ARM_EABI + if (float_abi == ARM_HARD_FLOAT) { + variadic = (vtop[-nb_args].type.ref->c == FUNC_ELLIPSIS); + corefloat = variadic || floats_in_core_regs(&vtop[-nb_args]); + } #endif /* cannot let cpu flags if other instruction are generated. Also avoid leaving VT_JMP anywhere except on the top of the stack because it would complicate @@ -1199,9 +1217,9 @@ void gfunc_call(int nb_args) gcall_or_jmp(0); if (args_size) gadd_sp(args_size); /* pop all parameters passed on the stack */ -#ifdef TCC_ARM_EABI -#ifdef TCC_ARM_VFP - if(corefloat && is_float(vtop->type.ref->type.t)) { +#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP) + if(float_abi == ARM_SOFTFP_FLOAT && corefloat && + is_float(vtop->type.ref->type.t)) { if((vtop->type.ref->type.t & VT_BTYPE) == VT_FLOAT) { o(0xEE000A10); /*vmov s0, r0 */ } else { @@ -1209,7 +1227,6 @@ void gfunc_call(int nb_args) o(0xEE201B10); /* vmov.32 d0[1], r1 */ } } -#endif #endif vtop -= nb_args + 1; /* Pop all params and fct address from value stack */ leaffunc = 0; /* we are calling a function, so we aren't in a leaf function */ @@ -1220,9 +1237,8 @@ void gfunc_prolog(CType *func_type) { Sym *sym,*sym2; int n, nf, size, align, struct_ret = 0; -#ifdef TCC_ARM_HARDFLOAT + int addr, pn, sn; /* pn=core, sn=stack */ struct avail_regs avregs = AVAIL_REGS_INITIALIZER; -#endif CType ret_type; sym = func_type->ref; @@ -1237,11 +1253,11 @@ void gfunc_prolog(CType *func_type) struct_ret = 1; func_vc = 12; /* Offset from fp of the place to store the result */ } - for(sym2=sym->next;sym2 && (n<4 || nf<16);sym2=sym2->next) { + for(sym2 = sym->next; sym2 && (n < 4 || nf < 16); sym2 = sym2->next) { size = type_size(&sym2->type, &align); -#ifdef TCC_ARM_HARDFLOAT - if (!func_var && (is_float(sym2->type.t) - || is_hgen_float_aggr(&sym2->type))) { +#ifdef TCC_ARM_EABI + if (float_abi == ARM_HARD_FLOAT && !func_var && + (is_float(sym2->type.t) || is_hgen_float_aggr(&sym2->type))) { int tmpnf = assign_vfpreg(&avregs, align, size); tmpnf += (size + 3) / 4; nf = (tmpnf > nf) ? tmpnf : nf; @@ -1270,50 +1286,49 @@ void gfunc_prolog(CType *func_type) o(0xE92D5800); /* save fp, ip, lr */ o(0xE1A0B00D); /* mov fp, sp */ func_sub_sp_offset = ind; - o(0xE1A00000); /* nop, leave space for stack adjustment in epilogue */ - { - int addr, pn = struct_ret, sn = 0; /* pn=core, sn=stack */ + o(0xE1A00000); /* nop, leave space for stack adjustment in epilog */ -#ifdef TCC_ARM_HARDFLOAT +#ifdef TCC_ARM_EABI + if (float_abi == ARM_HARD_FLOAT) { func_vc += nf * 4; avregs = AVAIL_REGS_INITIALIZER; + } #endif - while ((sym = sym->next)) { - CType *type; - type = &sym->type; - size = type_size(type, &align); - size = (size + 3) >> 2; - align = (align + 3) & ~3; -#ifdef TCC_ARM_HARDFLOAT - if (!func_var && (is_float(sym->type.t) - || is_hgen_float_aggr(&sym->type))) { - int fpn = assign_vfpreg(&avregs, align, size << 2); - if (fpn >= 0) { - addr = fpn * 4; - } else - goto from_stack; - } else + pn = struct_ret, sn = 0; + while ((sym = sym->next)) { + CType *type; + type = &sym->type; + size = type_size(type, &align); + size = (size + 3) >> 2; + align = (align + 3) & ~3; +#ifdef TCC_ARM_EABI + if (float_abi == ARM_HARD_FLOAT && !func_var && (is_float(sym->type.t) + || is_hgen_float_aggr(&sym->type))) { + int fpn = assign_vfpreg(&avregs, align, size << 2); + if (fpn >= 0) + addr = fpn * 4; + else + goto from_stack; + } else #endif - if (pn < 4) { + if (pn < 4) { #ifdef TCC_ARM_EABI pn = (pn + (align-1)/4) & -(align/4); #endif - addr = (nf + pn) * 4; - pn += size; - if (!sn && pn > 4) - sn = (pn - 4); - } else { -#ifdef TCC_ARM_HARDFLOAT + addr = (nf + pn) * 4; + pn += size; + if (!sn && pn > 4) + sn = (pn - 4); + } else { from_stack: -#endif #ifdef TCC_ARM_EABI sn = (sn + (align-1)/4) & -(align/4); #endif - addr = (n + nf + sn) * 4; - sn += size; - } - sym_push(sym->v & ~SYM_FIELD, type, VT_LOCAL | lvalue_type(type->t), addr+12); + addr = (n + nf + sn) * 4; + sn += size; } + sym_push(sym->v & ~SYM_FIELD, type, VT_LOCAL | lvalue_type(type->t), + addr + 12); } last_itod_magic=0; leaffunc = 1; @@ -1327,12 +1342,8 @@ void gfunc_epilog(void) int diff; /* Copy float return value to core register if base standard is used and float computation is made with VFP */ -#ifdef TCC_ARM_EABI - if ( -#ifdef TCC_ARM_HARDFLOAT - func_var && -#endif - is_float(func_vt.t)) { +#if defined(TCC_ARM_EABI) && defined(TCC_ARM_VFP) + if ((float_abi == ARM_SOFTFP_FLOAT || func_var) && is_float(func_vt.t)) { if((func_vt.t & VT_BTYPE) == VT_FLOAT) o(0xEE100A10); /* fmrs r0, s0 */ else { diff --git a/libtcc.c b/libtcc.c index 154a266..127806f 100644 --- a/libtcc.c +++ b/libtcc.c @@ -757,7 +757,7 @@ 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); #ifdef TCC_TARGET_ARM - arm_init_types(); + arm_init(s1); #endif #if 0 @@ -945,9 +945,12 @@ LIBTCCAPI TCCState *tcc_new(void) tcc_define_symbol(s, "__ARMEL__", NULL); #if defined(TCC_ARM_EABI) tcc_define_symbol(s, "__ARM_EABI__", NULL); +#endif #if defined(TCC_ARM_HARDFLOAT) + s->float_abi = ARM_HARD_FLOAT; tcc_define_symbol(s, "__ARM_PCS_VFP", NULL); -#endif +#else + s->float_abi = ARM_SOFTFP_FLOAT; #endif #endif @@ -1628,6 +1631,7 @@ enum { TCC_OPTION_b, TCC_OPTION_g, TCC_OPTION_c, + TCC_OPTION_float_abi, TCC_OPTION_static, TCC_OPTION_shared, TCC_OPTION_soname, @@ -1680,6 +1684,9 @@ static const TCCOption tcc_options[] = { #endif { "g", TCC_OPTION_g, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP }, { "c", TCC_OPTION_c, 0 }, +#ifdef TCC_TARGET_ARM + { "mfloat-abi", TCC_OPTION_float_abi, TCC_OPTION_HAS_ARG }, +#endif { "static", TCC_OPTION_static, 0 }, { "shared", TCC_OPTION_shared, 0 }, { "soname", TCC_OPTION_soname, TCC_OPTION_HAS_ARG }, @@ -1817,6 +1824,18 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) case TCC_OPTION_c: s->output_type = TCC_OUTPUT_OBJ; break; +#ifdef TCC_TARGET_ARM + case TCC_OPTION_float_abi: + /* tcc doesn't support soft float yet */ + if (!strcmp(optarg, "softfp")) { + s->float_abi = ARM_SOFTFP_FLOAT; + tcc_undefine_symbol(s, "__ARM_PCS_VFP"); + } else if (!strcmp(optarg, "hard")) + s->float_abi = ARM_HARD_FLOAT; + else + tcc_error("unsupported float abi '%s'", optarg); + break; +#endif case TCC_OPTION_static: s->static_link = 1; break; diff --git a/tcc-doc.texi b/tcc-doc.texi index 540b4b6..e8832f6 100644 --- a/tcc-doc.texi +++ b/tcc-doc.texi @@ -176,6 +176,9 @@ In a script, it gives the following header: #!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11 @end example +@item -mfloat-abi (ARM only) +Select the float ABI. Possible values: @code{softfp} and @code{hard} + @item -dumpversion Print only the compiler version and nothing else. diff --git a/tcc.c b/tcc.c index 58f9007..9b5ca2e 100644 --- a/tcc.c +++ b/tcc.c @@ -224,7 +224,7 @@ static void display_info(TCCState *s, int what) print_paths("crt", s->crt_paths, s->nb_crt_paths); print_paths("libraries", s->library_paths, s->nb_library_paths); print_paths("include", s->sysinclude_paths, s->nb_sysinclude_paths); - printf("elfinterp:\n %s\n", CONFIG_TCC_ELFINTERP); + printf("elfinterp:\n %s\n", DEFAULT_ELFINTERP(s)); break; } } diff --git a/tcc.h b/tcc.h index f3d868f..73285ae 100644 --- a/tcc.h +++ b/tcc.h @@ -221,21 +221,24 @@ # endif # elif defined __GNU__ # define CONFIG_TCC_ELFINTERP "/lib/ld.so" -# elif defined TCC_ARM_HARDFLOAT -# define CONFIG_TCC_ELFINTERP "/lib/ld-linux-armhf.so.3" -# elif defined TCC_ARM_EABI -# define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.3" # elif defined(TCC_TARGET_X86_64) # define CONFIG_TCC_ELFINTERP "/lib64/ld-linux-x86-64.so.2" # elif defined(TCC_UCLIBC) # define CONFIG_TCC_ELFINTERP "/lib/ld-uClibc.so.0" # elif defined(TCC_TARGET_PE) # define CONFIG_TCC_ELFINTERP "-" -# else +# elif !defined(TCC_ARM_EABI) # define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.2" # endif #endif +/* var elf_interp dans *-gen.c */ +#ifdef CONFIG_TCC_ELFINTERP +# define DEFAULT_ELFINTERP(s) CONFIG_TCC_ELFINTERP +#else +# define DEFAULT_ELFINTERP(s) default_elfinterp(s) +#endif + /* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */ #define TCC_LIBGCC USE_MUADIR(CONFIG_SYSROOT "/" CONFIG_LDDIR) "/libgcc_s.so.1" @@ -561,6 +564,9 @@ struct TCCState { /* compile with built-in memory and bounds checker */ int do_bounds_check; #endif +#ifdef TCC_TARGET_ARM + enum float_abi float_abi; /* float ABI of the generated code*/ +#endif addr_t text_addr; /* address of text section */ int has_text_addr; @@ -1329,7 +1335,10 @@ ST_FUNC void gen_opl(int op); /* ------------ arm-gen.c ------------ */ #ifdef TCC_TARGET_ARM -ST_FUNC void arm_init_types(void); +#ifdef TCC_ARM_EABI +ST_FUNC char *default_elfinterp(struct TCCState *s); +#endif +ST_FUNC void arm_init(struct TCCState *s); ST_FUNC uint32_t encbranch(int pos, int addr, int fail); ST_FUNC void gen_cvt_itof1(int t); #endif diff --git a/tccelf.c b/tccelf.c index aa3daac..43a8086 100644 --- a/tccelf.c +++ b/tccelf.c @@ -1592,7 +1592,7 @@ static int elf_output_file(TCCState *s1, const char *filename) /* allow override the dynamic loader */ const char *elfint = getenv("LD_SO"); if (elfint == NULL) - elfint = CONFIG_TCC_ELFINTERP; + elfint = DEFAULT_ELFINTERP(s1); /* add interpreter section only if executable */ interp = new_section(s1, ".interp", SHT_PROGBITS, SHF_ALLOC); interp->sh_addralign = 1; -- cgit v1.3.1 From 5cbe03b9c47e676e045b4978c384087433bd6042 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Sat, 1 Feb 2014 12:29:51 +0800 Subject: Move result of itof double conv back to VFP reg EABI functions to convert an int to a double register take the integer value in core registers and also give the result in core registers. It is thus necessary to move the result back to VFP register after the function call. This only affected integer to double conversion because integer to float conversion used a VFP instruction to do the conversion and this obviously left the result in VFP register. Note that the behavior is left untouched for !EABI as the correct behavior in this case is unknown to the author of this patch. --- Changelog | 1 + arm-gen.c | 9 +++++++++ 2 files changed, 10 insertions(+) (limited to 'Changelog') diff --git a/Changelog b/Changelog index 9a497cf..20814c1 100644 --- a/Changelog +++ b/Changelog @@ -65,6 +65,7 @@ Bug fixes: - fix NaN comparison (Thomas Preud'homme) - use libtcc for static linking with runtime library (Thomas Preud'homme) - fix negation of 0.0 and -0.0 values (Thomas Preud'homme) +- fix integer to double conversion on ARM (Thomas Preud'homme) version 0.9.26: diff --git a/arm-gen.c b/arm-gen.c index 9611dca..c746e91 100644 --- a/arm-gen.c +++ b/arm-gen.c @@ -1979,8 +1979,17 @@ ST_FUNC void gen_cvt_itof1(int t) vpush_global_sym(func_type, func); vswap(); gfunc_call(1); +#if defined(TCC_ARM_VFP) && defined(TCC_ARM_EABI) + r=get_reg(RC_FLOAT); + r2=vfpr(r); + o(0xEE000B10|(r2<<16)); /* vmov.32 dr2[0], r0 */ + o(0xEE201B10|(r2<<16)); /* vmov.32 dr2[1], r1 */ + vpushi(0); + vtop->r=r; +#else vpushi(0); vtop->r=TREG_F0; +#endif return; } } -- cgit v1.3.1 From 17314a1fb316eb712ae0c539ccea64fe1aeb5c93 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Tue, 4 Feb 2014 20:54:28 +0800 Subject: Fix parameter passing of long long bitfield --- Changelog | 1 + tccgen.c | 3 +++ 2 files changed, 4 insertions(+) (limited to 'Changelog') diff --git a/Changelog b/Changelog index 20814c1..966375d 100644 --- a/Changelog +++ b/Changelog @@ -66,6 +66,7 @@ Bug fixes: - use libtcc for static linking with runtime library (Thomas Preud'homme) - fix negation of 0.0 and -0.0 values (Thomas Preud'homme) - fix integer to double conversion on ARM (Thomas Preud'homme) +- fix parameter passing of (unsigned) long long bitfield (Thomas Preud'homme) version 0.9.26: diff --git a/tccgen.c b/tccgen.c index c5e368e..03a446a 100644 --- a/tccgen.c +++ b/tccgen.c @@ -3490,6 +3490,9 @@ static void gfunc_param_typed(Sym *func, Sym *arg) if ((vtop->type.t & VT_BTYPE) == VT_FLOAT) { type.t = VT_DOUBLE; gen_cast(&type); + } else if (vtop->type.t & VT_BITFIELD) { + type.t = vtop->type.t & (VT_BTYPE | VT_UNSIGNED); + gen_cast(&type); } } else if (arg == NULL) { tcc_error("too many arguments to function"); -- cgit v1.3.1 From e571850d794c46b55f1a0fb0ffb22d594bee1d69 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Sun, 2 Feb 2014 17:15:19 +0800 Subject: Add support of Thumb to ARM branch relocation --- Changelog | 1 + tccelf.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) (limited to 'Changelog') diff --git a/Changelog b/Changelog index 966375d..b7ddd42 100644 --- a/Changelog +++ b/Changelog @@ -67,6 +67,7 @@ Bug fixes: - fix negation of 0.0 and -0.0 values (Thomas Preud'homme) - fix integer to double conversion on ARM (Thomas Preud'homme) - fix parameter passing of (unsigned) long long bitfield (Thomas Preud'homme) +- fix relocation of Thumb branch to ARM function (Thomas Preud'homme) version 0.9.26: diff --git a/tccelf.c b/tccelf.c index 66462c2..bae8972 100644 --- a/tccelf.c +++ b/tccelf.c @@ -1188,6 +1188,34 @@ ST_FUNC void build_got_entries(TCCState *s1) sym_index); } break; + case R_ARM_THM_JUMP24: + sym_index = ELFW(R_SYM)(rel->r_info); + sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; + /* We are relocating a jump from thumb code to arm code */ + if (sym->st_shndx != SHN_UNDEF && !(sym->st_value & 1)) { + int index; + uint8_t *p; + char *name, buf[1024]; + Section *text_section; + + name = symtab_section->link->data + sym->st_name; + text_section = s1->sections[sym->st_shndx]; + /* Modify reloc to target a thumb stub to switch to ARM */ + snprintf(buf, sizeof(buf), "%s_from_thumb", name); + index = put_elf_sym(symtab_section, + text_section->data_offset + 1, + sym->st_size, sym->st_info, 0, + sym->st_shndx, buf); + rel->r_info = ELFW(R_INFO)(index, type); + /* Create a thumb stub fonction to switch to ARM mode */ + put_elf_reloc(symtab_section, text_section, + text_section->data_offset, R_ARM_JUMP24, + sym_index); + p = section_ptr_add(text_section, 8); + put32(p, 0x4778); /* bx pc */ + put32(p+2, 0x46c0); /* nop */ + put32(p+4, 0xeafffffe); /* b $sym */ + } #elif defined(TCC_TARGET_C67) case R_C60_GOT32: case R_C60_GOTOFF: -- cgit v1.3.1 From b0b5165d1668373c5d7b7933da599426f33e723b Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Thu, 6 Feb 2014 20:51:47 +0800 Subject: Def signedness != signed != unsigned for char When checking for exact compatibility between types (such as in __builtin_types_compatible_p) consider the case of default signedness to be incompatible with both of the explicit signedness for char. That is, char is incompatible with signed char *and* unsigned char, no matter what the default signedness for char is. --- Changelog | 1 + tcc-doc.texi | 2 +- tcc.h | 2 +- tccgen.c | 36 +++++++++++++++++++++++------------- 4 files changed, 26 insertions(+), 15 deletions(-) (limited to 'Changelog') diff --git a/Changelog b/Changelog index b7ddd42..af206e3 100644 --- a/Changelog +++ b/Changelog @@ -68,6 +68,7 @@ Bug fixes: - fix integer to double conversion on ARM (Thomas Preud'homme) - fix parameter passing of (unsigned) long long bitfield (Thomas Preud'homme) - fix relocation of Thumb branch to ARM function (Thomas Preud'homme) +- fix char wrong compatibility with [un]signed char (Thomas Preud'homme) version 0.9.26: diff --git a/tcc-doc.texi b/tcc-doc.texi index e8832f6..3a1c7df 100644 --- a/tcc-doc.texi +++ b/tcc-doc.texi @@ -970,7 +970,7 @@ be the best solution. #define VT_BITFIELD 0x0040 /* bitfield modifier */ #define VT_CONSTANT 0x0800 /* const modifier */ #define VT_VOLATILE 0x1000 /* volatile modifier */ -#define VT_SIGNED 0x2000 /* signed type */ +#define VT_DEFSIGN 0x2000 /* signed type */ #define VT_STRUCT_SHIFT 18 /* structure/enum name shift (14 bits left) */ @end example diff --git a/tcc.h b/tcc.h index 73285ae..476cdf7 100644 --- a/tcc.h +++ b/tcc.h @@ -745,7 +745,7 @@ struct TCCState { #define VT_BITFIELD 0x0040 /* bitfield modifier */ #define VT_CONSTANT 0x0800 /* const modifier */ #define VT_VOLATILE 0x1000 /* volatile modifier */ -#define VT_SIGNED 0x2000 /* signed type */ +#define VT_DEFSIGN 0x2000 /* signed type */ #define VT_VLA 0x00020000 /* VLA type (also has VT_PTR and VT_ARRAY) */ /* storage */ diff --git a/tccgen.c b/tccgen.c index 03a446a..2f5b366 100644 --- a/tccgen.c +++ b/tccgen.c @@ -949,7 +949,7 @@ static void lexpand(void) { int u; - u = vtop->type.t & VT_UNSIGNED; + u = vtop->type.t & (VT_DEFSIGN | VT_UNSIGNED); gv(RC_INT); vdup(); vtop[0].r = vtop[-1].r2; @@ -965,7 +965,7 @@ ST_FUNC void lexpand_nr(void) { int u,v; - u = vtop->type.t & VT_UNSIGNED; + u = vtop->type.t & (VT_DEFSIGN | VT_UNSIGNED); vdup(); vtop->r2 = VT_CONST; vtop->type.t = VT_INT | u; @@ -1621,8 +1621,8 @@ static void check_comparison_pointer_types(SValue *p1, SValue *p2, int op) return; tmp_type1 = *type1; tmp_type2 = *type2; - tmp_type1.t &= ~(VT_UNSIGNED | VT_CONSTANT | VT_VOLATILE); - tmp_type2.t &= ~(VT_UNSIGNED | VT_CONSTANT | VT_VOLATILE); + tmp_type1.t &= ~(VT_DEFSIGN | VT_UNSIGNED | VT_CONSTANT | VT_VOLATILE); + tmp_type2.t &= ~(VT_DEFSIGN | VT_UNSIGNED | VT_CONSTANT | VT_VOLATILE); if (!is_compatible_types(&tmp_type1, &tmp_type2)) { /* gcc-like error if '-' is used */ if (op == '-') @@ -2212,6 +2212,11 @@ static int compare_types(CType *type1, CType *type2, int unqualified) t1 &= ~(VT_CONSTANT | VT_VOLATILE); t2 &= ~(VT_CONSTANT | VT_VOLATILE); } + /* Default Vs explicit signedness only matters for char */ + if ((t1 & VT_BTYPE) != VT_BYTE) { + t1 &= ~VT_DEFSIGN; + t2 &= ~VT_DEFSIGN; + } /* XXX: bitfields ? */ if (t1 != t2) return 0; @@ -2264,8 +2269,10 @@ static void type_to_str(char *buf, int buf_size, pstrcat(buf, buf_size, "const "); if (t & VT_VOLATILE) pstrcat(buf, buf_size, "volatile "); - if (t & VT_UNSIGNED) + if (t & (VT_DEFSIGN | VT_UNSIGNED)) pstrcat(buf, buf_size, "unsigned "); + else if (t & VT_DEFSIGN) + pstrcat(buf, buf_size, "signed "); switch(bt) { case VT_VOID: tstr = "void"; @@ -2385,8 +2392,10 @@ static void gen_assign_cast(CType *dt) /* exact type match, except for unsigned */ tmp_type1 = *type1; tmp_type2 = *type2; - tmp_type1.t &= ~(VT_UNSIGNED | VT_CONSTANT | VT_VOLATILE); - tmp_type2.t &= ~(VT_UNSIGNED | VT_CONSTANT | VT_VOLATILE); + tmp_type1.t &= ~(VT_DEFSIGN | VT_UNSIGNED | VT_CONSTANT | + VT_VOLATILE); + tmp_type2.t &= ~(VT_DEFSIGN | VT_UNSIGNED | VT_CONSTANT | + VT_VOLATILE); if (!is_compatible_types(&tmp_type1, &tmp_type2)) tcc_warning("assignment from incompatible pointer type"); } @@ -3081,8 +3090,10 @@ static int parse_btype(CType *type, AttributeDef *ad) case TOK_SIGNED1: case TOK_SIGNED2: case TOK_SIGNED3: + if ((t & (VT_DEFSIGN|VT_UNSIGNED)) == (VT_DEFSIGN|VT_UNSIGNED)) + tcc_error("signed and unsigned modifier"); typespec_found = 1; - t |= VT_SIGNED; + t |= VT_DEFSIGN; next(); break; case TOK_REGISTER: @@ -3093,7 +3104,9 @@ static int parse_btype(CType *type, AttributeDef *ad) next(); break; case TOK_UNSIGNED: - t |= VT_UNSIGNED; + if ((t & (VT_DEFSIGN|VT_UNSIGNED)) == VT_DEFSIGN) + tcc_error("signed and unsigned modifier"); + t |= VT_DEFSIGN | VT_UNSIGNED; next(); typespec_found = 1; break; @@ -3160,13 +3173,10 @@ static int parse_btype(CType *type, AttributeDef *ad) type_found = 1; } the_end: - if ((t & (VT_SIGNED|VT_UNSIGNED)) == (VT_SIGNED|VT_UNSIGNED)) - tcc_error("signed and unsigned modifier"); if (tcc_state->char_is_unsigned) { - if ((t & (VT_SIGNED|VT_UNSIGNED|VT_BTYPE)) == VT_BYTE) + if ((t & (VT_DEFSIGN|VT_BTYPE)) == VT_BYTE) t |= VT_UNSIGNED; } - t &= ~VT_SIGNED; /* long is never used as type */ if ((t & VT_BTYPE) == VT_LONG) -- cgit v1.3.1 From fdc31e152ba8496bee1da0358e458f9f1234e0c4 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Sat, 4 Jan 2014 20:33:21 +0800 Subject: Update Changelog from git changelog entries --- Changelog | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 4 deletions(-) (limited to 'Changelog') diff --git a/Changelog b/Changelog index af206e3..f780a27 100644 --- a/Changelog +++ b/Changelog @@ -10,6 +10,11 @@ User interface: - added support for CPATH, C_INCLUDE_PATH and LD_LIBRARY_PATH (Andrew Aladjev and Urs Janssen) - added option -norunsrc to control argv[0] with tcc -run (James Lyon) +- improve --with-libgcc configure help (grischka) +- improve error message when memory is full (grischka) +- improve wording about compiler switches in documentation (Thomas Preud'homme) +- use GNU triplet prefix for cross compiler names (Thomas Preud'homme) +- ignore unknown linker optimization and as-needed option (Austin English) Features: @@ -34,12 +39,20 @@ Platforms: - add va_* macro implementation for ARM (Thomas Preud'homme) - define __ARM_EABI__, __ARMEL__ and __ARM_PCS_VFP (Thomas Preud'homme) - provide a runtime library for ARM (Thomas Preud'homme) -- improved support for ARM hard float calling convention (Thomas Preud'homme, -Daniel Glöckner) +- vastly improved support for ARM hard float calling convention +(Thomas Preud'homme, Daniel Glöckner) +- tcc can uses libtcc1 on ARM (Thomas Preud'homme) +- use __fixdfdi for all float to integer conversion (grischka) +- simplify startup code for unix platforms (grischka) +- improve ELF generated on ARM (Thomas Preud'homme) +- add support for thumb to ARM relocation (Thomas Preud'homme) +- fix globbing to match MSVC on Windows (Thomas Preud'homme) +- deprecate FPA and OABI support for ARM (Thomas Preud'homme) +- warn about softfloat not being supported on ARM (Thomas Preud'homme) Bug fixes: -- various code cleaning (Urs Janssen) -- fixes of other's patches (grischka, Ramsay Jones) +- many code clean up (Urs Janssen, grischka) +- fixes of other's patches (grischka, Ramsay Jones, Michael Matz) - fix documentation about __TINYC__ (Urs Janssen) - improve build of documentation (Urs Janssen) - improve build instructions (Jov) @@ -65,10 +78,47 @@ Bug fixes: - fix NaN comparison (Thomas Preud'homme) - use libtcc for static linking with runtime library (Thomas Preud'homme) - fix negation of 0.0 and -0.0 values (Thomas Preud'homme) +- fix use of long long as if condition (Thomas Preud'homme) +- disable bound check if libgcc is used (Thomas Preud'homme) +- error out when casting to void (grischka) +- remove circular dependency in Makefile (grischka) +- stop preventing gcc to do strict aliasing (grischka) +- fix Windows build of tcc (grischka) +- build runtime library for arm cross compiler (Thomas Preud'homme) +- fix installation of arm cross-compiler (Thomas Preud'homme) +- add basic test for cross-compiler (Thomas Preud'homme) +- fix failure when generating PE on x86-64 (Archidemon) +- fix floating point unary minus and plus (Michael Matz) +- add more tests for signed zero float (Michael Matz) +- fix precision of double on x86-64 (Vincent Lefevre) +- fix bound checking of argv with -run switch (Kirill Smelkov) +- work around a wine cmd bug when building tcc on Windows (Austin English) +- reenable some bound check tests (grischka) +- boundtest.c lookup honors VPATH (grischka) +- diff compared to CC in test[123]b? are now errors (grischka) +- fix test3 on Windows (grischka) +- prevent gcc from building (non functional) libtcc.a (grischka) +- fix warning related to PE file generation on x86-64 (grischka) +- stop mixing ordinary and implicit rule in Makefile (Iavael) - fix integer to double conversion on ARM (Thomas Preud'homme) +- fix parameter passing of structure < 4 bytes on ARM (Thomas Preud'homme) +- disable builtin_frame_address test on ARM due to gcc bug (Thomas Preud'homme) +- fix initialization of struct on ARM (Thomas Preud'homme) - fix parameter passing of (unsigned) long long bitfield (Thomas Preud'homme) +- improve float to integer tests (Thomas Preud'homme) - fix relocation of Thumb branch to ARM function (Thomas Preud'homme) - fix char wrong compatibility with [un]signed char (Thomas Preud'homme) +- choose the code to compile based on target in libtcc1 (Thomas Preud'homme) +- fix various clang warnings (Thomas Preud'homme) +- don't hardcode tcc in Makefile for tests (Thomas Preud'homme) +- fix relocation of __bound_init bound checking code (Thomas Preud'homme) +- accept only one basic type for a given variable (Thomas Preud'homme) +- fix error when using va_* with tcc using libgcc (Thomas Preud'homme) +- support GOT32 and PLT32 reloc on the same symbol (Thomas Preud'homme) +- fix memory leak due to symbol attributes (mingodad) +- partially fix bound checking of argv and arge (Thomas Preud'homme) +- fix possible dereference when getting name of symbol (grischka) +- fix va_list type definition on x86-64 (Daniel Glöckner) version 0.9.26: -- cgit v1.3.1 From 01cf514e59475d73363332e238ad552ae144a1aa Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Sat, 4 Jan 2014 20:33:21 +0800 Subject: Update Changelog from git changelog entries --- Changelog | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Changelog') diff --git a/Changelog b/Changelog index f780a27..4370310 100644 --- a/Changelog +++ b/Changelog @@ -24,6 +24,7 @@ Features: - add the possibility to use noname functions by ordinal (YX Hao) - add a install-strip target to install tcc (Thomas Preud'homme) - add runtime selection of float ABI on ARM (Thomas Preud'homme) +- add shared lib support on x86-64 (Michael Matz) Platforms: - support Debian GNU/kfreeBSD 64bit userspace (Thomas Preud'homme) @@ -119,6 +120,7 @@ Bug fixes: - partially fix bound checking of argv and arge (Thomas Preud'homme) - fix possible dereference when getting name of symbol (grischka) - fix va_list type definition on x86-64 (Daniel Glöckner) +- reduce number of scan-build false positive (mingodad) version 0.9.26: -- cgit v1.3.1