mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-27 06:10:06 +08:00
configure: --config-musl/-uClibc switch & misc cleanups
- configure:
- add --config-uClibc,-musl switch and suggest to use
it if uClibc/musl is detected
- make warning options magic clang compatible
- simplify (use $confvars instead of individual options)
- Revert "Remove some unused-parameter lint"
7443db0d5f
rather use -Wno-unused-parameter (or just not -Wextra)
- #ifdef functions that are unused on some targets
- tccgen.c: use PTR_SIZE==8 instead of (X86_64 || ARM64)
- tccpe.c: fix some warnings
- integrate dummy arm-asm better
This commit is contained in:
parent
3a9d6b3655
commit
28435ec58c
30
Makefile
30
Makefile
@ -10,15 +10,8 @@ endif
|
||||
|
||||
include $(TOP)/config.mak
|
||||
|
||||
ifeq (-$(findstring gcc,$(CC))-,-gcc-)
|
||||
ifeq (-$(GCC_MAJOR)-$(findstring $(GCC_MINOR),56789)-,-4--)
|
||||
CFLAGS += -D_FORTIFY_SOURCE=0
|
||||
endif
|
||||
else
|
||||
ifeq (-$(findstring clang,$(CC))-,-clang-)
|
||||
# make clang accept gnuisms in libtcc1.c
|
||||
CFLAGS+=-fheinous-gnu-extensions
|
||||
endif
|
||||
ifeq (-$(CC)-$(GCC_MAJOR)-$(findstring $(GCC_MINOR),56789)-,-gcc-4--)
|
||||
CFLAGS += -D_FORTIFY_SOURCE=0
|
||||
endif
|
||||
|
||||
LIBTCC = libtcc.a
|
||||
@ -30,7 +23,7 @@ CFLAGS += $(CPPFLAGS)
|
||||
VPATH = $(TOPSRC)
|
||||
|
||||
ifdef CONFIG_WIN32
|
||||
ifneq ($(DISABLE_STATIC),no)
|
||||
ifneq ($(CONFIG_static),yes)
|
||||
LIBTCC = libtcc$(DLLSUF)
|
||||
LIBTCCDEF = libtcc.def
|
||||
endif
|
||||
@ -38,14 +31,14 @@ ifdef CONFIG_WIN32
|
||||
NATIVE_TARGET = $(ARCH)-win$(if $(findstring arm,$(ARCH)),ce,32)
|
||||
else
|
||||
LIBS=-lm
|
||||
ifndef CONFIG_NOLDL
|
||||
ifneq ($(CONFIG_ldl),no)
|
||||
LIBS+=-ldl
|
||||
endif
|
||||
# make libtcc as static or dynamic library?
|
||||
ifeq ($(DISABLE_STATIC),yes)
|
||||
ifeq ($(CONFIG_static),no)
|
||||
LIBTCC=libtcc$(DLLSUF)
|
||||
export LD_LIBRARY_PATH := $(CURDIR)/$(TOP)
|
||||
ifndef DISABLE_RPATH
|
||||
ifneq ($(CONFIG_rpath),no)
|
||||
LINK_LIBTCC += -Wl,-rpath,"$(libdir)"
|
||||
endif
|
||||
endif
|
||||
@ -78,6 +71,8 @@ NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE
|
||||
NATIVE_DEFINES_$(CONFIG_OSX) += -DTCC_TARGET_MACHO
|
||||
NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC
|
||||
NATIVE_DEFINES_$(CONFIG_musl) += -DTCC_MUSL
|
||||
NATIVE_DEFINES_$(CONFIG_libgcc) += -DCONFIG_USE_LIBGCC
|
||||
NATIVE_DEFINES_$(CONFIG_selinux) += -DHAVE_SELINUX
|
||||
NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM
|
||||
NATIVE_DEFINES_$(CONFIG_arm_eabihf) += -DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT
|
||||
NATIVE_DEFINES_$(CONFIG_arm_eabi) += -DTCC_ARM_EABI
|
||||
@ -114,7 +109,7 @@ cross-%: %-tcc$(EXESUF) libtcc1-%.a ;
|
||||
install: install$(CFGWIN)
|
||||
uninstall: uninstall$(CFGWIN)
|
||||
|
||||
ifdef CONFIG_CROSS
|
||||
ifdef CONFIG_cross
|
||||
all : cross
|
||||
endif
|
||||
|
||||
@ -172,7 +167,7 @@ arm64_FILES = $(CORE_FILES) arm64-gen.c arm64-link.c
|
||||
c67_FILES = $(CORE_FILES) c67-gen.c c67-link.c tcccoff.c
|
||||
|
||||
# libtcc sources
|
||||
LIBTCC_SRC = $(filter-out tcc.c tcctools.c arm-asm.c,$(filter %.c,$($T_FILES)))
|
||||
LIBTCC_SRC = $(filter-out tcc.c tcctools.c,$(filter %.c,$($T_FILES)))
|
||||
|
||||
ifeq ($(ONE_SOURCE),yes)
|
||||
LIBTCC_OBJ = $(X)libtcc.o
|
||||
@ -191,7 +186,6 @@ $(X)%.o : %.c $(LIBTCC_INC)
|
||||
|
||||
# additional dependencies
|
||||
$(X)tcc.o : tcctools.c
|
||||
$(X)arm-gen.o : arm-asm.c
|
||||
|
||||
# Host Tiny C Compiler
|
||||
tcc$(EXESUF): tcc.o $(LIBTCC)
|
||||
@ -255,10 +249,10 @@ tcc-doc.info: tcc-doc.texi
|
||||
# install
|
||||
|
||||
INSTALL = install -m644
|
||||
INSTALLBIN = install -m755 $(STRIP_$(STRIP_BINARIES))
|
||||
INSTALLBIN = install -m755 $(STRIP_$(CONFIG_strip))
|
||||
STRIP_yes = -s
|
||||
install-strip: install
|
||||
install-strip: STRIP_BINARIES = yes
|
||||
install-strip: CONFIG_strip = yes
|
||||
|
||||
TRY-INSTALL = $(if $(wildcard $1),mkdir -p $2 && $(INSTALL) $1 $2)
|
||||
LIBTCC1_W = $(wildcard $(filter %-win32.a %-wince.a,$(LIBTCC1_CROSS)))
|
||||
|
@ -17,6 +17,8 @@ ST_FUNC void gen_le32(int c);
|
||||
#else
|
||||
/*************************************************************/
|
||||
|
||||
#include "tcc.h"
|
||||
|
||||
static void asm_error(void)
|
||||
{
|
||||
tcc_error("ARM asm not implemented.");
|
||||
|
@ -34,8 +34,8 @@
|
||||
#define NB_REGS 9
|
||||
#endif
|
||||
|
||||
#ifndef TCC_ARM_VERSION
|
||||
# define TCC_ARM_VERSION 5
|
||||
#ifndef TCC_CPU_VERSION
|
||||
# define TCC_CPU_VERSION 5
|
||||
#endif
|
||||
|
||||
/* a register can belong to several classes. The classes must be
|
||||
@ -2149,7 +2149,3 @@ ST_FUNC void gen_vla_alloc(CType *type, int align) {
|
||||
/*************************************************************/
|
||||
#endif
|
||||
/*************************************************************/
|
||||
|
||||
// #ifndef TCC_IS_NATIVE
|
||||
#include "arm-asm.c"
|
||||
// #endif
|
||||
|
@ -190,7 +190,7 @@ void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, addr_t
|
||||
if (x & 0x800000)
|
||||
x -= 0x1000000;
|
||||
x <<= 2;
|
||||
blx_avail = (TCC_ARM_VERSION >= 5);
|
||||
blx_avail = (TCC_CPU_VERSION >= 5);
|
||||
is_thumb = val & 1;
|
||||
is_bl = (*(unsigned *) ptr) >> 24 == 0xeb;
|
||||
is_call = (type == R_ARM_CALL || (type == R_ARM_PC24 && is_bl));
|
||||
|
@ -583,7 +583,7 @@ static void arm64_gen_bl_or_b(int b)
|
||||
{
|
||||
if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
|
||||
assert(!b && (vtop->r & VT_SYM));
|
||||
greloc(cur_text_section, vtop->sym, ind, R_AARCH64_CALL26);
|
||||
greloca(cur_text_section, vtop->sym, ind, R_AARCH64_CALL26, 0);
|
||||
o(0x94000000); // bl .
|
||||
}
|
||||
else
|
||||
|
190
configure
vendored
190
configure
vendored
@ -17,9 +17,6 @@ TMPN="./conftest-$$"
|
||||
TMPH=$TMPN.h
|
||||
|
||||
# default parameters
|
||||
build_cross="no"
|
||||
use_libgcc="no"
|
||||
disable_static=""
|
||||
prefix=""
|
||||
execprefix=""
|
||||
bindir=""
|
||||
@ -33,11 +30,8 @@ cross_prefix=""
|
||||
cc="gcc"
|
||||
ar="ar"
|
||||
strip="strip"
|
||||
noldl="no"
|
||||
gprof="no"
|
||||
bigendian="no"
|
||||
mingw32="no"
|
||||
osx="no"
|
||||
LIBSUF=".a"
|
||||
EXESUF=""
|
||||
DLLSUF=".so"
|
||||
@ -48,19 +42,25 @@ tcc_elfinterp=""
|
||||
triplet=
|
||||
tcc_lddir=
|
||||
confvars=
|
||||
suggest="yes"
|
||||
cpu=
|
||||
cpuver=
|
||||
gcc_major=0
|
||||
gcc_minor=0
|
||||
|
||||
# OS specific
|
||||
targetos=`uname`
|
||||
case $targetos in
|
||||
Darwin)
|
||||
osx=yes
|
||||
confvars="$confvars OSX"
|
||||
DLLSUF=".dylib"
|
||||
;;
|
||||
MINGW*|MSYS*|CYGWIN*)
|
||||
confvars="$confvars WIN32"
|
||||
mingw32=yes
|
||||
;;
|
||||
DragonFly|OpenBSD|FreeBSD|NetBSD)
|
||||
noldl=yes
|
||||
confvars="$confvars ldl=no"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
@ -126,23 +126,23 @@ for opt do
|
||||
;;
|
||||
--cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
|
||||
;;
|
||||
--enable-gprof) gprof="yes"
|
||||
--enable-mingw32) confvars="$confvars WIN32"; mingw32="yes"
|
||||
;;
|
||||
--enable-mingw32) mingw32="yes"
|
||||
--enable-cross) confvars="$confvars cross"
|
||||
;;
|
||||
--enable-cross) build_cross="yes"
|
||||
--disable-static) confvars="$confvars static=no"
|
||||
;;
|
||||
--disable-static) disable_static="yes"
|
||||
--enable-static) confvars="$confvars static"
|
||||
;;
|
||||
--enable-static) disable_static="no"
|
||||
--disable-rpath) confvars="$confvars rpath=no"
|
||||
;;
|
||||
--disable-rpath) disable_rpath="yes"
|
||||
--strip-binaries) confvars="$confvars strip"
|
||||
;;
|
||||
--strip-binaries) strip_binaries="yes"
|
||||
--with-libgcc) confvars="$confvars libgcc"
|
||||
;;
|
||||
--with-libgcc) use_libgcc="yes"
|
||||
--with-selinux) confvars="$confvars selinux"
|
||||
;;
|
||||
--with-selinux) have_selinux="yes"
|
||||
--config-*) confvars="$confvars ${opt#--config-}"; suggest="no"
|
||||
;;
|
||||
--help|-h) show_help="yes"
|
||||
;;
|
||||
@ -181,16 +181,16 @@ case "$cpu" in
|
||||
cpuver=7
|
||||
;;
|
||||
esac
|
||||
cpu="armv4l"
|
||||
cpu="arm"
|
||||
;;
|
||||
aarch64)
|
||||
cpu="aarch64"
|
||||
cpu="arm64"
|
||||
;;
|
||||
alpha)
|
||||
cpu="alpha"
|
||||
;;
|
||||
"Power Macintosh"|ppc|ppc64)
|
||||
cpu="powerpc"
|
||||
cpu="ppc"
|
||||
;;
|
||||
mips)
|
||||
cpu="mips"
|
||||
@ -199,7 +199,8 @@ case "$cpu" in
|
||||
cpu="s390"
|
||||
;;
|
||||
*)
|
||||
cpu="unknown"
|
||||
echo "Unsupported CPU"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
@ -262,9 +263,6 @@ else
|
||||
if test x"$tccdir" = x""; then
|
||||
tccdir="${libdir}/tcc"
|
||||
fi
|
||||
if test "$osx" = "yes" ; then
|
||||
DLLSUF=".dylib"
|
||||
fi
|
||||
fi # mingw32
|
||||
|
||||
if test x"$includedir" = x""; then
|
||||
@ -312,6 +310,7 @@ Advanced options (experts only):
|
||||
--crtprefix=... specify locations of crt?.o, colon separated
|
||||
--elfinterp=... specify elf interpreter
|
||||
--triplet=... specify system library/include directory triplet
|
||||
--config-uClibc,-musl... enable specific configuration for some systems
|
||||
EOF
|
||||
#echo "NOTE: The object files are build at the place where configure is launched"
|
||||
exit 1
|
||||
@ -341,14 +340,14 @@ if test -z "$cross_prefix" ; then
|
||||
fi
|
||||
|
||||
if test -z "$triplet"; then
|
||||
if test $cpu = "x86_64" -o $cpu = "aarch64" ; then
|
||||
if test $cpu = "x86_64" -o $cpu = "arm64" ; then
|
||||
if test -f "/usr/lib64/crti.o" ; then
|
||||
tcc_lddir="lib64"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$cpu" = "armv4l" ; then
|
||||
if test "$cpu" = "arm" ; then
|
||||
if test "${triplet%eabihf}" != "$triplet" ; then
|
||||
confvars="$confvars arm_eabihf"
|
||||
elif test "${triplet%eabi}" != "$triplet" ; then
|
||||
@ -359,46 +358,48 @@ if test -z "$cross_prefix" ; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# Enable uClibc or musl native support only if GNU ld is not already present
|
||||
if test -f "/lib/ld-linux.so.2"; then
|
||||
:
|
||||
elif test -f "/lib64/ld-linux-x86-64.so.2"; then
|
||||
:
|
||||
elif test -f "/lib64/ld-linux-aarch64.so.1"; then
|
||||
:
|
||||
elif test -f "/lib/ld-uClibc.so.0" ; then
|
||||
confvars="$confvars uClibc"
|
||||
elif test -f "/lib/ld-musl-$cpu.so.1"; then
|
||||
confvars="$confvars musl"
|
||||
if test "$suggest" = "yes"; then
|
||||
if test -f "/lib/ld-uClibc.so.0" ; then
|
||||
echo "Perhaps you want ./configure --config-uClibc"
|
||||
fi
|
||||
if test -f "/lib/ld-musl-$cpu.so.1"; then
|
||||
echo "Perhaps you want ./configure --config-musl"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# if cross compiling, cannot launch a program, so make a static guess
|
||||
case $cpu in
|
||||
powerpc|mips|s390) bigendian=yes;;
|
||||
ppc|mips|s390) bigendian=yes;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# a final configuration tuning
|
||||
$cc -v --help > cc_help.txt 2>&1
|
||||
W_OPTIONS="declaration-after-statement undef strict-prototypes write-strings"
|
||||
for i in $W_OPTIONS; do
|
||||
O_PRESENT="$(grep -- -W$i cc_help.txt)"
|
||||
if test -n "$O_PRESENT"; then CFLAGS="$CFLAGS -W$i"; fi
|
||||
done
|
||||
W_OPTIONS="pointer-sign sign-compare unused-result"
|
||||
for i in $W_OPTIONS; do
|
||||
O_PRESENT="$(grep -- -W$i cc_help.txt)"
|
||||
if test -n "$O_PRESENT"; then CFLAGS="$CFLAGS -Wno-$i"; fi
|
||||
done
|
||||
F_OPTIONS="strict-aliasing"
|
||||
for i in $F_OPTIONS; do
|
||||
O_PRESENT="$(grep -- -f$i cc_help.txt)"
|
||||
if test -n "$O_PRESENT"; then CFLAGS="$CFLAGS -fno-$i"; fi
|
||||
done
|
||||
rm -f cc_help.txt
|
||||
if test "$bigendian" = "yes" ; then
|
||||
confvars="$confvars BIGENDIAN"
|
||||
fi
|
||||
|
||||
fcho() { if test -n "$2"; then echo "$1$2"; else echo "$1-"; fi }
|
||||
# a final configuration tuning
|
||||
if ! echo "$cc" | grep -q "tcc"; then
|
||||
OPT1="-Wdeclaration-after-statement -fno-strict-aliasing"
|
||||
# we want -Wno- but gcc does not always reject unknown -Wno- options
|
||||
OPT2="-Wpointer-sign -Wsign-compare -Wunused-result"
|
||||
if echo "$cc" | grep -q "clang"; then
|
||||
OPT1="$OPT1 -fheinous-gnu-extensions"
|
||||
OPT2="$OPT2 -Wstring-plus-int"
|
||||
fi
|
||||
$cc $OPT1 $OPT2 -o a.out -c -xc - < /dev/null > cc_msg.txt 2>&1
|
||||
for o in $OPT1; do # enable these options
|
||||
if ! grep -q -- $o cc_msg.txt; then CFLAGS="$CFLAGS $o"; fi
|
||||
done
|
||||
for o in $OPT2; do # disable these options
|
||||
if ! grep -q -- $o cc_msg.txt; then CFLAGS="$CFLAGS -Wno-${o#-W*}"; fi
|
||||
done
|
||||
# cat cc_msg.txt
|
||||
# echo $CFLAGS
|
||||
rm -f cc_msg.txt a.out
|
||||
fi
|
||||
|
||||
fcho() { if test -n "$2"; then echo "$1$2"; fi }
|
||||
|
||||
echo "Binary directory $bindir"
|
||||
echo "TinyCC directory $tccdir"
|
||||
@ -412,12 +413,8 @@ echo "Source path $source_path"
|
||||
echo "C compiler $cc"
|
||||
echo "Target OS $targetos"
|
||||
echo "CPU $cpu"
|
||||
echo "Big Endian $bigendian"
|
||||
echo "Profiling $gprof"
|
||||
echo "Cross compilers $build_cross"
|
||||
echo "Use libgcc $use_libgcc"
|
||||
fcho "Triplet " "$triplet"
|
||||
|
||||
fcho "Config " "${confvars# }"
|
||||
echo "Creating config.mak and config.h"
|
||||
|
||||
cat >config.mak <<EOF
|
||||
@ -449,12 +446,19 @@ print_inc() {
|
||||
echo "#endif" >> $TMPH
|
||||
fi
|
||||
}
|
||||
|
||||
print_mak() {
|
||||
if test -n "$2"; then
|
||||
echo "NATIVE_DEFINES+=-D$1=\"\\\"$2\\\"\"" >> config.mak
|
||||
fi
|
||||
}
|
||||
|
||||
print_mak_int() {
|
||||
if test -n "$2"; then
|
||||
echo "NATIVE_DEFINES+=-D$1=$2" >> config.mak
|
||||
fi
|
||||
}
|
||||
|
||||
echo "/* Automatically generated by configure - do not modify */" > $TMPH
|
||||
|
||||
print_inc CONFIG_SYSROOT "$sysroot"
|
||||
@ -465,74 +469,26 @@ print_mak CONFIG_TCC_CRTPREFIX "$tcc_crtprefix"
|
||||
print_mak CONFIG_TCC_ELFINTERP "$tcc_elfinterp"
|
||||
print_mak CONFIG_LDDIR "$tcc_lddir"
|
||||
print_mak CONFIG_TRIPLET "$triplet"
|
||||
print_mak_int TCC_CPU_VERSION "$cpuver"
|
||||
|
||||
echo "#define GCC_MAJOR $gcc_major" >> $TMPH
|
||||
echo "#define GCC_MINOR $gcc_minor" >> $TMPH
|
||||
|
||||
if test "$cpu" = "x86" ; then
|
||||
echo "ARCH=i386" >> config.mak
|
||||
elif test "$cpu" = "x86_64" ; then
|
||||
echo "ARCH=x86_64" >> config.mak
|
||||
elif test "$cpu" = "armv4l" ; then
|
||||
echo "ARCH=arm" >> config.mak
|
||||
echo "#define TCC_ARM_VERSION $cpuver" >> $TMPH
|
||||
elif test "$cpu" = "aarch64" ; then
|
||||
echo "ARCH=arm64" >> config.mak
|
||||
elif test "$cpu" = "powerpc" ; then
|
||||
echo "ARCH=ppc" >> config.mak
|
||||
elif test "$cpu" = "mips" ; then
|
||||
echo "ARCH=mips" >> config.mak
|
||||
elif test "$cpu" = "s390" ; then
|
||||
echo "ARCH=s390" >> config.mak
|
||||
elif test "$cpu" = "alpha" ; then
|
||||
echo "ARCH=alpha" >> config.mak
|
||||
else
|
||||
echo "Unsupported CPU"
|
||||
exit 1
|
||||
echo "ARCH=$cpu" >> config.mak
|
||||
fi
|
||||
|
||||
echo "TARGETOS=$targetos" >> config.mak
|
||||
|
||||
for v in $confvars ; do
|
||||
echo "CONFIG_$v=yes" >> config.mak
|
||||
if test "${v%=*}" = "$v"; then
|
||||
echo "CONFIG_$v=yes" >> config.mak
|
||||
else
|
||||
echo "CONFIG_$v" >> config.mak
|
||||
fi
|
||||
done
|
||||
if test "$noldl" = "yes" ; then
|
||||
echo "CONFIG_NOLDL=yes" >> config.mak
|
||||
fi
|
||||
if test "$mingw32" = "yes" ; then
|
||||
echo "CONFIG_WIN32=yes" >> config.mak
|
||||
fi
|
||||
if test "$osx" = "yes" ; then
|
||||
echo "CONFIG_OSX=yes" >> config.mak
|
||||
fi
|
||||
if test "$bigendian" = "yes" ; then
|
||||
echo "WORDS_BIGENDIAN=yes" >> config.mak
|
||||
echo "#define WORDS_BIGENDIAN 1" >> $TMPH
|
||||
fi
|
||||
if test "$gprof" = "yes" ; then
|
||||
echo "TARGET_GPROF=yes" >> config.mak
|
||||
echo "#define HAVE_GPROF 1" >> $TMPH
|
||||
fi
|
||||
if test "$build_cross" = "yes" ; then
|
||||
echo "CONFIG_CROSS=yes" >> config.mak
|
||||
fi
|
||||
if test -n "$disable_static" ; then
|
||||
echo "DISABLE_STATIC=$disable_static" >> config.mak
|
||||
fi
|
||||
if test "$disable_rpath" = "yes" ; then
|
||||
echo "DISABLE_RPATH=yes" >> config.mak
|
||||
fi
|
||||
if test "$strip_binaries" = "yes" ; then
|
||||
echo "STRIP_BINARIES=yes" >> config.mak
|
||||
fi
|
||||
if test "$use_libgcc" = "yes" ; then
|
||||
echo "#define CONFIG_USE_LIBGCC" >> $TMPH
|
||||
echo "CONFIG_USE_LIBGCC=yes" >> config.mak
|
||||
fi
|
||||
if test "$have_selinux" = "yes" ; then
|
||||
echo "#define HAVE_SELINUX" >> $TMPH
|
||||
echo "HAVE_SELINUX=yes" >> config.mak
|
||||
fi
|
||||
|
||||
version=`head $source_path/VERSION`
|
||||
echo "VERSION = $version" >> config.mak
|
||||
|
@ -23,6 +23,7 @@
|
||||
/* number of available registers */
|
||||
#define NB_REGS 5
|
||||
#define NB_ASM_REGS 8
|
||||
#define CONFIG_TCC_ASM
|
||||
|
||||
/* a register can belong to several classes. The classes must be
|
||||
sorted from more general to more precise (see gv2() code which does
|
||||
@ -329,6 +330,7 @@ static void gadd_sp(int val)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined CONFIG_TCC_BCHECK || defined TCC_TARGET_PE
|
||||
static void gen_static_call(int v)
|
||||
{
|
||||
Sym *sym;
|
||||
@ -337,6 +339,7 @@ static void gen_static_call(int v)
|
||||
oad(0xe8, -4);
|
||||
greloc(cur_text_section, sym, ind-4, R_386_PC32);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* 'is_jmp' is '1' if it is a jump */
|
||||
static void gcall_or_jmp(int is_jmp)
|
||||
|
@ -17,7 +17,7 @@ XFLAGS-win = -B$(TOPSRC)/win32 -I$(TOPSRC)/include
|
||||
XFLAGS = $(XFLAGS$(XCFG))
|
||||
XCFG = $(or $(findstring -win,$T),-unx)
|
||||
|
||||
# using gcc ("make armlib-usegcc=no" to use tcc)
|
||||
# in order to use gcc, tyoe: make <target>lib-usegcc=yes
|
||||
armlib-usegcc ?= no
|
||||
|
||||
ifeq "$($(X)$(T)lib-usegcc)" "yes"
|
||||
|
15
libtcc.c
15
libtcc.c
@ -44,10 +44,12 @@ static int nb_states;
|
||||
#ifdef TCC_TARGET_I386
|
||||
#include "i386-gen.c"
|
||||
#include "i386-link.c"
|
||||
#include "i386-asm.c"
|
||||
#endif
|
||||
#ifdef TCC_TARGET_ARM
|
||||
#include "arm-gen.c"
|
||||
#include "arm-link.c"
|
||||
#include "arm-asm.c"
|
||||
#endif
|
||||
#ifdef TCC_TARGET_ARM64
|
||||
#include "arm64-gen.c"
|
||||
@ -60,12 +62,10 @@ static int nb_states;
|
||||
#ifdef TCC_TARGET_X86_64
|
||||
#include "x86_64-gen.c"
|
||||
#include "x86_64-link.c"
|
||||
#include "i386-asm.c"
|
||||
#endif
|
||||
#ifdef CONFIG_TCC_ASM
|
||||
#include "tccasm.c"
|
||||
#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
|
||||
#include "i386-asm.c"
|
||||
#endif
|
||||
#endif
|
||||
#ifdef TCC_TARGET_COFF
|
||||
#include "tcccoff.c"
|
||||
@ -702,7 +702,6 @@ LIBTCCAPI void tcc_undefine_symbol(TCCState *s1, const char *sym)
|
||||
{
|
||||
TokenSym *ts;
|
||||
Sym *s;
|
||||
(void) s1; /* not used */
|
||||
ts = tok_alloc(sym, strlen(sym));
|
||||
s = define_find(ts->tok);
|
||||
/* undefine symbol by putting an invalid name */
|
||||
@ -836,12 +835,12 @@ LIBTCCAPI TCCState *tcc_new(void)
|
||||
# endif
|
||||
|
||||
/* TinyCC & gcc defines */
|
||||
#if defined(TCC_TARGET_PE) && defined(TCC_TARGET_X86_64)
|
||||
#if defined(TCC_TARGET_PE) && PTR_SIZE == 8
|
||||
/* 64bit Windows. */
|
||||
tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned long long");
|
||||
tcc_define_symbol(s, "__PTRDIFF_TYPE__", "long long");
|
||||
tcc_define_symbol(s, "__LLP64__", NULL);
|
||||
#elif defined(TCC_TARGET_X86_64) || defined(TCC_TARGET_ARM64)
|
||||
#elif PTR_SIZE == 8
|
||||
/* Other 64bit systems. */
|
||||
tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned long");
|
||||
tcc_define_symbol(s, "__PTRDIFF_TYPE__", "long");
|
||||
@ -1192,7 +1191,6 @@ LIBTCCAPI int tcc_add_symbol(TCCState *s, const char *name, const void *val)
|
||||
So it is handled here as if it were in a DLL. */
|
||||
pe_putimport(s, 0, name, (uintptr_t)val);
|
||||
#else
|
||||
(void) s; /* not used */
|
||||
set_elf_sym(symtab_section, (uintptr_t)val, 0,
|
||||
ELFW(ST_INFO)(STB_GLOBAL, STT_NOTYPE), 0,
|
||||
SHN_ABS, name);
|
||||
@ -1367,7 +1365,7 @@ static int tcc_set_linker(TCCState *s, const char *option)
|
||||
} else if (link_option(option, "oformat=", &p)) {
|
||||
#if defined(TCC_TARGET_PE)
|
||||
if (strstart("pe-", &p)) {
|
||||
#elif defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
#elif PTR_SIZE == 8
|
||||
if (strstart("elf64-", &p)) {
|
||||
#else
|
||||
if (strstart("elf32-", &p)) {
|
||||
@ -1987,7 +1985,6 @@ LIBTCCAPI void tcc_set_options(TCCState *s, const char *r)
|
||||
|
||||
PUB_FUNC void tcc_print_stats(TCCState *s, unsigned total_time)
|
||||
{
|
||||
(void) s; /* not used */
|
||||
if (total_time < 1)
|
||||
total_time = 1;
|
||||
if (total_bytes < 1)
|
||||
|
59
tcc.h
59
tcc.h
@ -122,10 +122,10 @@
|
||||
|
||||
/* target selection */
|
||||
/* #define TCC_TARGET_I386 *//* i386 code generator */
|
||||
/* #define TCC_TARGET_X86_64 *//* x86-64 code generator */
|
||||
/* #define TCC_TARGET_ARM *//* ARMv4 code generator */
|
||||
/* #define TCC_TARGET_ARM64 *//* ARMv8 code generator */
|
||||
/* #define TCC_TARGET_C67 *//* TMS320C67xx code generator */
|
||||
/* #define TCC_TARGET_X86_64 *//* x86-64 code generator */
|
||||
|
||||
/* default target is I386 */
|
||||
#if !defined(TCC_TARGET_I386) && !defined(TCC_TARGET_ARM) && \
|
||||
@ -134,18 +134,6 @@
|
||||
#define TCC_TARGET_I386
|
||||
#endif
|
||||
|
||||
#if !defined(TCC_UCLIBC) && !defined(TCC_TARGET_ARM) && \
|
||||
!defined(TCC_TARGET_ARM64) && !defined(TCC_TARGET_C67) && \
|
||||
!defined(CONFIG_USE_LIBGCC) && !defined(TCC_MUSL)
|
||||
#define CONFIG_TCC_BCHECK /* enable bound checking code */
|
||||
#endif
|
||||
|
||||
/* define it to include assembler support */
|
||||
#if !defined(TCC_TARGET_ARM) && !defined(TCC_TARGET_ARM64) && \
|
||||
!defined(TCC_TARGET_C67)
|
||||
#define CONFIG_TCC_ASM
|
||||
#endif
|
||||
|
||||
/* object format selection */
|
||||
#if defined(TCC_TARGET_C67)
|
||||
#define TCC_TARGET_COFF
|
||||
@ -166,6 +154,10 @@
|
||||
|
||||
#if defined TCC_IS_NATIVE && !defined CONFIG_TCCBOOT
|
||||
# define CONFIG_TCC_BACKTRACE
|
||||
# if (defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64) \
|
||||
&& !defined TCC_UCLIBC && !defined TCC_MUSL
|
||||
# define CONFIG_TCC_BCHECK /* enable bound checking code */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* ------------ path configuration ------------ */
|
||||
@ -282,24 +274,6 @@
|
||||
#include "elf.h"
|
||||
#include "stab.h"
|
||||
|
||||
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
# define ELFCLASSW ELFCLASS64
|
||||
# define ElfW(type) Elf##64##_##type
|
||||
# define ELFW(type) ELF##64##_##type
|
||||
# define ElfW_Rel ElfW(Rela)
|
||||
# define SHT_RELX SHT_RELA
|
||||
# define REL_SECTION_FMT ".rela%s"
|
||||
#else
|
||||
# define ELFCLASSW ELFCLASS32
|
||||
# define ElfW(type) Elf##32##_##type
|
||||
# define ELFW(type) ELF##32##_##type
|
||||
# define ElfW_Rel ElfW(Rel)
|
||||
# define SHT_RELX SHT_REL
|
||||
# define REL_SECTION_FMT ".rel%s"
|
||||
#endif
|
||||
/* target address type */
|
||||
#define addr_t ElfW(Addr)
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
#ifndef PUB_FUNC /* functions used by tcc.c but not in libtcc.h */
|
||||
@ -335,6 +309,7 @@
|
||||
#ifdef TCC_TARGET_ARM
|
||||
# include "arm-gen.c"
|
||||
# include "arm-link.c"
|
||||
# include "arm-asm.c"
|
||||
#endif
|
||||
#ifdef TCC_TARGET_ARM64
|
||||
# include "arm64-gen.c"
|
||||
@ -349,6 +324,26 @@
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
#if PTR_SIZE == 8
|
||||
# define ELFCLASSW ELFCLASS64
|
||||
# define ElfW(type) Elf##64##_##type
|
||||
# define ELFW(type) ELF##64##_##type
|
||||
# define ElfW_Rel ElfW(Rela)
|
||||
# define SHT_RELX SHT_RELA
|
||||
# define REL_SECTION_FMT ".rela%s"
|
||||
#else
|
||||
# define ELFCLASSW ELFCLASS32
|
||||
# define ElfW(type) Elf##32##_##type
|
||||
# define ELFW(type) ELF##32##_##type
|
||||
# define ElfW_Rel ElfW(Rel)
|
||||
# define SHT_RELX SHT_REL
|
||||
# define REL_SECTION_FMT ".rel%s"
|
||||
#endif
|
||||
/* target address type */
|
||||
#define addr_t ElfW(Addr)
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
#define INCLUDE_STACK_SIZE 32
|
||||
#define IFDEF_STACK_SIZE 64
|
||||
#define VSTACK_SIZE 256
|
||||
@ -1390,7 +1385,9 @@ ST_FUNC Section *new_symtab(TCCState *s1, const char *symtab_name, int sh_type,
|
||||
|
||||
ST_FUNC void put_extern_sym2(Sym *sym, Section *section, addr_t value, unsigned long size, int can_add_underscore);
|
||||
ST_FUNC void put_extern_sym(Sym *sym, Section *section, addr_t value, unsigned long size);
|
||||
#if PTR_SIZE == 4
|
||||
ST_FUNC void greloc(Section *s, Sym *sym, unsigned long offset, int type);
|
||||
#endif
|
||||
ST_FUNC void greloca(Section *s, Sym *sym, unsigned long offset, int type, addr_t addend);
|
||||
|
||||
ST_FUNC int put_elf_str(Section *s, const char *sym);
|
||||
|
2
tccasm.c
2
tccasm.c
@ -26,7 +26,6 @@ ST_FUNC int asm_get_local_label_name(TCCState *s1, unsigned int n)
|
||||
char buf[64];
|
||||
TokenSym *ts;
|
||||
|
||||
(void) s1; /* not used */
|
||||
snprintf(buf, sizeof(buf), "L..%u", n);
|
||||
ts = tok_alloc(buf, strlen(buf));
|
||||
return ts->tok;
|
||||
@ -435,7 +434,6 @@ static void asm_free_labels(TCCState *st)
|
||||
|
||||
static void use_section1(TCCState *s1, Section *sec)
|
||||
{
|
||||
(void) s1; /* not used */
|
||||
cur_text_section->data_offset = ind;
|
||||
cur_text_section = sec;
|
||||
ind = cur_text_section->data_offset;
|
||||
|
22
tccelf.c
22
tccelf.c
@ -1127,8 +1127,6 @@ ST_FUNC void tcc_add_bcheck(TCCState *s1)
|
||||
init_section->data_offset - 4, R_386_PC32, sym_index);
|
||||
/* R_386_PC32 = R_X86_64_PC32 = 2 */
|
||||
}
|
||||
#else
|
||||
(void) s1; /* not used */
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1739,7 +1737,7 @@ static void fill_dynamic(TCCState *s1, struct dyn_inf *dyninf)
|
||||
put_dt(dynamic, DT_SYMTAB, s1->dynsym->sh_addr);
|
||||
put_dt(dynamic, DT_STRSZ, dyninf->dynstr->data_offset);
|
||||
put_dt(dynamic, DT_SYMENT, sizeof(ElfW(Sym)));
|
||||
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 8
|
||||
put_dt(dynamic, DT_RELA, dyninf->rel_addr);
|
||||
put_dt(dynamic, DT_RELASZ, dyninf->rel_size);
|
||||
put_dt(dynamic, DT_RELAENT, sizeof(ElfW_Rel));
|
||||
@ -2760,7 +2758,7 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level)
|
||||
#define LD_TOK_EOF (-1)
|
||||
|
||||
/* return next ld script token */
|
||||
static int ld_next(char *name, int name_size)
|
||||
static int ld_next(TCCState *s1, char *name, int name_size)
|
||||
{
|
||||
int c;
|
||||
char *q;
|
||||
@ -2905,10 +2903,10 @@ static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed)
|
||||
group = !strcmp(cmd, "GROUP");
|
||||
if (!as_needed)
|
||||
new_undef_syms();
|
||||
t = ld_next(filename, sizeof(filename));
|
||||
t = ld_next(s1, filename, sizeof(filename));
|
||||
if (t != '(')
|
||||
expect("(");
|
||||
t = ld_next(filename, sizeof(filename));
|
||||
t = ld_next(s1, filename, sizeof(filename));
|
||||
for(;;) {
|
||||
libname[0] = '\0';
|
||||
if (t == LD_TOK_EOF) {
|
||||
@ -2918,7 +2916,7 @@ static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed)
|
||||
} else if (t == ')') {
|
||||
break;
|
||||
} else if (t == '-') {
|
||||
t = ld_next(filename, sizeof(filename));
|
||||
t = ld_next(s1, filename, sizeof(filename));
|
||||
if ((t != LD_TOK_NAME) || (filename[0] != 'l')) {
|
||||
tcc_error_noabort("library name expected");
|
||||
ret = -1;
|
||||
@ -2953,9 +2951,9 @@ static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed)
|
||||
}
|
||||
}
|
||||
}
|
||||
t = ld_next(filename, sizeof(filename));
|
||||
t = ld_next(s1, filename, sizeof(filename));
|
||||
if (t == ',') {
|
||||
t = ld_next(filename, sizeof(filename));
|
||||
t = ld_next(s1, filename, sizeof(filename));
|
||||
}
|
||||
}
|
||||
if (group && !as_needed) {
|
||||
@ -2981,7 +2979,7 @@ ST_FUNC int tcc_load_ldscript(TCCState *s1)
|
||||
|
||||
ch = handle_eob();
|
||||
for(;;) {
|
||||
t = ld_next(cmd, sizeof(cmd));
|
||||
t = ld_next(s1, cmd, sizeof(cmd));
|
||||
if (t == LD_TOK_EOF)
|
||||
return 0;
|
||||
else if (t != LD_TOK_NAME)
|
||||
@ -2994,11 +2992,11 @@ ST_FUNC int tcc_load_ldscript(TCCState *s1)
|
||||
} else if (!strcmp(cmd, "OUTPUT_FORMAT") ||
|
||||
!strcmp(cmd, "TARGET")) {
|
||||
/* ignore some commands */
|
||||
t = ld_next(cmd, sizeof(cmd));
|
||||
t = ld_next(s1, cmd, sizeof(cmd));
|
||||
if (t != '(')
|
||||
expect("(");
|
||||
for(;;) {
|
||||
t = ld_next(filename, sizeof(filename));
|
||||
t = ld_next(s1, filename, sizeof(filename));
|
||||
if (t == LD_TOK_EOF) {
|
||||
tcc_error_noabort("unexpected end of file");
|
||||
return -1;
|
||||
|
60
tccgen.c
60
tccgen.c
@ -404,10 +404,12 @@ ST_FUNC void greloca(Section *s, Sym *sym, unsigned long offset, int type,
|
||||
put_elf_reloca(symtab_section, s, offset, type, c, addend);
|
||||
}
|
||||
|
||||
#if PTR_SIZE == 4
|
||||
ST_FUNC void greloc(Section *s, Sym *sym, unsigned long offset, int type)
|
||||
{
|
||||
greloca(s, sym, offset, type, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* symbol allocator */
|
||||
@ -897,7 +899,7 @@ ST_FUNC void save_reg_upstack(int r, int n)
|
||||
type = &p->type;
|
||||
if ((p->r & VT_LVAL) ||
|
||||
(!is_float(type->t) && (type->t & VT_BTYPE) != VT_LLONG))
|
||||
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 8
|
||||
type = &char_pointer_type;
|
||||
#else
|
||||
type = &int_type;
|
||||
@ -914,7 +916,7 @@ ST_FUNC void save_reg_upstack(int r, int n)
|
||||
o(0xd8dd); /* fstp %st(0) */
|
||||
}
|
||||
#endif
|
||||
#if !defined(TCC_TARGET_ARM64) && !defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 4
|
||||
/* special long long case */
|
||||
if ((type->t & VT_BTYPE) == VT_LLONG) {
|
||||
sv.c.i += 4;
|
||||
@ -1129,7 +1131,7 @@ ST_FUNC int gv(int rc)
|
||||
if (r >= VT_CONST
|
||||
|| (vtop->r & VT_LVAL)
|
||||
|| !(reg_classes[r] & rc)
|
||||
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 8
|
||||
|| ((vtop->type.t & VT_BTYPE) == VT_QLONG && !(reg_classes[vtop->r2] & rc2))
|
||||
|| ((vtop->type.t & VT_BTYPE) == VT_QFLOAT && !(reg_classes[vtop->r2] & rc2))
|
||||
#else
|
||||
@ -1138,7 +1140,7 @@ ST_FUNC int gv(int rc)
|
||||
)
|
||||
{
|
||||
r = get_reg(rc);
|
||||
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 8
|
||||
if (((vtop->type.t & VT_BTYPE) == VT_QLONG) || ((vtop->type.t & VT_BTYPE) == VT_QFLOAT)) {
|
||||
int addr_type = VT_LLONG, load_size = 8, load_type = ((vtop->type.t & VT_BTYPE) == VT_QLONG) ? VT_LLONG : VT_DOUBLE;
|
||||
#else
|
||||
@ -1150,7 +1152,7 @@ ST_FUNC int gv(int rc)
|
||||
original_type = vtop->type.t;
|
||||
/* two register type load : expand to two words
|
||||
temporarily */
|
||||
#if !defined(TCC_TARGET_ARM64) && !defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 4
|
||||
if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
|
||||
/* load constant */
|
||||
ll = vtop->c.i;
|
||||
@ -1286,7 +1288,7 @@ static int reg_fret(int t)
|
||||
return REG_FRET;
|
||||
}
|
||||
|
||||
#if !defined(TCC_TARGET_ARM64) && !defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 4
|
||||
/* expand 64bit on stack in two ints */
|
||||
static void lexpand(void)
|
||||
{
|
||||
@ -1337,7 +1339,7 @@ ST_FUNC void lexpand_nr(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(TCC_TARGET_X86_64) && !defined(TCC_TARGET_ARM64)
|
||||
#if PTR_SIZE == 4
|
||||
/* build a long long from two ints */
|
||||
static void lbuild(int t)
|
||||
{
|
||||
@ -1356,7 +1358,7 @@ static void gv_dup(void)
|
||||
SValue sv;
|
||||
|
||||
t = vtop->type.t;
|
||||
#if !defined(TCC_TARGET_X86_64) && !defined(TCC_TARGET_ARM64)
|
||||
#if PTR_SIZE == 4
|
||||
if ((t & VT_BTYPE) == VT_LLONG) {
|
||||
lexpand();
|
||||
gv_dup();
|
||||
@ -1418,7 +1420,7 @@ ST_FUNC int gvtst(int inv, int t)
|
||||
return gtst(inv, t);
|
||||
}
|
||||
|
||||
#if !defined(TCC_TARGET_ARM64) && !defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 4
|
||||
/* generate CPU independent (unsigned) long long operations */
|
||||
static void gen_opl(int op)
|
||||
{
|
||||
@ -1977,7 +1979,7 @@ redo:
|
||||
if (op >= TOK_ULT && op <= TOK_LOR) {
|
||||
check_comparison_pointer_types(vtop - 1, vtop, op);
|
||||
/* pointers are handled are unsigned */
|
||||
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 8
|
||||
t = VT_LLONG | VT_UNSIGNED;
|
||||
#else
|
||||
t = VT_INT | VT_UNSIGNED;
|
||||
@ -1998,7 +2000,7 @@ redo:
|
||||
vrott(3);
|
||||
gen_opic(op);
|
||||
/* set to integer type */
|
||||
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 8
|
||||
vtop->type.t = VT_LLONG;
|
||||
#else
|
||||
vtop->type.t = VT_INT;
|
||||
@ -2027,7 +2029,7 @@ redo:
|
||||
u = pointed_size(&vtop[-1].type);
|
||||
if (u < 0)
|
||||
tcc_error("unknown array element size");
|
||||
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 8
|
||||
vpushll(u);
|
||||
#else
|
||||
/* XXX: cast to int ? (long long case) */
|
||||
@ -2298,7 +2300,7 @@ static void gen_cast(CType *type)
|
||||
;
|
||||
else if (sbt & VT_UNSIGNED)
|
||||
vtop->c.i = (uint32_t)vtop->c.i;
|
||||
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 8
|
||||
else if (sbt == VT_PTR)
|
||||
;
|
||||
#endif
|
||||
@ -2310,7 +2312,7 @@ static void gen_cast(CType *type)
|
||||
;
|
||||
else if (dbt == VT_BOOL)
|
||||
vtop->c.i = (vtop->c.i != 0);
|
||||
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 8
|
||||
else if (dbt == VT_PTR)
|
||||
;
|
||||
#endif
|
||||
@ -2352,7 +2354,7 @@ static void gen_cast(CType *type)
|
||||
gen_cast(type);
|
||||
}
|
||||
}
|
||||
#if !defined(TCC_TARGET_ARM64) && !defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 4
|
||||
} else if ((dbt & VT_BTYPE) == VT_LLONG) {
|
||||
if ((sbt & VT_BTYPE) != VT_LLONG) {
|
||||
/* scalar to long long */
|
||||
@ -2410,7 +2412,7 @@ static void gen_cast(CType *type)
|
||||
tcc_warning("nonportable conversion from pointer to char/short");
|
||||
}
|
||||
force_charshort_cast(dbt);
|
||||
#if !defined(TCC_TARGET_ARM64) && !defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 4
|
||||
} else if ((dbt & VT_BTYPE) == VT_INT) {
|
||||
/* scalar to int */
|
||||
if ((sbt & VT_BTYPE) == VT_LLONG) {
|
||||
@ -2986,7 +2988,7 @@ ST_FUNC void vstore(void)
|
||||
if ((vtop[-1].r & VT_VALMASK) == VT_LLOCAL) {
|
||||
SValue sv;
|
||||
t = get_reg(RC_INT);
|
||||
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 8
|
||||
sv.type.t = VT_PTR;
|
||||
#else
|
||||
sv.type.t = VT_INT;
|
||||
@ -2997,7 +2999,7 @@ ST_FUNC void vstore(void)
|
||||
vtop[-1].r = t | VT_LVAL;
|
||||
}
|
||||
/* two word case handling : store second register at word + 4 (or +8 for x86-64) */
|
||||
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 8
|
||||
if (((ft & VT_BTYPE) == VT_QLONG) || ((ft & VT_BTYPE) == VT_QFLOAT)) {
|
||||
int addr_type = VT_LLONG, load_size = 8, load_type = ((vtop->type.t & VT_BTYPE) == VT_QLONG) ? VT_LLONG : VT_DOUBLE;
|
||||
#else
|
||||
@ -3535,7 +3537,7 @@ static void struct_decl(CType *type, AttributeDef *ad, int u)
|
||||
next();
|
||||
if (tok == '=') {
|
||||
next();
|
||||
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 8
|
||||
c = expr_const64();
|
||||
#else
|
||||
/* We really want to support long long enums
|
||||
@ -3913,11 +3915,10 @@ the_end:
|
||||
|
||||
/* long is never used as type */
|
||||
if ((t & VT_BTYPE) == VT_LONG)
|
||||
#if (!defined TCC_TARGET_X86_64 && !defined TCC_TARGET_ARM64) || \
|
||||
defined TCC_TARGET_PE
|
||||
t = (t & ~VT_BTYPE) | VT_INT;
|
||||
#else
|
||||
#if PTR_SIZE == 8 && !defined TCC_TARGET_PE
|
||||
t = (t & ~VT_BTYPE) | VT_LLONG;
|
||||
#else
|
||||
t = (t & ~VT_BTYPE) | VT_INT;
|
||||
#endif
|
||||
type->t = t;
|
||||
return type_found;
|
||||
@ -6140,7 +6141,7 @@ static void init_putv(CType *type, Section *sec, unsigned long c)
|
||||
c + rel->r_offset - esym->st_value,
|
||||
ELFW(R_TYPE)(rel->r_info),
|
||||
ELFW(R_SYM)(rel->r_info),
|
||||
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 8
|
||||
rel->r_addend
|
||||
#else
|
||||
0
|
||||
@ -6189,6 +6190,11 @@ static void init_putv(CType *type, Section *sec, unsigned long c)
|
||||
#if (defined __i386__ || defined __x86_64__) && (defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64)
|
||||
else if (sizeof (long double) >= 10)
|
||||
memcpy(memset(ptr, 0, LDOUBLE_SIZE), &vtop->c.ld, 10);
|
||||
#ifdef __TINYC__
|
||||
else if (sizeof (long double) == sizeof (double))
|
||||
__asm__("fldl %1\nfstpt %0\n" : "=m"
|
||||
(memset(ptr, 0, LDOUBLE_SIZE), ptr) : "m" (vtop->c.ld));
|
||||
#endif
|
||||
#endif
|
||||
else
|
||||
tcc_error("can't cross compile long double constants");
|
||||
@ -6203,7 +6209,7 @@ static void init_putv(CType *type, Section *sec, unsigned long c)
|
||||
case VT_PTR:
|
||||
{
|
||||
addr_t val = (vtop->c.i & bit_mask) << bit_pos;
|
||||
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 8
|
||||
if (vtop->r & VT_SYM)
|
||||
greloca(sec, vtop->sym, c, R_DATA_PTR, val);
|
||||
else
|
||||
@ -6218,7 +6224,7 @@ static void init_putv(CType *type, Section *sec, unsigned long c)
|
||||
default:
|
||||
{
|
||||
int val = (vtop->c.i & bit_mask) << bit_pos;
|
||||
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
|
||||
#if PTR_SIZE == 8
|
||||
if (vtop->r & VT_SYM)
|
||||
greloca(sec, vtop->sym, c, R_DATA_PTR, val);
|
||||
else
|
||||
@ -6613,7 +6619,7 @@ static void decl_initializer_alloc(CType *type, AttributeDef *ad, int r,
|
||||
if (tcc_state->do_bounds_check) {
|
||||
addr_t *bounds_ptr;
|
||||
|
||||
greloc(bounds_section, sym, bounds_section->data_offset, R_DATA_PTR);
|
||||
greloca(bounds_section, sym, bounds_section->data_offset, R_DATA_PTR, 0);
|
||||
/* then add global bound info */
|
||||
bounds_ptr = section_ptr_add(bounds_section, 2 * sizeof(addr_t));
|
||||
bounds_ptr[0] = 0; /* relocated */
|
||||
|
8
tccpe.c
8
tccpe.c
@ -381,7 +381,7 @@ struct pe_info {
|
||||
|
||||
static const char *pe_export_name(TCCState *s1, ElfW(Sym) *sym)
|
||||
{
|
||||
const char *name = symtab_section->link->data + sym->st_name;
|
||||
const char *name = (char*)symtab_section->link->data + sym->st_name;
|
||||
if (s1->leading_underscore && name[0] == '_' && !(sym->st_other & ST_PE_STDCALL))
|
||||
return name + 1;
|
||||
return name;
|
||||
@ -835,7 +835,7 @@ static void pe_build_imports(struct pe_info *pe)
|
||||
int sym_index = p->symbols[k]->sym_index;
|
||||
ElfW(Sym) *imp_sym = (ElfW(Sym) *)pe->s1->dynsymtab_section->data + sym_index;
|
||||
ElfW(Sym) *org_sym = (ElfW(Sym) *)symtab_section->data + iat_index;
|
||||
const char *name = pe->s1->dynsymtab_section->link->data + imp_sym->st_name;
|
||||
const char *name = (char*)pe->s1->dynsymtab_section->link->data + imp_sym->st_name;
|
||||
int ordinal;
|
||||
|
||||
org_sym->st_value = thk_ptr;
|
||||
@ -1237,7 +1237,7 @@ static int pe_check_symbols(struct pe_info *pe)
|
||||
sym = (ElfW(Sym) *)symtab_section->data + sym_index;
|
||||
if (sym->st_shndx == SHN_UNDEF) {
|
||||
|
||||
const char *name = symtab_section->link->data + sym->st_name;
|
||||
const char *name = (char*)symtab_section->link->data + sym->st_name;
|
||||
unsigned type = ELFW(ST_TYPE)(sym->st_info);
|
||||
int imp_sym = pe_find_import(pe->s1, sym);
|
||||
struct import_symbol *is;
|
||||
@ -1648,7 +1648,7 @@ static int pe_load_res(TCCState *s1, int fd)
|
||||
|
||||
if (hdr.filehdr.Machine != IMAGE_FILE_MACHINE
|
||||
|| hdr.filehdr.NumberOfSections != 1
|
||||
|| strcmp(hdr.sectionhdr.Name, ".rsrc") != 0)
|
||||
|| strcmp((char*)hdr.sectionhdr.Name, ".rsrc") != 0)
|
||||
goto quit;
|
||||
|
||||
rsrc_section = new_section(s1, ".rsrc", SHT_PROGBITS, SHF_ALLOC);
|
||||
|
1
tccpp.c
1
tccpp.c
@ -3557,7 +3557,6 @@ ST_FUNC void tccpp_delete(TCCState *s)
|
||||
{
|
||||
int i, n;
|
||||
|
||||
(void) s; /* not used */
|
||||
/* free -D and compiler defines */
|
||||
free_defines(NULL);
|
||||
|
||||
|
@ -104,7 +104,6 @@ ST_FUNC int tcc_tool_ar(TCCState *s1, int argc, char **argv)
|
||||
const char *ops_conflict = "habdioptxN"; // unsupported but destructive if ignored.
|
||||
int verbose = 0;
|
||||
|
||||
(void) s1; /* not used */
|
||||
i_lib = 0; i_obj = 0; // will hold the index of the lib and first obj
|
||||
for (i = 1; i < argc; i++) {
|
||||
const char *a = argv[i];
|
||||
@ -322,7 +321,6 @@ ST_FUNC int tcc_tool_impdef(TCCState *s1, int argc, char **argv)
|
||||
p = NULL;
|
||||
v = 0;
|
||||
|
||||
(void) s1; /* not used */
|
||||
for (i = 1; i < argc; ++i) {
|
||||
const char *a = argv[i];
|
||||
if ('-' == a[0]) {
|
||||
@ -435,7 +433,6 @@ the_end:
|
||||
|
||||
ST_FUNC void tcc_tool_cross(TCCState *s, char **argv, int option)
|
||||
{
|
||||
(void) s; (void) argv; /* not used */
|
||||
tcc_error("-m%d not implemented.", option);
|
||||
}
|
||||
|
||||
@ -489,7 +486,6 @@ ST_FUNC void tcc_tool_cross(TCCState *s, char **argv, int target)
|
||||
char *a0 = argv[0];
|
||||
int prefix = tcc_basename(a0) - a0;
|
||||
|
||||
(void) s; /* not used */
|
||||
snprintf(program, sizeof program,
|
||||
"%.*s%s"
|
||||
#ifdef TCC_TARGET_PE
|
||||
|
@ -46,7 +46,7 @@ endif
|
||||
ifeq (,$(filter i386 x86_64,$(ARCH)))
|
||||
TESTS := $(filter-out dlltest,$(TESTS))
|
||||
endif
|
||||
ifndef CONFIG_CROSS
|
||||
ifndef CONFIG_cross
|
||||
TESTS := $(filter-out cross-%,$(TESTS))
|
||||
endif
|
||||
|
||||
|
11
x86_64-gen.c
11
x86_64-gen.c
@ -25,6 +25,7 @@
|
||||
/* number of available registers */
|
||||
#define NB_REGS 25
|
||||
#define NB_ASM_REGS 16
|
||||
#define CONFIG_TCC_ASM
|
||||
|
||||
/* a register can belong to several classes. The classes must be
|
||||
sorted from more general to more precise (see gv2() code which does
|
||||
@ -264,17 +265,15 @@ ST_FUNC void gen_addrpc32(int r, Sym *sym, long c)
|
||||
/* output got address with relocation */
|
||||
static void gen_gotpcrel(int r, Sym *sym, int c)
|
||||
{
|
||||
#ifndef TCC_TARGET_PE
|
||||
greloca(cur_text_section, sym, ind, R_X86_64_GOTPCREL, -4);
|
||||
#else
|
||||
#ifdef TCC_TARGET_PE
|
||||
tcc_error("internal error: no GOT on PE: %s %x %x | %02x %02x %02x\n",
|
||||
get_tok_str(sym->v, NULL), c, r,
|
||||
cur_text_section->data[ind-3],
|
||||
cur_text_section->data[ind-2],
|
||||
cur_text_section->data[ind-1]
|
||||
);
|
||||
greloc(cur_text_section, sym, ind, R_X86_64_PC32);
|
||||
#endif
|
||||
greloca(cur_text_section, sym, ind, R_X86_64_GOTPCREL, -4);
|
||||
gen_le32(0);
|
||||
if (c) {
|
||||
/* we use add c, %xxx for displacement */
|
||||
@ -1661,14 +1660,14 @@ void gfunc_epilog(void)
|
||||
func_bound_offset, lbounds_section->data_offset);
|
||||
saved_ind = ind;
|
||||
ind = func_bound_ind;
|
||||
greloc(cur_text_section, sym_data, ind + 1, R_386_32);
|
||||
greloca(cur_text_section, sym_data, ind + 1, R_X86_64_64, 0);
|
||||
ind = ind + 5 + 3;
|
||||
gen_static_call(TOK___bound_local_new);
|
||||
ind = saved_ind;
|
||||
|
||||
/* generate bound check local freeing */
|
||||
o(0x5250); /* save returned value, if any */
|
||||
greloc(cur_text_section, sym_data, ind + 1, R_386_32);
|
||||
greloca(cur_text_section, sym_data, ind + 1, R_X86_64_64, 0);
|
||||
oad(0xb8, 0); /* mov xxx, %rax */
|
||||
o(0xc78948); /* mov %rax,%rdi # first arg in %rdi, this must be ptr */
|
||||
gen_static_call(TOK___bound_local_delete);
|
||||
|
Loading…
Reference in New Issue
Block a user