Put former NATIVE_DEFINES into config.h. Such tcc can be run and tested directly from source more easily, like for example: tcc -run tcc.c -B. -run test.c Also: - tccelf.c: cleanup - tccpp.c: avoid stupid clang warning - configure: reduce -Wno- switches - tcc.h: inline wait/post_sem() - tccpe.c: simplify import (assume STT_NOTYPE is function)
Unified · Split
| @@ -48,6 +48,9 @@ win32/include/stddef.h · 47 unmodified lines | |||
| 48 | win32/include/stdnoreturn.h | 48 | win32/include/stdnoreturn.h |
| 49 | win32/include/varargs.h | 49 | win32/include/varargs.h |
| 50 | win32/include/tcclib.h | 50 | win32/include/tcclib.h |
| 51 | win32/include/tccdefs.h | ||
| 52 | win32/include/stdatomic.h | ||
| 53 | win32/include/tgmath.h | ||
| 51 | 54 | ||
| 52 | tests/tcctest[1234] | 55 | tests/tcctest[1234] |
| 53 | tests/tcctest.gcc | 56 | tests/tcctest.gcc |
| @@ -20,18 +20,15 @@ LIBTCC = libtcc.a · 19 unmodified lines | |||
| 20 | LIBTCC1 = libtcc1.a | 20 | LIBTCC1 = libtcc1.a |
| 21 | LINK_LIBTCC = | 21 | LINK_LIBTCC = |
| 22 | LIBS = | 22 | LIBS = |
| 23 | CFLAGS += -I$(TOP) | ||
| 24 | CFLAGS += $(CPPFLAGS) | 23 | CFLAGS += $(CPPFLAGS) |
| 25 | VPATH = $(TOPSRC) | 24 | VPATH = $(TOPSRC) |
| 25 | -LTCC = $(TOP)/$(LIBTCC) | ||
| 26 | 26 | ||
| 27 | ifdef CONFIG_WIN32 | 27 | ifdef CONFIG_WIN32 |
| 28 | CFG = -win | 28 | CFG = -win |
| 29 | ifneq ($(CONFIG_static),yes) | 29 | ifneq ($(CONFIG_static),yes) |
| 30 | LIBTCC = libtcc$(DLLSUF) | 30 | LIBTCC = libtcc$(DLLSUF) |
| 31 | LIBTCCDEF = libtcc.def | 31 | LIBTCCDEF = libtcc.def |
| 32 | -LTCC = $(bindir)/libtcc.dll | ||
| 33 | else | ||
| 34 | -LTCC = -ltcc -L$(libdir) | ||
| 35 | endif | 32 | endif |
| 36 | ifneq ($(CONFIG_debug),yes) | 33 | ifneq ($(CONFIG_debug),yes) |
| 37 | LDFLAGS += -s | 34 | LDFLAGS += -s |
| @@ -76,7 +73,6 @@ else · 38 unmodified lines | |||
| 76 | endif | 73 | endif |
| 77 | export MACOSX_DEPLOYMENT_TARGET := 10.6 | 74 | export MACOSX_DEPLOYMENT_TARGET := 10.6 |
| 78 | endif | 75 | endif |
| 79 | -LTCC = -ltcc | ||
| 80 | endif | 76 | endif |
| 81 | 77 | ||
| 82 | # run local version of tcc with local libraries and includes | 78 | # run local version of tcc with local libraries and includes |
| @@ -89,42 +85,15 @@ TCC = $(TCC_LOCAL) $(TCCFLAGS) · 6 unmodified lines | |||
| 89 | # run tests with the installed tcc instead | 85 | # run tests with the installed tcc instead |
| 90 | ifdef TESTINSTALL | 86 | ifdef TESTINSTALL |
| 91 | TCC_LOCAL = $(bindir)/tcc | 87 | TCC_LOCAL = $(bindir)/tcc |
| 92 | TCCFLAGS-unx = -I.. | 88 | TCCFLAGS-unx = -I$(TOP) |
| 93 | TCCFLAGS-win = -I.. -B$(bindir) | 89 | TCCFLAGS-win = -B$(bindir) -I$(TOP) |
| 94 | LIBTCC = | 90 | -LTCC = $(libdir)/$(LIBTCC) $(LINK_LIBTCC) |
| 95 | LIBS += $(-LTCC) | ||
| 96 | endif | 91 | endif |
| 97 | 92 | ||
| 98 | CFLAGS_P = $(CFLAGS) -pg -static -DCONFIG_TCC_STATIC -DTCC_PROFILE | 93 | CFLAGS_P = $(CFLAGS) -pg -static -DCONFIG_TCC_STATIC -DTCC_PROFILE |
| 99 | LIBS_P = $(LIBS) | 94 | LIBS_P = $(LIBS) |
| 100 | LDFLAGS_P = $(LDFLAGS) | 95 | LDFLAGS_P = $(LDFLAGS) |
| 101 | 96 | ||
| 102 | CONFIG_$(ARCH) = yes | ||
| 103 | NATIVE_DEFINES_$(CONFIG_i386) += -DTCC_TARGET_I386 | ||
| 104 | NATIVE_DEFINES_$(CONFIG_x86_64) += -DTCC_TARGET_X86_64 | ||
| 105 | NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE | ||
| 106 | NATIVE_DEFINES_$(CONFIG_OSX) += -DTCC_TARGET_MACHO | ||
| 107 | NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC | ||
| 108 | NATIVE_DEFINES_$(CONFIG_musl) += -DTCC_MUSL | ||
| 109 | NATIVE_DEFINES_$(CONFIG_libgcc) += -DCONFIG_USE_LIBGCC | ||
| 110 | NATIVE_DEFINES_$(CONFIG_selinux) += -DHAVE_SELINUX | ||
| 111 | NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM | ||
| 112 | NATIVE_DEFINES_$(CONFIG_arm_eabihf) += -DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT | ||
| 113 | NATIVE_DEFINES_$(CONFIG_arm_eabi) += -DTCC_ARM_EABI | ||
| 114 | NATIVE_DEFINES_$(CONFIG_arm_vfp) += -DTCC_ARM_VFP | ||
| 115 | NATIVE_DEFINES_$(CONFIG_arm64) += -DTCC_TARGET_ARM64 | ||
| 116 | NATIVE_DEFINES_$(CONFIG_riscv64) += -DTCC_TARGET_RISCV64 | ||
| 117 | NATIVE_DEFINES_$(CONFIG_BSD) += -DTARGETOS_$(TARGETOS) | ||
| 118 | NATIVE_DEFINES_$(CONFIG_Android) += -DTARGETOS_ANDROID | ||
| 119 | NATIVE_DEFINES_$(CONFIG_pie) += -DCONFIG_TCC_PIE | ||
| 120 | NATIVE_DEFINES_$(CONFIG_pic) += -DCONFIG_TCC_PIC | ||
| 121 | NATIVE_DEFINES_no_$(CONFIG_new_macho) += -DCONFIG_NEW_MACHO=0 | ||
| 122 | NATIVE_DEFINES_$(CONFIG_codesign) += -DCONFIG_CODESIGN | ||
| 123 | NATIVE_DEFINES_$(CONFIG_new-dtags) += -DCONFIG_NEW_DTAGS | ||
| 124 | NATIVE_DEFINES_no_$(CONFIG_bcheck) += -DCONFIG_TCC_BCHECK=0 | ||
| 125 | NATIVE_DEFINES_no_$(CONFIG_backtrace) += -DCONFIG_TCC_BACKTRACE=0 | ||
| 126 | NATIVE_DEFINES += $(NATIVE_DEFINES_yes) $(NATIVE_DEFINES_no_no) | ||
| 127 | |||
| 128 | DEF-i386 = -DTCC_TARGET_I386 | 97 | DEF-i386 = -DTCC_TARGET_I386 |
| 129 | DEF-i386-win32 = -DTCC_TARGET_I386 -DTCC_TARGET_PE | 98 | DEF-i386-win32 = -DTCC_TARGET_I386 -DTCC_TARGET_PE |
| 130 | DEF-i386-OpenBSD = $(DEF-i386) -DTARGETOS_OpenBSD | 99 | DEF-i386-OpenBSD = $(DEF-i386) -DTARGETOS_OpenBSD |
| @@ -150,8 +119,6 @@ DEF-x86_64-FreeBSD = $(DEF-x86_64) -DTARGETOS_FreeBSD · 19 unmodified lines | |||
| 150 | DEF-x86_64-NetBSD = $(DEF-x86_64) -DTARGETOS_NetBSD | 119 | DEF-x86_64-NetBSD = $(DEF-x86_64) -DTARGETOS_NetBSD |
| 151 | DEF-x86_64-OpenBSD = $(DEF-x86_64) -DTARGETOS_OpenBSD | 120 | DEF-x86_64-OpenBSD = $(DEF-x86_64) -DTARGETOS_OpenBSD |
| 152 | 121 | ||
| 153 | DEF-$(NATIVE_TARGET) = $(NATIVE_DEFINES) | ||
| 154 | |||
| 155 | ifeq ($(INCLUDED),no) | 122 | ifeq ($(INCLUDED),no) |
| 156 | # -------------------------------------------------------------------------- | 123 | # -------------------------------------------------------------------------- |
| 157 | # running top Makefile | 124 | # running top Makefile |
| @@ -192,7 +159,7 @@ endif · 34 unmodified lines | |||
| 192 | T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown) | 159 | T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown) |
| 193 | X = $(if $(CROSS_TARGET),$(CROSS_TARGET)-) | 160 | X = $(if $(CROSS_TARGET),$(CROSS_TARGET)-) |
| 194 | 161 | ||
| 195 | DEFINES += $(DEF-$T) $(DEF-all) | 162 | DEFINES += $(DEF-$T) |
| 196 | DEFINES += $(if $(ROOT-$T),-DCONFIG_SYSROOT="\"$(ROOT-$T)\"") | 163 | DEFINES += $(if $(ROOT-$T),-DCONFIG_SYSROOT="\"$(ROOT-$T)\"") |
| 197 | DEFINES += $(if $(CRT-$T),-DCONFIG_TCC_CRTPREFIX="\"$(CRT-$T)\"") | 164 | DEFINES += $(if $(CRT-$T),-DCONFIG_TCC_CRTPREFIX="\"$(CRT-$T)\"") |
| 198 | DEFINES += $(if $(LIB-$T),-DCONFIG_TCC_LIBPATHS="\"$(LIB-$T)\"") | 165 | DEFINES += $(if $(LIB-$T),-DCONFIG_TCC_LIBPATHS="\"$(LIB-$T)\"") |
| @@ -202,10 +169,15 @@ DEFINES += $(DEF-$(or $(findstring win,$T),unx)) · 3 unmodified lines | |||
| 202 | 169 | ||
| 203 | ifneq ($(X),) | 170 | ifneq ($(X),) |
| 204 | $(if $(DEF-$T),,$(error error: unknown target: '$T')) | 171 | $(if $(DEF-$T),,$(error error: unknown target: '$T')) |
| 205 | DEF-all += -DCONFIG_TCC_CROSSPREFIX="\"$X\"" | 172 | DEF-$T += -DCONFIG_TCC_CROSS |
| 173 | DEF-$(NATIVE_TARGET) = | ||
| 174 | DEF-$T += -DCONFIG_TCC_CROSSPREFIX="\"$X\"" | ||
| 206 | ifneq ($(CONFIG_WIN32),yes) | 175 | ifneq ($(CONFIG_WIN32),yes) |
| 207 | DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\"" | 176 | DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\"" |
| 208 | endif | 177 | endif |
| 178 | else | ||
| 179 | # using values from config.h | ||
| 180 | DEF-$(NATIVE_TARGET) = | ||
| 209 | endif | 181 | endif |
| 210 | 182 | ||
| 211 | # include custom configuration (see make help) | 183 | # include custom configuration (see make help) |
| @@ -255,15 +227,16 @@ ifeq ($(ONE_SOURCE),yes) · 43 unmodified lines | |||
| 255 | LIBTCC_OBJ = $(X)libtcc.o | 227 | LIBTCC_OBJ = $(X)libtcc.o |
| 256 | LIBTCC_INC = $($T_FILES) | 228 | LIBTCC_INC = $($T_FILES) |
| 257 | TCC_FILES = $(X)tcc.o | 229 | TCC_FILES = $(X)tcc.o |
| 258 | tcc.o : DEFINES += -DONE_SOURCE=0 | 230 | $(X)tcc.o $(X)libtcc.o : $(TCCDEFS_H) |
| 259 | $(X)tcc.o $(X)libtcc.o : $(TCCDEFS_H) | ||
| 260 | else | 231 | else |
| 261 | LIBTCC_OBJ = $(patsubst %.c,$(X)%.o,$(LIBTCC_SRC)) | 232 | LIBTCC_OBJ = $(patsubst %.c,$(X)%.o,$(LIBTCC_SRC)) |
| 262 | LIBTCC_INC = $(filter %.h %-gen.c %-link.c,$($T_FILES)) | 233 | LIBTCC_INC = $(filter %.h %-gen.c %-link.c,$($T_FILES)) |
| 263 | TCC_FILES = $(X)tcc.o $(LIBTCC_OBJ) | 234 | TCC_FILES = $(X)tcc.o $(LIBTCC_OBJ) |
| 264 | $(TCC_FILES) : DEFINES += -DONE_SOURCE=0 | ||
| 265 | $(X)tccpp.o : $(TCCDEFS_H) | 235 | $(X)tccpp.o : $(TCCDEFS_H) |
| 236 | $(X)libtcc.o : DEFINES += -DONE_SOURCE=0 | ||
| 266 | endif | 237 | endif |
| 238 | tcc.o : DEFINES += -DONE_SOURCE=0 | ||
| 239 | DEFINES += -I$(TOP) | ||
| 267 | 240 | ||
| 268 | GITHASH:=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo no) | 241 | GITHASH:=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo no) |
| 269 | ifneq ($(GITHASH),no) | 242 | ifneq ($(GITHASH),no) |
| @@ -283,7 +256,7 @@ endif · 13 unmodified lines | |||
| 283 | 256 | ||
| 284 | # target specific object rule | 257 | # target specific object rule |
| 285 | $(X)%.o : %.c $(LIBTCC_INC) | 258 | $(X)%.o : %.c $(LIBTCC_INC) |
| 286 | $S$(CC) -o $@ -c $< $(DEFINES) $(CFLAGS) | 259 | $S$(CC) -o $@ -c $< $(addsuffix ,$(DEFINES) $(CFLAGS)) |
| 287 | 260 | ||
| 288 | # additional dependencies | 261 | # additional dependencies |
| 289 | $(X)tcc.o : tcctools.c | 262 | $(X)tcc.o : tcctools.c |
| @@ -291,7 +264,7 @@ $(X)tcc.o : DEFINES += $(DEF_GITHASH) · 1 unmodified line | |||
| 291 | 264 | ||
| 292 | # Host Tiny C Compiler | 265 | # Host Tiny C Compiler |
| 293 | tcc$(EXESUF): tcc.o $(LIBTCC) | 266 | tcc$(EXESUF): tcc.o $(LIBTCC) |
| 294 | $S$(CC) -o $@ $^ $(LIBS) $(LDFLAGS) $(LINK_LIBTCC) | 267 | $S$(CC) -o $@ $^ $(addsuffix ,$(LIBS) $(LDFLAGS) $(LINK_LIBTCC)) |
| 295 | 268 | ||
| 296 | # Cross Tiny C Compilers | 269 | # Cross Tiny C Compilers |
| 297 | # (the TCCDEFS_H dependency is only necessary for parallel makes, | 270 | # (the TCCDEFS_H dependency is only necessary for parallel makes, |
| @@ -318,8 +291,8 @@ libtcc.a: $(LIBTCC_OBJ) · 20 unmodified lines | |||
| 318 | libtcc.so: $(LIBTCC_OBJ) | 291 | libtcc.so: $(LIBTCC_OBJ) |
| 319 | $S$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LIBS) $(LDFLAGS) | 292 | $S$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LIBS) $(LDFLAGS) |
| 320 | 293 | ||
| 321 | libtcc.so: CFLAGS+=-fPIC | 294 | libtcc.so: override CFLAGS += -fPIC |
| 322 | libtcc.so: LDFLAGS+=-fPIC | 295 | libtcc.so: override LDFLAGS += -fPIC |
| 323 | 296 | ||
| 324 | # OSX dynamic libtcc library | 297 | # OSX dynamic libtcc library |
| 325 | libtcc.dylib: $(LIBTCC_OBJ) | 298 | libtcc.dylib: $(LIBTCC_OBJ) |
| @@ -529,13 +502,12 @@ help: · 203 unmodified lines | |||
| 529 | @echo "make test-install" | 502 | @echo "make test-install" |
| 530 | @echo " run tests with the installed tcc" | 503 | @echo " run tests with the installed tcc" |
| 531 | @echo "Other supported make targets:" | 504 | @echo "Other supported make targets:" |
| 532 | @echo " install install-strip doc clean tags ETAGS tar distclean help" | 505 | @echo " install install-strip uninstall doc [dist]clean tags ETAGS tar help" |
| 533 | @echo "Custom configuration:" | 506 | @echo "Custom configuration:" |
| 534 | @echo " The makefile includes a file 'config-extra.mak' if it is present." | 507 | @echo " The makefile includes a file 'config-extra.mak' if it is present." |
| 535 | @echo " This file may contain some custom configuration. For example:" | 508 | @echo " This file may contain some custom configuration. For example to" |
| 536 | @echo " NATIVE_DEFINES += -D..." | 509 | @echo " configure the search paths for a cross-compiler, assuming the" |
| 537 | @echo " Or for example to configure the search paths for a cross-compiler" | 510 | @echo " support files in /usr/i686-linux-gnu:" |
| 538 | @echo " assuming the support files in /usr/i686-linux-gnu:" | ||
| 539 | @echo " ROOT-i386 = /usr/i686-linux-gnu" | 511 | @echo " ROOT-i386 = /usr/i686-linux-gnu" |
| 540 | @echo " CRT-i386 = {R}/lib" | 512 | @echo " CRT-i386 = {R}/lib" |
| 541 | @echo " LIB-i386 = {B}:{R}/lib" | 513 | @echo " LIB-i386 = {B}:{R}/lib" |
| @@ -34,8 +34,8 @@ · 33 unmodified lines | |||
| 34 | #define NB_REGS 9 | 34 | #define NB_REGS 9 |
| 35 | #endif | 35 | #endif |
| 36 | 36 | ||
| 37 | #ifndef TCC_CPU_VERSION | 37 | #ifndef CONFIG_TCC_CPUVER |
| 38 | # define TCC_CPU_VERSION 5 | 38 | # define CONFIG_TCC_CPUVER 5 |
| 39 | #endif | 39 | #endif |
| 40 | 40 | ||
| 41 | /* a register can belong to several classes. The classes must be | 41 | /* a register can belong to several classes. The classes must be |
| @@ -202,7 +202,7 @@ ST_FUNC void relocate(TCCState *s1, ElfW_Rel *rel, int type, unsigned char *ptr, · 201 unmodified lines | |||
| 202 | if (x & 0x800000) | 202 | if (x & 0x800000) |
| 203 | x -= 0x1000000; | 203 | x -= 0x1000000; |
| 204 | x <<= 2; | 204 | x <<= 2; |
| 205 | blx_avail = (TCC_CPU_VERSION >= 5); | 205 | blx_avail = (CONFIG_TCC_CPUVER >= 5); |
| 206 | is_thumb = val & 1; | 206 | is_thumb = val & 1; |
| 207 | is_bl = (*(unsigned *) ptr) >> 24 == 0xeb; | 207 | is_bl = (*(unsigned *) ptr) >> 24 == 0xeb; |
| 208 | is_call = (type == R_ARM_CALL || (type == R_ARM_PC24 && is_bl)); | 208 | is_call = (type == R_ARM_CALL || (type == R_ARM_PC24 && is_bl)); |
| @@ -117,7 +117,7 @@ for opt do · 116 unmodified lines | |||
| 117 | ;; | 117 | ;; |
| 118 | --cpu=*) cpu=`echo $opt | cut -d '=' -f 2-` | 118 | --cpu=*) cpu=`echo $opt | cut -d '=' -f 2-` |
| 119 | ;; | 119 | ;; |
| 120 | --dwarf=*) dwarf=`echo $opt | cut -d '=' -f 2-` | 120 | --dwarf=*) confvars="$confvars dwarf=${opt#*=}" |
| 121 | ;; | 121 | ;; |
| 122 | --enable-cross) confvars="$confvars cross" | 122 | --enable-cross) confvars="$confvars cross" |
| 123 | ;; | 123 | ;; |
| @@ -193,9 +193,10 @@ Advanced options (experts only): · 69 unmodified lines | |||
| 193 | --config-backtrace=no disable stack backtraces (with -run or -bt) | 193 | --config-backtrace=no disable stack backtraces (with -run or -bt) |
| 194 | --config-bcheck=no disable bounds checker (-b) | 194 | --config-bcheck=no disable bounds checker (-b) |
| 195 | --config-predefs=no do not compile tccdefs.h, instead just include | 195 | --config-predefs=no do not compile tccdefs.h, instead just include |
| 196 | --config-new_macho=no|yes Force apple object format (autodetect osx <= 10) | 196 | --config-new_macho=no|yes force apple object format (autodetect osx <= 10) |
| 197 | --config-new_dtags=yes use new ELF DTAGs (DT_RUNPATH instead of DT_RPATH) | ||
| 197 | --config-codesign=no do not use codesign on apple to sign executables | 198 | --config-codesign=no do not use codesign on apple to sign executables |
| 198 | --dwarf=x Use dwarf debug info instead of stabs (x=2..5) | 199 | --config-dwarf=x use dwarf debug info instead of stabs (x=2..5) |
| 199 | 200 | ||
| 200 | Cross build options (experimental): | 201 | Cross build options (experimental): |
| 201 | --cpu=CPU target CPU [$cpu] | 202 | --cpu=CPU target CPU [$cpu] |
| @@ -209,7 +210,7 @@ default() # set variable unless already set · 7 unmodified lines | |||
| 209 | { | 210 | { |
| 210 | local v | 211 | local v |
| 211 | eval v=\"\$$1\" | 212 | eval v=\"\$$1\" |
| 212 | test -z "$v" && eval $1=\"$2\" | 213 | test -z "$v" -a -n "$2" && eval $1=\"$2\" |
| 213 | } | 214 | } |
| 214 | 215 | ||
| 215 | default_conf() # add to confvars unless already present | 216 | default_conf() # add to confvars unless already present |
| @@ -251,10 +252,9 @@ else · 35 unmodified lines | |||
| 251 | fi | 252 | fi |
| 252 | 253 | ||
| 253 | default cpu "$cpu_sys" | 254 | default cpu "$cpu_sys" |
| 254 | cpu_set="$cpu" | ||
| 255 | 255 | ||
| 256 | # check for crpss build | 256 | # check for crpss build |
| 257 | if test "$cpu_set" != "$cpu_sys" \ | 257 | if test "$cpu" != "$cpu_sys" \ |
| 258 | -o "$targetos" != "$buildos" \ | 258 | -o "$targetos" != "$buildos" \ |
| 259 | -o -n "$cross_prefix" ; then | 259 | -o -n "$cross_prefix" ; then |
| 260 | build_cross="yes" | 260 | build_cross="yes" |
| @@ -322,8 +322,7 @@ esac · 61 unmodified lines | |||
| 322 | 322 | ||
| 323 | case $targetos in | 323 | case $targetos in |
| 324 | Darwin) | 324 | Darwin) |
| 325 | dwarf=4 | 325 | confvars="$confvars OSX dwarf=4" |
| 326 | confvars="$confvars OSX" | ||
| 327 | default_conf "codesign" | 326 | default_conf "codesign" |
| 328 | DLLSUF=".dylib" | 327 | DLLSUF=".dylib" |
| 329 | if test -z "$build_cross"; then | 328 | if test -z "$build_cross"; then |
| @@ -354,14 +353,14 @@ case $targetos in · 24 unmodified lines | |||
| 354 | default sysroot "/usr" | 353 | default sysroot "/usr" |
| 355 | fi | 354 | fi |
| 356 | default prefix "${sysroot}" | 355 | default prefix "${sysroot}" |
| 357 | confvars="$confvars Android new-dtags rpath=no" | 356 | confvars="$confvars Android new_dtags rpath=no" |
| 358 | test "${cpu}" != "i386" && confvars="$confvars pie" | 357 | test "${cpu}" != "i386" && confvars="$confvars pie" |
| 359 | default_conf "static=no" | 358 | default_conf "static=no" |
| 360 | if test "${cpu}" = "arm"; then | 359 | if test "${cpu}" = "arm"; then |
| 361 | default triplet "arm-linux-androideabi" | 360 | default triplet "arm-linux-androideabi" |
| 362 | cpuver=7 | 361 | cpuver=7 |
| 363 | else | 362 | else |
| 364 | default triplet "${cpu_set}-linux-android" | 363 | default triplet "${cpu}-linux-android" |
| 365 | fi | 364 | fi |
| 366 | test "${cpu%64}" != "${cpu}" && S="64" || S="" | 365 | test "${cpu%64}" != "${cpu}" && S="64" || S="" |
| 367 | default tcc_sysincludepaths "{B}/include:{R}/include:{R}/include/${triplet}" | 366 | default tcc_sysincludepaths "{B}/include:{R}/include:{R}/include/${triplet}" |
| @@ -372,13 +371,16 @@ case $targetos in · 4 unmodified lines | |||
| 372 | ;; | 371 | ;; |
| 373 | WIN32) | 372 | WIN32) |
| 374 | mingw32="yes" | 373 | mingw32="yes" |
| 375 | confvars="$confvars WIN32" | 374 | confvars="WIN32 $confvars" |
| 376 | default prefix "C:/Program Files/tcc" | 375 | default prefix "C:/Program Files/tcc" |
| 377 | default tccdir "${prefix}" | 376 | default tccdir "${prefix}" |
| 378 | default bindir "${tccdir}" | 377 | default bindir "${tccdir}" |
| 379 | default docdir "${tccdir}/doc" | 378 | default docdir "${tccdir}/doc" |
| 380 | default libdir "${tccdir}/libtcc" | 379 | default libdir "${tccdir}/libtcc" |
| 380 | # set tccdir at runtime from executable path | ||
| 381 | test "$tccdir" = "$bindir" && tccdir_auto="yes" | 381 | test "$tccdir" = "$bindir" && tccdir_auto="yes" |
| 382 | # avoid mingw dependencies such as 'libgcc_s_dw2-1.dll' | ||
| 383 | test "$cc_name" = "gcc" && default LDFLAGS "-static" | ||
| 382 | LIBSUF=".lib" | 384 | LIBSUF=".lib" |
| 383 | EXESUF=".exe" | 385 | EXESUF=".exe" |
| 384 | DLLSUF=".dll" | 386 | DLLSUF=".dll" |
| @@ -435,7 +437,7 @@ if test -z "$build_cross"; then · 50 unmodified lines | |||
| 435 | if test -f "/lib/ld-uClibc.so.0" ; then | 437 | if test -f "/lib/ld-uClibc.so.0" ; then |
| 436 | echo "Perhaps you want ./configure --config-uClibc" | 438 | echo "Perhaps you want ./configure --config-uClibc" |
| 437 | fi | 439 | fi |
| 438 | if test -f "/lib/ld-musl-$cpu.so.1"; then | 440 | if test -f "/lib/ld-musl-${cpu}.so.1"; then |
| 439 | echo "Perhaps you want ./configure --config-musl" | 441 | echo "Perhaps you want ./configure --config-musl" |
| 440 | fi | 442 | fi |
| 441 | fi | 443 | fi |
| @@ -452,7 +454,7 @@ else · 10 unmodified lines | |||
| 452 | esac | 454 | esac |
| 453 | case $targetos in | 455 | case $targetos in |
| 454 | Linux) | 456 | Linux) |
| 455 | default triplet "$cpu_set-linux-gnu" | 457 | default triplet "${cpu}-linux-gnu" |
| 456 | esac | 458 | esac |
| 457 | fi | 459 | fi |
| 458 | 460 | ||
| @@ -460,11 +462,6 @@ if test "$bigendian" = "yes" ; then · 1 unmodified line | |||
| 460 | confvars="$confvars BIGENDIAN" | 462 | confvars="$confvars BIGENDIAN" |
| 461 | fi | 463 | fi |
| 462 | 464 | ||
| 463 | if test "$mingw32" = "yes" -a "$cc_name" = "gcc"; then | ||
| 464 | # avoid mingw dependencies such as 'libgcc_s_dw2-1.dll' | ||
| 465 | default LDFLAGS "-static" | ||
| 466 | fi | ||
| 467 | |||
| 468 | if test "$cpu" = "arm"; then | 465 | if test "$cpu" = "arm"; then |
| 469 | if test "${triplet%eabihf}" != "$triplet" ; then | 466 | if test "${triplet%eabihf}" != "$triplet" ; then |
| 470 | confvars="$confvars arm_eabihf arm_vfp" | 467 | confvars="$confvars arm_eabihf arm_vfp" |
| @@ -481,19 +478,14 @@ if test "$cpu" = "arm"; then · 10 unmodified lines | |||
| 481 | fi | 478 | fi |
| 482 | fi | 479 | fi |
| 483 | 480 | ||
| 484 | if test -n "$dwarf"; then | ||
| 485 | confvars="$confvars dwarf=$dwarf" | ||
| 486 | fi | ||
| 487 | |||
| 488 | # a final configuration tuning | 481 | # a final configuration tuning |
| 489 | if test "$cc_name" != "tcc"; then | 482 | if test "$cc_name" != "tcc"; then |
| 490 | OPT1="-Wdeclaration-after-statement -fno-strict-aliasing" | 483 | OPT1="-Wdeclaration-after-statement" #-fno-strict-aliasing |
| 491 | # we want -Wno- but gcc does not always reject unknown -Wno- options | 484 | # we want -Wno- but gcc does not always reject unknown -Wno- options |
| 492 | OPT2="-Wpointer-sign -Wsign-compare -Wunused-result -Wformat-truncation" | ||
| 493 | OPT2="$OPT2 -Wstringop-truncation" | ||
| 494 | if test "$cc_name" = "clang"; then | 485 | if test "$cc_name" = "clang"; then |
| 495 | OPT1="$OPT1 -fheinous-gnu-extensions" | 486 | OPT2= #"-Wstring-plus-int" |
| 496 | OPT2="$OPT2 -Wstring-plus-int -Wdeprecated-declarations" | 487 | else |
| 488 | OPT2="-Wunused-result" | ||
| 497 | fi | 489 | fi |
| 498 | $cc $OPT1 $OPT2 -o a.out -c -xc - < /dev/null > cc_msg.txt 2>&1 | 490 | $cc $OPT1 $OPT2 -o a.out -c -xc - < /dev/null > cc_msg.txt 2>&1 |
| 499 | for o in $OPT1; do # enable these options | 491 | for o in $OPT1; do # enable these options |
| @@ -534,6 +526,8 @@ fcho "Switches " "$tcc_switches" · 34 unmodified lines | |||
| 534 | fcho "Config " "${confvars# }" | 526 | fcho "Config " "${confvars# }" |
| 535 | echo "Creating config.mak and config.h" | 527 | echo "Creating config.mak and config.h" |
| 536 | 528 | ||
| 529 | version=`head $source_path/VERSION` | ||
| 530 | |||
| 537 | cat >config.mak <<EOF | 531 | cat >config.mak <<EOF |
| 538 | # Automatically generated by configure - do not modify | 532 | # Automatically generated by configure - do not modify |
| 539 | prefix=$prefix | 533 | prefix=$prefix |
| @@ -549,80 +543,132 @@ CC_NAME=$cc_name · 9 unmodified lines | |||
| 549 | GCC_MAJOR=$gcc_major | 543 | GCC_MAJOR=$gcc_major |
| 550 | GCC_MINOR=$gcc_minor | 544 | GCC_MINOR=$gcc_minor |
| 551 | AR=$ar | 545 | AR=$ar |
| 552 | CFLAGS=$CFLAGS | ||
| 553 | LDFLAGS=$LDFLAGS | ||
| 554 | LIBSUF=$LIBSUF | 546 | LIBSUF=$LIBSUF |
| 555 | EXESUF=$EXESUF | 547 | EXESUF=$EXESUF |
| 556 | DLLSUF=$DLLSUF | 548 | DLLSUF=$DLLSUF |
| 549 | CFLAGS=$CFLAGS | ||
| 550 | LDFLAGS=$LDFLAGS | ||
| 551 | ARCH=$cpu | ||
| 552 | TARGETOS=$targetos | ||
| 553 | BUILDOS=$buildos | ||
| 554 | VERSION=$version | ||
| 557 | EOF | 555 | EOF |
| 558 | 556 | ||
| 559 | print_inc() { | 557 | if test "$source_path_used" = "yes" ; then |
| 558 | case $source_path in | ||
| 559 | /*) echo "TOPSRC=$source_path";; | ||
| 560 | *) echo "TOPSRC=\$(TOP)/$source_path";; | ||
| 561 | esac >>config.mak | ||
| 562 | else | ||
| 563 | echo 'TOPSRC=$(TOP)' >>config.mak | ||
| 564 | fi | ||
| 565 | |||
| 566 | print_str() { | ||
| 560 | local v="$2" | 567 | local v="$2" |
| 561 | if test -n "$v"; then | 568 | if test -n "$v"; then |
| 562 | test "$3" = "num" || v="\"$v\"" | 569 | test -n "$3" && echo "#ifndef $1" >> $TMPH |
| 563 | echo "#ifndef $1" >> $TMPH | 570 | echo "#define $1 \"$v\"" >> $TMPH |
| 564 | echo "# define $1 $v" >> $TMPH | 571 | test -n "$3" && echo "#endif" >> $TMPH |
| 565 | echo "#endif" >> $TMPH | ||
| 566 | fi | 572 | fi |
| 567 | } | 573 | } |
| 568 | 574 | ||
| 569 | print_mak() { | 575 | print_num() { |
| 570 | local v="$2" | 576 | local v="$2" |
| 571 | if test -n "$v"; then | 577 | if test -n "$v"; then |
| 572 | test "$3" = "num" || v="\"\\\"$v\\\"\"" | 578 | test -n "$3" && echo "#ifndef $1" >> $TMPH |
| 573 | echo "NATIVE_DEFINES+=-D$1=$v" >> config.mak | 579 | echo "#define $1 $v" >> $TMPH |
| 580 | test -n "$3" && echo "#endif" >> $TMPH | ||
| 574 | fi | 581 | fi |
| 575 | } | 582 | } |
| 576 | 583 | ||
| 577 | echo "/* Automatically generated by configure - do not modify */" > $TMPH | 584 | cat >$TMPH <<EOF |
| 578 | 585 | /* Automatically generated by configure - do not modify */ | |
| 579 | print_inc CONFIG_SYSROOT "$sysroot" | ||
| 580 | test "$tccdir_auto" = "yes" || print_inc CONFIG_TCCDIR "$tccdir" | ||
| 581 | print_inc DWARF_VERSION "$dwarf" num | ||
| 582 | print_mak CONFIG_USR_INCLUDE "$tcc_usrinclude" | ||
| 583 | print_mak CONFIG_TCC_SYSINCLUDEPATHS "$tcc_sysincludepaths" | ||
| 584 | print_mak CONFIG_TCC_LIBPATHS "$tcc_libpaths" | ||
| 585 | print_mak CONFIG_TCC_CRTPREFIX "$tcc_crtprefix" | ||
| 586 | print_mak CONFIG_TCC_ELFINTERP "$tcc_elfinterp" | ||
| 587 | print_mak CONFIG_TCC_SWITCHES "$tcc_switches" | ||
| 588 | print_mak CONFIG_LDDIR "$tcc_lddir" | ||
| 589 | print_mak CONFIG_TRIPLET "$triplet" | ||
| 590 | print_mak TCC_CPU_VERSION "$cpuver" num | ||
| 591 | |||
| 592 | echo "ARCH=$cpu" >> config.mak | ||
| 593 | echo "TARGETOS=$targetos" >> config.mak | ||
| 594 | echo "BUILDOS=$buildos" >> config.mak | ||
| 595 | |||
| 596 | predefs="1" | ||
| 597 | for v in $confvars ; do | ||
| 598 | test "$v" = "predefs=no" && predefs="" | ||
| 599 | if test "${v%=*}" = "$v"; then | ||
| 600 | echo "CONFIG_$v=yes" >> config.mak | ||
| 601 | else | ||
| 602 | echo "CONFIG_$v" >> config.mak | ||
| 603 | fi | ||
| 604 | done | ||
| 605 | print_inc CONFIG_TCC_PREDEFS "$predefs" num | ||
| 606 | 586 | ||
| 607 | version=`head $source_path/VERSION` | 587 | #define TCC_VERSION "$version" |
| 608 | echo "VERSION = $version" >> config.mak | ||
| 609 | echo "#define TCC_VERSION \"$version\"" >> $TMPH | ||
| 610 | echo "@set VERSION $version" > config.texi | ||
| 611 | 588 | ||
| 612 | if test "$source_path_used" = "yes" ; then | 589 | #define CC_NAME CC_$cc_name |
| 613 | case $source_path in | ||
| 614 | /*) echo "TOPSRC=$source_path";; | ||
| 615 | *) echo "TOPSRC=\$(TOP)/$source_path";; | ||
| 616 | esac >>config.mak | ||
| 617 | else | ||
| 618 | echo 'TOPSRC=$(TOP)' >>config.mak | ||
| 619 | fi | ||
| 620 | cat >>$TMPH <<EOF | ||
| 621 | #define GCC_MAJOR $gcc_major | 590 | #define GCC_MAJOR $gcc_major |
| 622 | #define GCC_MINOR $gcc_minor | 591 | #define GCC_MINOR $gcc_minor |
| 623 | #define CC_NAME CC_${cc_name} | 592 | |
| 593 | #if !CONFIG_TCC_CROSS | ||
| 624 | EOF | 594 | EOF |
| 625 | 595 | ||
| 596 | predefs=1 | ||
| 597 | # options that are applied only to the native tcc | ||
| 598 | for v in $cpu $confvars ; do | ||
| 599 | if test "${v%=*}" = "$v"; then | ||
| 600 | v="$v=yes" | ||
| 601 | fi | ||
| 602 | R="CONFIG_$v" | ||
| 603 | echo "$R" >> config.mak | ||
| 604 | case "$R" in | ||
| 605 | # CPU | ||
| 606 | CONFIG_i386=yes) print_num TCC_TARGET_I386 1 ;; | ||
| 607 | CONFIG_x86_64=yes) print_num TCC_TARGET_X86_64 1 ;; | ||
| 608 | CONFIG_arm64=yes) print_num TCC_TARGET_ARM64 1 ;; | ||
| 609 | CONFIG_riscv64=yes) print_num TCC_TARGET_RISCV64 1 ;; | ||
| 610 | CONFIG_arm=yes) print_num TCC_TARGET_ARM 1 | ||
| 611 | print_num CONFIG_TCC_CPUVER "$cpuver" ;; | ||
| 612 | CONFIG_arm_eabihf=yes) print_num TCC_ARM_EABI 1 | ||
| 613 | print_num TCC_ARM_HARDFLOAT 1 ;; | ||
| 614 | CONFIG_arm_eabi=yes) print_num TCC_ARM_EABI 1 ;; | ||
| 615 | CONFIG_arm_vfp=yes) print_num TCC_ARM_VFP 1 ;; | ||
| 616 | # OS | ||
| 617 | CONFIG_WIN32=yes) print_num TCC_TARGET_PE 1 ;; | ||
| 618 | CONFIG_OSX=yes) print_num TCC_TARGET_MACHO 1 ;; | ||
| 619 | CONFIG_Android=yes) print_num TARGETOS_ANDROID 1 ;; | ||
| 620 | CONFIG_BSD=yes) print_num TARGETOS_$targetos 1 | ||
| 621 | case "$targetos" in | ||
| 622 | FreeBSD) default tcc_elfinterp "/libexec/ld-elf.so.1";; | ||
| 623 | FreeBSD_kernel) | ||
| 624 | case "$cpu" in | ||
| 625 | x86_64) default tcc_elfinterp "/lib/ld-kfreebsd-x86-64.so.1";; | ||
| 626 | *) default tcc_elfinterp "/lib/ld.so.1";; | ||
| 627 | esac ;; | ||
| 628 | DragonFly) default tcc_elfinterp "/usr/libexec/ld-elf.so.2";; | ||
| 629 | NetBSD) default tcc_elfinterp "/usr/libexec/ld.elf_so";; | ||
| 630 | OpenBSD) default tcc_elfinterp "/usr/libexec/ld.so";; | ||
| 631 | esac | ||
| 632 | ;; | ||
| 633 | CONFIG_uClibc=yes) print_num CONFIG_TCC_UCLIBC 1 | ||
| 634 | default tcc_elfinterp "/lib/ld-uClibc.so.0" | ||
| 635 | ;; | ||
| 636 | CONFIG_musl=yes) print_num CONFIG_TCC_MUSL 1 | ||
| 637 | case "$cpu" in | ||
| 638 | arm64) default tcc_elfinterp "/lib/ld-musl-aarch64.so.1";; | ||
| 639 | *) default tcc_elfinterp "/lib/ld-musl-${cpu}.so.1";; | ||
| 640 | esac | ||
| 641 | ;; | ||
| 642 | # other | ||
| 643 | CONFIG_libgcc=yes) print_num CONFIG_USE_LIBGCC 1 ;; | ||
| 644 | CONFIG_selinux=yes) print_num CONFIG_SELINUX 1 ;; | ||
| 645 | CONFIG_pie=yes) print_num CONFIG_TCC_PIE 1 ;; | ||
| 646 | CONFIG_pic=yes) print_num CONFIG_TCC_PIC 1 ;; | ||
| 647 | CONFIG_new_dtags=yes) print_num CONFIG_NEW_DTAGS 1 ;; | ||
| 648 | CONFIG_codesign=yes) print_num CONFIG_CODESIGN 1 ;; | ||
| 649 | CONFIG_new_macho=no) print_num CONFIG_NEW_MACHO 0 ;; | ||
| 650 | CONFIG_bcheck=no) print_num CONFIG_TCC_BCHECK 0 ;; | ||
| 651 | CONFIG_backtrace=no) print_num CONFIG_TCC_BACKTRACE 0 ;; | ||
| 652 | CONFIG_dwarf=*) print_num CONFIG_DWARF_VERSION ${R#*=} ;; | ||
| 653 | CONFIG_semlock=*) print_num CONFIG_TCC_SEMLOCK ${R#*=} ;; | ||
| 654 | CONFIG_predefs=no) predefs=0 ;; | ||
| 655 | esac | ||
| 656 | done | ||
| 657 | |||
| 658 | print_str CONFIG_USR_INCLUDE "$tcc_usrinclude" | ||
| 659 | print_str CONFIG_TCC_SYSINCLUDEPATHS "$tcc_sysincludepaths" | ||
| 660 | print_str CONFIG_TCC_LIBPATHS "$tcc_libpaths" | ||
| 661 | print_str CONFIG_TCC_CRTPREFIX "$tcc_crtprefix" | ||
| 662 | print_str CONFIG_TCC_ELFINTERP "$tcc_elfinterp" | ||
| 663 | print_str CONFIG_TCC_SWITCHES "$tcc_switches" | ||
| 664 | print_str CONFIG_LDDIR "$tcc_lddir" | ||
| 665 | print_str CONFIG_TRIPLET "$triplet" | ||
| 666 | echo "#endif" >> $TMPH && echo >> $TMPH | ||
| 667 | |||
| 668 | print_str CONFIG_SYSROOT "$sysroot" x | ||
| 669 | test "$tccdir_auto" = "yes" || print_str CONFIG_TCCDIR "$tccdir" x | ||
| 670 | print_num CONFIG_TCC_PREDEFS "$predefs" | ||
| 671 | |||
| 626 | diff $TMPH config.h >/dev/null 2>&1 | 672 | diff $TMPH config.h >/dev/null 2>&1 |
| 627 | if test $? -ne 0 ; then | 673 | if test $? -ne 0 ; then |
| 628 | mv -f $TMPH config.h | 674 | mv -f $TMPH config.h |
| @@ -630,6 +676,8 @@ else · 1 unmodified line | |||
| 630 | echo "config.h is unchanged" | 676 | echo "config.h is unchanged" |
| 631 | fi | 677 | fi |
| 632 | 678 | ||
| 679 | echo "@set VERSION $version" > config.texi | ||
| 680 | |||
| 633 | rm -f $TMPN* $CONFTEST | 681 | rm -f $TMPN* $CONFTEST |
| 634 | 682 | ||
| 635 | # --------------------------------------------------------------------------- | 683 | # --------------------------------------------------------------------------- |
| @@ -218,11 +218,6 @@ ST_FUNC void load(int r, SValue *sv) · 217 unmodified lines | |||
| 218 | int v, t, ft, fc, fr; | 218 | int v, t, ft, fc, fr; |
| 219 | SValue v1; | 219 | SValue v1; |
| 220 | 220 | ||
| 221 | #ifdef TCC_TARGET_PE | ||
| 222 | SValue v2; | ||
| 223 | sv = pe_getimport(sv, &v2); | ||
| 224 | #endif | ||
| 225 | |||
| 226 | fr = sv->r; | 221 | fr = sv->r; |
| 227 | ft = sv->type.t & ~VT_DEFSIGN; | 222 | ft = sv->type.t & ~VT_DEFSIGN; |
| 228 | fc = sv->c.i; | 223 | fc = sv->c.i; |
| @@ -297,11 +292,6 @@ ST_FUNC void store(int r, SValue *v) · 68 unmodified lines | |||
| 297 | { | 292 | { |
| 298 | int fr, bt, ft, fc; | 293 | int fr, bt, ft, fc; |
| 299 | 294 | ||
| 300 | #ifdef TCC_TARGET_PE | ||
| 301 | SValue v2; | ||
| 302 | v = pe_getimport(v, &v2); | ||
| 303 | #endif | ||
| 304 | |||
| 305 | ft = v->type.t; | 295 | ft = v->type.t; |
| 306 | fc = v->c.i; | 296 | fc = v->c.i; |
| 307 | fr = v->r & VT_VALMASK; | 297 | fr = v->r & VT_VALMASK; |
| @@ -91,7 +91,7 @@ $(X)%.o : %.S $(TCC) · 90 unmodified lines | |||
| 91 | $(TOP)/%.o : %.c $(TCC) | 91 | $(TOP)/%.o : %.c $(TCC) |
| 92 | $S$(XCC) -c $< -o $@ $(XFLAGS) | 92 | $S$(XCC) -c $< -o $@ $(XFLAGS) |
| 93 | 93 | ||
| 94 | $(TOP)/bcheck.o : XFLAGS += $(BFLAGS) $(if $(CONFIG_musl),-DTCC_MUSL) | 94 | $(TOP)/bcheck.o : XFLAGS += $(BFLAGS) |
| 95 | $(TOP)/bt-exe.o : $(TOP)/tccrun.c | 95 | $(TOP)/bt-exe.o : $(TOP)/tccrun.c |
| 96 | 96 | ||
| 97 | $(X)crt1w.o : crt1.c | 97 | $(X)crt1w.o : crt1.c |
| @@ -37,6 +37,8 @@ · 36 unmodified lines | |||
| 37 | #include <sys/syscall.h> | 37 | #include <sys/syscall.h> |
| 38 | #endif | 38 | #endif |
| 39 | 39 | ||
| 40 | #include "config.h" | ||
| 41 | |||
| 40 | #define BOUND_DEBUG (1) | 42 | #define BOUND_DEBUG (1) |
| 41 | #define BOUND_STATISTIC (1) | 43 | #define BOUND_STATISTIC (1) |
| 42 | 44 | ||
| @@ -161,7 +163,7 @@ static pthread_spinlock_t bounds_spin; · 118 unmodified lines | |||
| 161 | #define HAVE_TLS_FUNC (1) | 163 | #define HAVE_TLS_FUNC (1) |
| 162 | #define HAVE_TLS_VAR (0) | 164 | #define HAVE_TLS_VAR (0) |
| 163 | #endif | 165 | #endif |
| 164 | #if defined TCC_MUSL || defined __ANDROID__ | 166 | #if defined CONFIG_TCC_MUSL || defined __ANDROID__ |
| 165 | # undef HAVE_CTYPE | 167 | # undef HAVE_CTYPE |
| 166 | #endif | 168 | #endif |
| 167 | #endif | 169 | #endif |
| @@ -1187,7 +1189,7 @@ void __attribute__((destructor)) __bound_exit(void) · 1019 unmodified lines | |||
| 1187 | dprintf(stderr, "%s, %s():\n", __FILE__, __FUNCTION__); | 1189 | dprintf(stderr, "%s, %s():\n", __FILE__, __FUNCTION__); |
| 1188 | 1190 | ||
| 1189 | if (inited) { | 1191 | if (inited) { |
| 1190 | #if !defined(_WIN32) && !defined(__APPLE__) && !defined TCC_MUSL && \ | 1192 | #if !defined(_WIN32) && !defined(__APPLE__) && !defined CONFIG_TCC_MUSL && \ |
| 1191 | !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \ | 1193 | !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && \ |
| 1192 | !defined(__ANDROID__) | 1194 | !defined(__ANDROID__) |
| 1193 | if (print_heap) { | 1195 | if (print_heap) { |
| @@ -5,7 +5,6 @@ · 4 unmodified lines | |||
| 5 | #define CONFIG_TCC_BACKTRACE_ONLY | 5 | #define CONFIG_TCC_BACKTRACE_ONLY |
| 6 | #define ONE_SOURCE 1 | 6 | #define ONE_SOURCE 1 |
| 7 | #define pstrcpy tcc_pstrcpy | 7 | #define pstrcpy tcc_pstrcpy |
| 8 | #define TCC_SEM_IMPL 1 | ||
| 9 | #include "../tccrun.c" | 8 | #include "../tccrun.c" |
| 10 | 9 | ||
| 11 | #ifndef _WIN32 | 10 | #ifndef _WIN32 |
| @@ -18,7 +18,11 @@ · 17 unmodified lines | |||
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ | 19 | */ |
| 20 | 20 | ||
| 21 | #if !defined ONE_SOURCE || ONE_SOURCE | 21 | #ifndef ONE_SOURCE |
| 22 | # define ONE_SOURCE 1 | ||
| 23 | #endif | ||
| 24 | |||
| 25 | #if ONE_SOURCE | ||
| 22 | #include "tccpp.c" | 26 | #include "tccpp.c" |
| 23 | #include "tccgen.c" | 27 | #include "tccgen.c" |
| 24 | #include "tccdbg.c" | 28 | #include "tccdbg.c" |
| @@ -60,7 +64,6 @@ · 35 unmodified lines | |||
| 60 | #endif | 64 | #endif |
| 61 | #endif /* ONE_SOURCE */ | 65 | #endif /* ONE_SOURCE */ |
| 62 | 66 | ||
| 63 | #define TCC_SEM_IMPL 1 | ||
| 64 | #include "tcc.h" | 67 | #include "tcc.h" |
| 65 | 68 | ||
| 66 | /********************************************************/ | 69 | /********************************************************/ |
| @@ -1189,12 +1192,14 @@ ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags) · 1122 unmodified lines | |||
| 1189 | } | 1192 | } |
| 1190 | 1193 | ||
| 1191 | /* find [cross-]libtcc1.a and tcc helper objects in library path */ | 1194 | /* find [cross-]libtcc1.a and tcc helper objects in library path */ |
| 1192 | ST_FUNC void tcc_add_support(TCCState *s1, const char *filename) | 1195 | ST_FUNC int tcc_add_support(TCCState *s1, const char *filename) |
| 1193 | { | 1196 | { |
| 1197 | #if CONFIG_TCC_CROSS | ||
| 1194 | char buf[100]; | 1198 | char buf[100]; |
| 1195 | if (CONFIG_TCC_CROSSPREFIX[0]) | 1199 | if (CONFIG_TCC_CROSSPREFIX[0]) |
| 1196 | filename = strcat(strcpy(buf, CONFIG_TCC_CROSSPREFIX), filename); | 1200 | filename = strcat(strcpy(buf, CONFIG_TCC_CROSSPREFIX), filename); |
| 1197 | tcc_add_dll(s1, filename, AFF_PRINT_ERROR); | 1201 | #endif |
| 1202 | return tcc_add_dll(s1, filename, AFF_PRINT_ERROR); | ||
| 1198 | } | 1203 | } |
| 1199 | 1204 | ||
| 1200 | #if !defined TCC_TARGET_PE && !defined TCC_TARGET_MACHO | 1205 | #if !defined TCC_TARGET_PE && !defined TCC_TARGET_MACHO |
| @@ -1229,6 +1234,11 @@ LIBTCCAPI int tcc_add_library(TCCState *s, const char *libraryname) · 28 unmodified lines | |||
| 1229 | return ret; | 1234 | return ret; |
| 1230 | ++pp; | 1235 | ++pp; |
| 1231 | } | 1236 | } |
| 1237 | #if CONFIG_TCC_CROSS | ||
| 1238 | /* hack for '<cross>-tcc -nostdlib -ltcc1' to find <cross>-libtcc1.a */ | ||
| 1239 | if (0 == strcmp(libraryname, "tcc1")) | ||
| 1240 | return tcc_add_support(s, TCC_LIBTCC1); | ||
| 1241 | #endif | ||
| 1232 | return tcc_add_dll(s, libraryname, AFF_PRINT_ERROR); | 1242 | return tcc_add_dll(s, libraryname, AFF_PRINT_ERROR); |
| 1233 | } | 1243 | } |
| 1234 | 1244 | ||
| @@ -1750,7 +1760,7 @@ static const char dumpmachine_str[] = · 515 unmodified lines | |||
| 1750 | "openbsd" | 1760 | "openbsd" |
| 1751 | #elif TARGETOS_NetBSD | 1761 | #elif TARGETOS_NetBSD |
| 1752 | "netbsd" | 1762 | "netbsd" |
| 1753 | #elif TCC_MUSL | 1763 | #elif CONFIG_TCC_MUSL |
| 1754 | "linux-musl" | 1764 | "linux-musl" |
| 1755 | #else | 1765 | #else |
| 1756 | "linux-gnu" | 1766 | "linux-gnu" |
| @@ -1941,7 +1951,7 @@ dorun: · 184 unmodified lines | |||
| 1941 | enable_backtrace: | 1951 | enable_backtrace: |
| 1942 | s->do_backtrace = 1; | 1952 | s->do_backtrace = 1; |
| 1943 | s->do_debug = s->do_debug ? s->do_debug : 1; | 1953 | s->do_debug = s->do_debug ? s->do_debug : 1; |
| 1944 | s->dwarf = DWARF_VERSION; | 1954 | s->dwarf = CONFIG_DWARF_VERSION; |
| 1945 | break; | 1955 | break; |
| 1946 | #ifdef CONFIG_TCC_BCHECK | 1956 | #ifdef CONFIG_TCC_BCHECK |
| 1947 | case TCC_OPTION_b: | 1957 | case TCC_OPTION_b: |
| @@ -1951,7 +1961,7 @@ dorun: · 3 unmodified lines | |||
| 1951 | #endif | 1961 | #endif |
| 1952 | case TCC_OPTION_g: | 1962 | case TCC_OPTION_g: |
| 1953 | s->do_debug = 2; | 1963 | s->do_debug = 2; |
| 1954 | s->dwarf = DWARF_VERSION; | 1964 | s->dwarf = CONFIG_DWARF_VERSION; |
| 1955 | if (strstart("dwarf", &optarg)) { | 1965 | if (strstart("dwarf", &optarg)) { |
| 1956 | s->dwarf = (*optarg) ? (0 - atoi(optarg)) : DEFAULT_DWARF_VERSION; | 1966 | s->dwarf = (*optarg) ? (0 - atoi(optarg)) : DEFAULT_DWARF_VERSION; |
| 1957 | } else if (isnum(*optarg)) { | 1967 | } else if (isnum(*optarg)) { |
| @@ -1614,7 +1614,7 @@ ST_FUNC void asm_gen_code(ASMOperand *operands, int nb_operands, · 1613 unmodified lines | |||
| 1614 | /* push */ | 1614 | /* push */ |
| 1615 | /* addi sp, sp, -offset */ | 1615 | /* addi sp, sp, -offset */ |
| 1616 | gen_le32((4 << 2) | 3 | | 1616 | gen_le32((4 << 2) | 3 | |
| 1617 | ENCODE_RD(2) | ENCODE_RS1(2) | -8 << 20); | 1617 | ENCODE_RD(2) | ENCODE_RS1(2) | (unsigned)-8 << 20); |
| 1618 | if (REG_IS_FLOAT(reg)){ | 1618 | if (REG_IS_FLOAT(reg)){ |
| 1619 | /* fsd reg, offset(sp) */ | 1619 | /* fsd reg, offset(sp) */ |
| 1620 | gen_le32( 0x27 | (3 << 12) | | 1620 | gen_le32( 0x27 | (3 << 12) | |
| @@ -18,6 +18,10 @@ · 17 unmodified lines | |||
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ | 19 | */ |
| 20 | 20 | ||
| 21 | #ifndef ONE_SOURCE | ||
| 22 | # define ONE_SOURCE 1 | ||
| 23 | #endif | ||
| 24 | |||
| 21 | #include "tcc.h" | 25 | #include "tcc.h" |
| 22 | #if ONE_SOURCE | 26 | #if ONE_SOURCE |
| 23 | # include "libtcc.c" | 27 | # include "libtcc.c" |
| @@ -212,7 +212,7 @@ extern long double strtold (const char *__nptr, char **__endptr); · 211 unmodified lines | |||
| 212 | || defined TARGETOS_FreeBSD_kernel | 212 | || defined TARGETOS_FreeBSD_kernel |
| 213 | # define TARGETOS_BSD 1 | 213 | # define TARGETOS_BSD 1 |
| 214 | #elif !(defined TCC_TARGET_PE || defined TCC_TARGET_MACHO) | 214 | #elif !(defined TCC_TARGET_PE || defined TCC_TARGET_MACHO) |
| 215 | # define TARGETOS_Linux 1 | 215 | # define TARGETOS_Linux 1 /* for tccdefs_.h */ |
| 216 | #endif | 216 | #endif |
| 217 | 217 | ||
| 218 | #if defined TCC_TARGET_PE || defined TCC_TARGET_MACHO | 218 | #if defined TCC_TARGET_PE || defined TCC_TARGET_MACHO |
| @@ -231,6 +231,11 @@ extern long double strtold (const char *__nptr, char **__endptr); · 12 unmodified lines | |||
| 231 | # define CONFIG_TCC_PIC 1 | 231 | # define CONFIG_TCC_PIC 1 |
| 232 | #endif | 232 | #endif |
| 233 | 233 | ||
| 234 | /* support using libtcc from threads */ | ||
| 235 | #ifndef CONFIG_TCC_SEMLOCK | ||
| 236 | # define CONFIG_TCC_SEMLOCK 1 | ||
| 237 | #endif | ||
| 238 | |||
| 234 | /* ------------ path configuration ------------ */ | 239 | /* ------------ path configuration ------------ */ |
| 235 | 240 | ||
| 236 | #ifndef CONFIG_SYSROOT | 241 | #ifndef CONFIG_SYSROOT |
| @@ -288,58 +293,26 @@ extern long double strtold (const char *__nptr, char **__endptr); · 51 unmodified lines | |||
| 288 | 293 | ||
| 289 | /* name of ELF interpreter */ | 294 | /* name of ELF interpreter */ |
| 290 | #ifndef CONFIG_TCC_ELFINTERP | 295 | #ifndef CONFIG_TCC_ELFINTERP |
| 291 | # if TARGETOS_FreeBSD | 296 | # if defined __GNU__ |
| 292 | # define CONFIG_TCC_ELFINTERP "/libexec/ld-elf.so.1" | ||
| 293 | # elif TARGETOS_FreeBSD_kernel | ||
| 294 | # if defined(TCC_TARGET_X86_64) | ||
| 295 | # define CONFIG_TCC_ELFINTERP "/lib/ld-kfreebsd-x86-64.so.1" | ||
| 296 | # else | ||
| 297 | # define CONFIG_TCC_ELFINTERP "/lib/ld.so.1" | ||
| 298 | # endif | ||
| 299 | # elif TARGETOS_DragonFly | ||
| 300 | # define CONFIG_TCC_ELFINTERP "/usr/libexec/ld-elf.so.2" | ||
| 301 | # elif TARGETOS_NetBSD | ||
| 302 | # define CONFIG_TCC_ELFINTERP "/usr/libexec/ld.elf_so" | ||
| 303 | # elif TARGETOS_OpenBSD | ||
| 304 | # define CONFIG_TCC_ELFINTERP "/usr/libexec/ld.so" | ||
| 305 | # elif defined __GNU__ | ||
| 306 | # define CONFIG_TCC_ELFINTERP "/lib/ld.so" | 297 | # define CONFIG_TCC_ELFINTERP "/lib/ld.so" |
| 307 | # elif defined(TCC_TARGET_PE) | 298 | # elif defined(TCC_TARGET_PE) |
| 308 | # define CONFIG_TCC_ELFINTERP "-" | 299 | # define CONFIG_TCC_ELFINTERP "-" |
| 309 | # elif defined(TCC_UCLIBC) | ||
| 310 | # define CONFIG_TCC_ELFINTERP "/lib/ld-uClibc.so.0" /* is there a uClibc for x86_64 ? */ | ||
| 311 | # elif defined TCC_TARGET_ARM64 | 300 | # elif defined TCC_TARGET_ARM64 |
| 312 | # if defined(TCC_MUSL) | 301 | # define CONFIG_TCC_ELFINTERP "/lib/ld-linux-aarch64.so.1" |
| 313 | # define CONFIG_TCC_ELFINTERP "/lib/ld-musl-aarch64.so.1" | ||
| 314 | # else | ||
| 315 | # define CONFIG_TCC_ELFINTERP "/lib/ld-linux-aarch64.so.1" | ||
| 316 | # endif | ||
| 317 | # elif defined(TCC_TARGET_X86_64) | 302 | # elif defined(TCC_TARGET_X86_64) |
| 318 | # if defined(TCC_MUSL) | 303 | # define CONFIG_TCC_ELFINTERP "/lib64/ld-linux-x86-64.so.2" |
| 319 | # define CONFIG_TCC_ELFINTERP "/lib/ld-musl-x86_64.so.1" | ||
| 320 | # else | ||
| 321 | # define CONFIG_TCC_ELFINTERP "/lib64/ld-linux-x86-64.so.2" | ||
| 322 | # endif | ||
| 323 | # elif defined(TCC_TARGET_RISCV64) | 304 | # elif defined(TCC_TARGET_RISCV64) |
| 324 | # define CONFIG_TCC_ELFINTERP "/lib/ld-linux-riscv64-lp64d.so.1" | 305 | # define CONFIG_TCC_ELFINTERP "/lib/ld-linux-riscv64-lp64d.so.1" |
| 325 | # elif !defined(TCC_ARM_EABI) | 306 | # elif defined(TCC_ARM_EABI) |
| 326 | # if defined(TCC_MUSL) | 307 | # define DEFAULT_ELFINTERP(s) default_elfinterp(s) |
| 327 | # if defined(TCC_TARGET_I386) | 308 | # else |
| 328 | # define CONFIG_TCC_ELFINTERP "/lib/ld-musl-i386.so.1" | 309 | # define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.2" |
| 329 | # else | ||
| 330 | # define CONFIG_TCC_ELFINTERP "/lib/ld-musl-arm.so.1" | ||
| 331 | # endif | ||
| 332 | # else | ||
| 333 | # define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.2" | ||
| 334 | # endif | ||
| 335 | # endif | 310 | # endif |
| 336 | #endif | 311 | #endif |
| 337 | 312 | ||
| 338 | /* var elf_interp dans *-gen.c */ | 313 | /* var elf_interp dans *-gen.c */ |
| 339 | #ifdef CONFIG_TCC_ELFINTERP | 314 | #ifndef DEFAULT_ELFINTERP |
| 340 | # define DEFAULT_ELFINTERP(s) CONFIG_TCC_ELFINTERP | 315 | # define DEFAULT_ELFINTERP(s) CONFIG_TCC_ELFINTERP |
| 341 | #else | ||
| 342 | # define DEFAULT_ELFINTERP(s) default_elfinterp(s) | ||
| 343 | #endif | 316 | #endif |
| 344 | 317 | ||
| 345 | /* (target specific) libtcc1.a */ | 318 | /* (target specific) libtcc1.a */ |
| @@ -347,15 +320,16 @@ extern long double strtold (const char *__nptr, char **__endptr); · 1 unmodified line | |||
| 347 | # define TCC_LIBTCC1 "libtcc1.a" | 320 | # define TCC_LIBTCC1 "libtcc1.a" |
| 348 | #endif | 321 | #endif |
| 349 | 322 | ||
| 350 | #ifndef CONFIG_TCC_CROSSPREFIX | ||
| 351 | # define CONFIG_TCC_CROSSPREFIX "" | ||
| 352 | #endif | ||
| 353 | |||
| 354 | /* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */ | 323 | /* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */ |
| 355 | #if defined CONFIG_USE_LIBGCC && !defined TCC_LIBGCC | 324 | #if defined CONFIG_USE_LIBGCC && !defined TCC_LIBGCC |
| 356 | #define TCC_LIBGCC USE_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) "/libgcc_s.so.1" | 325 | #define TCC_LIBGCC USE_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) "/libgcc_s.so.1" |
| 357 | #endif | 326 | #endif |
| 358 | 327 | ||
| 328 | /* <cross-prefix-to->libtcc1.a */ | ||
| 329 | #ifndef CONFIG_TCC_CROSSPREFIX | ||
| 330 | # define CONFIG_TCC_CROSSPREFIX "" | ||
| 331 | #endif | ||
| 332 | |||
| 359 | /* -------------------------------------------- */ | 333 | /* -------------------------------------------- */ |
| 360 | 334 | ||
| 361 | #include "libtcc.h" | 335 | #include "libtcc.h" |
| @@ -370,12 +344,7 @@ extern long double strtold (const char *__nptr, char **__endptr); · 8 unmodified lines | |||
| 370 | #endif | 344 | #endif |
| 371 | 345 | ||
| 372 | #ifndef ONE_SOURCE | 346 | #ifndef ONE_SOURCE |
| 373 | # define ONE_SOURCE 1 | 347 | # define ONE_SOURCE 0 |
| 374 | #endif | ||
| 375 | |||
| 376 | /* support using libtcc from threads */ | ||
| 377 | #ifndef CONFIG_TCC_SEMLOCK | ||
| 378 | # define CONFIG_TCC_SEMLOCK 1 | ||
| 379 | #endif | 348 | #endif |
| 380 | 349 | ||
| 381 | #if ONE_SOURCE | 350 | #if ONE_SOURCE |
| @@ -1310,7 +1279,7 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) · 928 unmodified lines | |||
| 1310 | ST_FUNC int tcc_add_crt(TCCState *s, const char *filename); | 1279 | ST_FUNC int tcc_add_crt(TCCState *s, const char *filename); |
| 1311 | #endif | 1280 | #endif |
| 1312 | ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags); | 1281 | ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags); |
| 1313 | ST_FUNC void tcc_add_support(TCCState *s1, const char *filename); | 1282 | ST_FUNC int tcc_add_support(TCCState *s1, const char *filename); |
| 1314 | #ifdef CONFIG_TCC_BCHECK | 1283 | #ifdef CONFIG_TCC_BCHECK |
| 1315 | ST_FUNC void tcc_add_bcheck(TCCState *s1); | 1284 | ST_FUNC void tcc_add_bcheck(TCCState *s1); |
| 1316 | #endif | 1285 | #endif |
| @@ -1821,7 +1790,6 @@ ST_FUNC int pe_load_file(struct TCCState *s1, int fd, const char *filename); · 504 unmodified lines | |||
| 1821 | ST_FUNC int pe_output_file(TCCState * s1, const char *filename); | 1790 | ST_FUNC int pe_output_file(TCCState * s1, const char *filename); |
| 1822 | ST_FUNC int pe_putimport(TCCState *s1, int dllindex, const char *name, addr_t value); | 1791 | ST_FUNC int pe_putimport(TCCState *s1, int dllindex, const char *name, addr_t value); |
| 1823 | #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64 | 1792 | #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64 |
| 1824 | ST_FUNC SValue *pe_getimport(SValue *sv, SValue *v2); | ||
| 1825 | #endif | 1793 | #endif |
| 1826 | #ifdef TCC_TARGET_X86_64 | 1794 | #ifdef TCC_TARGET_X86_64 |
| 1827 | ST_FUNC void pe_add_unwind_data(unsigned start, unsigned end, unsigned stack); | 1795 | ST_FUNC void pe_add_unwind_data(unsigned start, unsigned end, unsigned stack); |
| @@ -1924,8 +1892,8 @@ ST_FUNC void tcc_tcov_reset_ind(TCCState *s1); · 96 unmodified lines | |||
| 1924 | #endif | 1892 | #endif |
| 1925 | 1893 | ||
| 1926 | /* default dwarf version for "-g". use 0 to emit stab debug infos */ | 1894 | /* default dwarf version for "-g". use 0 to emit stab debug infos */ |
| 1927 | #ifndef DWARF_VERSION | 1895 | #ifndef CONFIG_DWARF_VERSION |
| 1928 | # define DWARF_VERSION 0 //DEFAULT_DWARF_VERSION | 1896 | # define CONFIG_DWARF_VERSION 0 |
| 1929 | #endif | 1897 | #endif |
| 1930 | 1898 | ||
| 1931 | #if defined TCC_TARGET_PE | 1899 | #if defined TCC_TARGET_PE |
| @@ -1939,16 +1907,38 @@ ST_FUNC void tcc_tcov_reset_ind(TCCState *s1); · 7 unmodified lines | |||
| 1939 | /********************************************************/ | 1907 | /********************************************************/ |
| 1940 | #if CONFIG_TCC_SEMLOCK | 1908 | #if CONFIG_TCC_SEMLOCK |
| 1941 | #if defined _WIN32 | 1909 | #if defined _WIN32 |
| 1942 | typedef struct { int init; CRITICAL_SECTION cr; } TCCSem; | 1910 | typedef struct { int init; CRITICAL_SECTION cs; } TCCSem; |
| 1911 | static inline void wait_sem(TCCSem *p) { | ||
| 1912 | if (!p->init) | ||
| 1913 | InitializeCriticalSection(&p->cs), p->init = 1; | ||
| 1914 | EnterCriticalSection(&p->cs); | ||
| 1915 | } | ||
| 1916 | static inline void post_sem(TCCSem *p) { | ||
| 1917 | LeaveCriticalSection(&p->cs); | ||
| 1918 | } | ||
| 1943 | #elif defined __APPLE__ | 1919 | #elif defined __APPLE__ |
| 1944 | #include <dispatch/dispatch.h> | 1920 | #include <dispatch/dispatch.h> |
| 1945 | typedef struct { int init; dispatch_semaphore_t sem; } TCCSem; | 1921 | typedef struct { int init; dispatch_semaphore_t sem; } TCCSem; |
| 1922 | static inline void wait_sem(TCCSem *p) { | ||
| 1923 | if (!p->init) | ||
| 1924 | p->sem = dispatch_semaphore_create(1), p->init = 1; | ||
| 1925 | dispatch_semaphore_wait(p->sem, DISPATCH_TIME_FOREVER); | ||
| 1926 | } | ||
| 1927 | static inline void post_sem(TCCSem *p) { | ||
| 1928 | dispatch_semaphore_signal(p->sem); | ||
| 1929 | } | ||
| 1946 | #else | 1930 | #else |
| 1947 | #include <semaphore.h> | 1931 | #include <semaphore.h> |
| 1948 | typedef struct { int init; sem_t sem; } TCCSem; | 1932 | typedef struct { int init; sem_t sem; } TCCSem; |
| 1933 | static inline void wait_sem(TCCSem *p) { | ||
| 1934 | if (!p->init) | ||
| 1935 | sem_init(&p->sem, 0, 1), p->init = 1; | ||
| 1936 | while (sem_wait(&p->sem) < 0 && errno == EINTR); | ||
| 1937 | } | ||
| 1938 | static inline void post_sem(TCCSem *p) { | ||
| 1939 | sem_post(&p->sem); | ||
| 1940 | } | ||
| 1949 | #endif | 1941 | #endif |
| 1950 | ST_FUNC void wait_sem(TCCSem *p); | ||
| 1951 | ST_FUNC void post_sem(TCCSem *p); | ||
| 1952 | #define TCC_SEM(s) TCCSem s | 1942 | #define TCC_SEM(s) TCCSem s |
| 1953 | #define WAIT_SEM wait_sem | 1943 | #define WAIT_SEM wait_sem |
| 1954 | #define POST_SEM post_sem | 1944 | #define POST_SEM post_sem |
| @@ -2009,41 +1999,3 @@ PUB_FUNC void tcc_exit_state(TCCState *s1); · 54 unmodified lines | |||
| 2009 | # define TCC_SET_STATE(fn) (tcc_enter_state(s1),fn) | 1999 | # define TCC_SET_STATE(fn) (tcc_enter_state(s1),fn) |
| 2010 | # define _tcc_error use_tcc_error_noabort | 2000 | # define _tcc_error use_tcc_error_noabort |
| 2011 | #endif | 2001 | #endif |
| 2012 | |||
| 2013 | #if CONFIG_TCC_SEMLOCK && TCC_SEM_IMPL | ||
| 2014 | #undef TCC_SEM_IMPL | ||
| 2015 | #if defined _WIN32 | ||
| 2016 | ST_FUNC void wait_sem(TCCSem *p) | ||
| 2017 | { | ||
| 2018 | if (!p->init) | ||
| 2019 | InitializeCriticalSection(&p->cr), p->init = 1; | ||
| 2020 | EnterCriticalSection(&p->cr); | ||
| 2021 | } | ||
| 2022 | ST_FUNC void post_sem(TCCSem *p) | ||
| 2023 | { | ||
| 2024 | LeaveCriticalSection(&p->cr); | ||
| 2025 | } | ||
| 2026 | #elif defined __APPLE__ | ||
| 2027 | ST_FUNC void wait_sem(TCCSem *p) | ||
| 2028 | { | ||
| 2029 | if (!p->init) | ||
| 2030 | p->sem = dispatch_semaphore_create(1), p->init = 1; | ||
| 2031 | dispatch_semaphore_wait(p->sem, DISPATCH_TIME_FOREVER); | ||
| 2032 | } | ||
| 2033 | ST_FUNC void post_sem(TCCSem *p) | ||
| 2034 | { | ||
| 2035 | dispatch_semaphore_signal(p->sem); | ||
| 2036 | } | ||
| 2037 | #else | ||
| 2038 | ST_FUNC void wait_sem(TCCSem *p) | ||
| 2039 | { | ||
| 2040 | if (!p->init) | ||
| 2041 | sem_init(&p->sem, 0, 1), p->init = 1; | ||
| 2042 | while (sem_wait(&p->sem) < 0 && errno == EINTR); | ||
| 2043 | } | ||
| 2044 | ST_FUNC void post_sem(TCCSem *p) | ||
| 2045 | { | ||
| 2046 | sem_post(&p->sem); | ||
| 2047 | } | ||
| 2048 | #endif | ||
| 2049 | #endif | ||
| @@ -826,6 +826,7 @@ static void asm_parse_directive(TCCState *s1, int global) · 825 unmodified lines | |||
| 826 | { | 826 | { |
| 827 | Sym *sym; | 827 | Sym *sym; |
| 828 | const char *newtype; | 828 | const char *newtype; |
| 829 | int st_type; | ||
| 829 | 830 | ||
| 830 | next(); | 831 | next(); |
| 831 | sym = get_asm_sym(tok, NULL); | 832 | sym = get_asm_sym(tok, NULL); |
| @@ -840,11 +841,17 @@ static void asm_parse_directive(TCCState *s1, int global) · 8 unmodified lines | |||
| 840 | } | 841 | } |
| 841 | 842 | ||
| 842 | if (!strcmp(newtype, "function") || !strcmp(newtype, "STT_FUNC")) { | 843 | if (!strcmp(newtype, "function") || !strcmp(newtype, "STT_FUNC")) { |
| 843 | sym->type.t = (sym->type.t & ~VT_BTYPE) | VT_FUNC; | 844 | if (IS_ASM_SYM(sym)) |
| 845 | sym->type.t = (sym->type.t & ~VT_ASM) | VT_ASM_FUNC; | ||
| 846 | st_type = STT_FUNC; | ||
| 847 | set_st_type: | ||
| 844 | if (sym->c) { | 848 | if (sym->c) { |
| 845 | ElfSym *esym = elfsym(sym); | 849 | ElfSym *esym = elfsym(sym); |
| 846 | esym->st_info = ELFW(ST_INFO)(ELFW(ST_BIND)(esym->st_info), STT_FUNC); | 850 | esym->st_info = ELFW(ST_INFO)(ELFW(ST_BIND)(esym->st_info), st_type); |
| 847 | } | 851 | } |
| 852 | } else if (!strcmp(newtype, "object") || !strcmp(newtype, "STT_OBJECT")) { | ||
| 853 | st_type = STT_OBJECT; | ||
| 854 | goto set_st_type; | ||
| 848 | } else | 855 | } else |
| 849 | tcc_warning_c(warn_unsupported)("change type of '%s' from 0x%x to '%s' ignored", | 856 | tcc_warning_c(warn_unsupported)("change type of '%s' from 0x%x to '%s' ignored", |
| 850 | get_tok_str(sym->v, NULL), sym->type.t, newtype); | 857 | get_tok_str(sym->v, NULL), sym->type.t, newtype); |
| @@ -1381,7 +1388,7 @@ ST_FUNC void asm_global_instr(void) · 530 unmodified lines | |||
| 1381 | expect("';'"); | 1388 | expect("';'"); |
| 1382 | 1389 | ||
| 1383 | #ifdef ASM_DEBUG | 1390 | #ifdef ASM_DEBUG |
| 1384 | printf("asm_global: \"%s\"\n", (char *)astr.data); | 1391 | printf("asm_global: \"%s\"\n", (char *)astr->data); |
| 1385 | #endif | 1392 | #endif |
| 1386 | cur_text_section = text_section; | 1393 | cur_text_section = text_section; |
| 1387 | ind = cur_text_section->data_offset; | 1394 | ind = cur_text_section->data_offset; |
| @@ -90,6 +90,8 @@ ST_FUNC void tccelf_new(TCCState *s) · 89 unmodified lines | |||
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | #if TCC_EH_FRAME | 92 | #if TCC_EH_FRAME |
| 93 | if (s->output_format != TCC_OUTPUT_FORMAT_ELF) | ||
| 94 | s->unwind_tables = 0; | ||
| 93 | tcc_eh_frame_start(s); | 95 | tcc_eh_frame_start(s); |
| 94 | #endif | 96 | #endif |
| 95 | 97 | ||
| @@ -101,6 +103,13 @@ ST_FUNC void tccelf_new(TCCState *s) · 5 unmodified lines | |||
| 101 | lbounds_section = new_section(s, ".lbounds", SHT_PROGBITS, shf_RELRO); | 103 | lbounds_section = new_section(s, ".lbounds", SHT_PROGBITS, shf_RELRO); |
| 102 | } | 104 | } |
| 103 | #endif | 105 | #endif |
| 106 | |||
| 107 | #ifdef TCC_TARGET_PE | ||
| 108 | /* to make sure that -ltcc1 -Wl,-e,_start will grab the startup code | ||
| 109 | from libtcc1.a (unless _start defined) */ | ||
| 110 | if (s->elf_entryname) | ||
| 111 | set_global_sym(s, s->elf_entryname, NULL, 0); /* SHN_UNDEF */ | ||
| 112 | #endif | ||
| 104 | } | 113 | } |
| 105 | 114 | ||
| 106 | ST_FUNC void free_section(Section *s) | 115 | ST_FUNC void free_section(Section *s) |
| @@ -2157,10 +2166,8 @@ static int sort_sections(TCCState *s1, int *sec_order, struct dyn_inf *d) · 2050 unmodified lines | |||
| 2157 | } else { | 2166 | } else { |
| 2158 | j = 0x700; | 2167 | j = 0x700; |
| 2159 | } | 2168 | } |
| 2160 | if (s1->output_format != TCC_OUTPUT_FORMAT_ELF) { | 2169 | if (j >= 0x700 && s1->output_format != TCC_OUTPUT_FORMAT_ELF) |
| 2161 | if (j >= 0x700 || 0 == strncmp(s->name, ".eh_frame", 9)) | 2170 | s->sh_size = 0, j = 0x900; |
| 2162 | s->sh_size = 0, j = 0x900; | ||
| 2163 | } | ||
| 2164 | 2171 | ||
| 2165 | if (s->sh_type == SHT_SYMTAB || s->sh_type == SHT_DYNSYM) { | 2172 | if (s->sh_type == SHT_SYMTAB || s->sh_type == SHT_DYNSYM) { |
| 2166 | k = 0x10; | 2173 | k = 0x10; |
| @@ -3149,23 +3156,24 @@ invalid: · 982 unmodified lines | |||
| 3149 | if (sh->sh_type == SHT_RELX) | 3156 | if (sh->sh_type == SHT_RELX) |
| 3150 | sh = &shdr[sh->sh_info]; | 3157 | sh = &shdr[sh->sh_info]; |
| 3151 | /* ignore sections types we do not handle (plus relocs to those) */ | 3158 | /* ignore sections types we do not handle (plus relocs to those) */ |
| 3152 | if (0 == strncmp(strsec + sh->sh_name, ".debug_", 7) | 3159 | sh_name = strsec + sh->sh_name; |
| 3153 | || 0 == strncmp(strsec + sh->sh_name, ".stab", 5)) { | 3160 | if (0 == strncmp(sh_name, ".debug_", 7) |
| 3161 | || 0 == strncmp(sh_name, ".stab", 5)) { | ||
| 3154 | if (!s1->do_debug || seencompressed) | 3162 | if (!s1->do_debug || seencompressed) |
| 3155 | continue; | 3163 | continue; |
| 3164 | } else if (0 == strncmp(sh_name, ".eh_frame", 9)) { | ||
| 3165 | if (NULL == eh_frame_section) | ||
| 3166 | continue; | ||
| 3156 | } else | 3167 | } else |
| 3157 | if (sh->sh_type != SHT_PROGBITS && | 3168 | if (sh->sh_type != SHT_PROGBITS && |
| 3158 | #ifdef TCC_ARM_EABI | ||
| 3159 | sh->sh_type != SHT_ARM_EXIDX && | ||
| 3160 | #endif | ||
| 3161 | #if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD | ||
| 3162 | sh->sh_type != SHT_X86_64_UNWIND && | ||
| 3163 | #endif | ||
| 3164 | sh->sh_type != SHT_NOTE && | 3169 | sh->sh_type != SHT_NOTE && |
| 3165 | sh->sh_type != SHT_NOBITS && | 3170 | sh->sh_type != SHT_NOBITS && |
| 3166 | sh->sh_type != SHT_PREINIT_ARRAY && | 3171 | sh->sh_type != SHT_PREINIT_ARRAY && |
| 3167 | sh->sh_type != SHT_INIT_ARRAY && | 3172 | sh->sh_type != SHT_INIT_ARRAY && |
| 3168 | sh->sh_type != SHT_FINI_ARRAY | 3173 | sh->sh_type != SHT_FINI_ARRAY |
| 3174 | #ifdef TCC_ARM_EABI | ||
| 3175 | && sh->sh_type != SHT_ARM_EXIDX | ||
| 3176 | #endif | ||
| 3169 | ) | 3177 | ) |
| 3170 | continue; | 3178 | continue; |
| 3171 | 3179 | ||
| @@ -3176,24 +3184,29 @@ invalid: · 4 unmodified lines | |||
| 3176 | /* find corresponding section, if any */ | 3184 | /* find corresponding section, if any */ |
| 3177 | for(j = 1; j < s1->nb_sections;j++) { | 3185 | for(j = 1; j < s1->nb_sections;j++) { |
| 3178 | s = s1->sections[j]; | 3186 | s = s1->sections[j]; |
| 3179 | if (!strcmp(s->name, sh_name)) { | 3187 | if (strcmp(s->name, sh_name)) |
| 3180 | if (!strncmp(sh_name, ".gnu.linkonce", | 3188 | continue; |
| 3181 | sizeof(".gnu.linkonce") - 1)) { | 3189 | if (sh->sh_type != s->sh_type |
| 3182 | /* if a 'linkonce' section is already present, we | 3190 | && s != eh_frame_section |
| 3183 | do not add it again. It is a little tricky as | 3191 | ) { |
| 3184 | symbols can still be defined in | 3192 | tcc_error_noabort("section type conflict: %s %02x <> %02x", s->name, sh->sh_type, s->sh_type); |
| 3185 | it. */ | 3193 | goto the_end; |
| 3186 | sm_table[i].link_once = 1; | ||
| 3187 | goto next; | ||
| 3188 | } | ||
| 3189 | if (stab_section) { | ||
| 3190 | if (s == stab_section) | ||
| 3191 | stab_index = i; | ||
| 3192 | if (s == stab_section->link) | ||
| 3193 | stabstr_index = i; | ||
| 3194 | } | ||
| 3195 | goto found; | ||
| 3196 | } | 3194 | } |
| 3195 | if (!strncmp(sh_name, ".gnu.linkonce", 13)) { | ||
| 3196 | /* if a 'linkonce' section is already present, we | ||
| 3197 | do not add it again. It is a little tricky as | ||
| 3198 | symbols can still be defined in | ||
| 3199 | it. */ | ||
| 3200 | sm_table[i].link_once = 1; | ||
| 3201 | goto next; | ||
| 3202 | } | ||
| 3203 | if (stab_section) { | ||
| 3204 | if (s == stab_section) | ||
| 3205 | stab_index = i; | ||
| 3206 | if (s == stab_section->link) | ||
| 3207 | stabstr_index = i; | ||
| 3208 | } | ||
| 3209 | goto found; | ||
| 3197 | } | 3210 | } |
| 3198 | /* not found: create new section */ | 3211 | /* not found: create new section */ |
| 3199 | s = new_section(s1, sh_name, sh->sh_type, sh->sh_flags & ~SHF_GROUP); | 3212 | s = new_section(s1, sh_name, sh->sh_type, sh->sh_flags & ~SHF_GROUP); |
| @@ -3203,14 +3216,6 @@ invalid: · 3 unmodified lines | |||
| 3203 | s->sh_entsize = sh->sh_entsize; | 3216 | s->sh_entsize = sh->sh_entsize; |
| 3204 | sm_table[i].new_section = 1; | 3217 | sm_table[i].new_section = 1; |
| 3205 | found: | 3218 | found: |
| 3206 | if (sh->sh_type != s->sh_type | ||
| 3207 | #if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD | ||
| 3208 | && strcmp (s->name, ".eh_frame") | ||
| 3209 | #endif | ||
| 3210 | ) { | ||
| 3211 | tcc_error_noabort("invalid section type"); | ||
| 3212 | goto the_end; | ||
| 3213 | } | ||
| 3214 | /* align start of section */ | 3219 | /* align start of section */ |
| 3215 | s->data_offset += -s->data_offset & (sh->sh_addralign - 1); | 3220 | s->data_offset += -s->data_offset & (sh->sh_addralign - 1); |
| 3216 | if (sh->sh_addralign > s->sh_addralign) | 3221 | if (sh->sh_addralign > s->sh_addralign) |
| @@ -3907,7 +3912,7 @@ static int ld_add_file(TCCState *s1, const char filename[]) · 690 unmodified lines | |||
| 3907 | 3912 | ||
| 3908 | static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed) | 3913 | static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed) |
| 3909 | { | 3914 | { |
| 3910 | char filename[1024], libname[1024]; | 3915 | char filename[1024], libname[1016]; |
| 3911 | int t, group, nblibs = 0, ret = 0; | 3916 | int t, group, nblibs = 0, ret = 0; |
| 3912 | char **libs = NULL; | 3917 | char **libs = NULL; |
| 3913 | 3918 | ||
| @@ -157,6 +157,7 @@ static void gv_dup(void); · 156 unmodified lines | |||
| 157 | static int get_temp_local_var(int size,int align,int *r2); | 157 | static int get_temp_local_var(int size,int align,int *r2); |
| 158 | static void cast_error(CType *st, CType *dt); | 158 | static void cast_error(CType *st, CType *dt); |
| 159 | static void end_switch(void); | 159 | static void end_switch(void); |
| 160 | static void do_Static_assert(void); | ||
| 160 | 161 | ||
| 161 | /* ------------------------------------------------------------------------- */ | 162 | /* ------------------------------------------------------------------------- */ |
| 162 | /* Automagical code suppression */ | 163 | /* Automagical code suppression */ |
| @@ -4340,8 +4341,6 @@ static void struct_layout(CType *type, AttributeDef *ad) · 4177 unmodified lines | |||
| 4340 | } | 4341 | } |
| 4341 | } | 4342 | } |
| 4342 | 4343 | ||
| 4343 | static void do_Static_assert(void); | ||
| 4344 | |||
| 4345 | /* enum/struct/union declaration. u is VT_ENUM/VT_STRUCT/VT_UNION */ | 4344 | /* enum/struct/union declaration. u is VT_ENUM/VT_STRUCT/VT_UNION */ |
| 4346 | static void struct_decl(CType *type, int u) | 4345 | static void struct_decl(CType *type, int u) |
| 4347 | { | 4346 | { |
| @@ -6027,6 +6026,13 @@ special_math_val: · 1679 unmodified lines | |||
| 6027 | 6026 | ||
| 6028 | if (r & VT_SYM) { | 6027 | if (r & VT_SYM) { |
| 6029 | vtop->c.i = 0; | 6028 | vtop->c.i = 0; |
| 6029 | #ifdef TCC_TARGET_PE | ||
| 6030 | if (s->a.dllimport) { | ||
| 6031 | mk_pointer(&vtop->type); | ||
| 6032 | vtop->r |= VT_LVAL; | ||
| 6033 | indir(); | ||
| 6034 | } | ||
| 6035 | #endif | ||
| 6030 | } else if (r == VT_CONST && IS_ENUM_VAL(s->type.t)) { | 6036 | } else if (r == VT_CONST && IS_ENUM_VAL(s->type.t)) { |
| 6031 | vtop->c.i = s->enum_val; | 6037 | vtop->c.i = s->enum_val; |
| 6032 | } | 6038 | } |
| @@ -384,47 +384,6 @@ static const char *pe_export_name(TCCState *s1, ElfW(Sym) *sym) · 383 unmodified lines | |||
| 384 | return name; | 384 | return name; |
| 385 | } | 385 | } |
| 386 | 386 | ||
| 387 | static int pe_find_import(TCCState * s1, ElfW(Sym) *sym) | ||
| 388 | { | ||
| 389 | char buffer[200]; | ||
| 390 | const char *s, *p; | ||
| 391 | int sym_index = 0, n = 0; | ||
| 392 | int a, err = 0; | ||
| 393 | |||
| 394 | do { | ||
| 395 | s = pe_export_name(s1, sym); | ||
| 396 | a = 0; | ||
| 397 | if (n) { | ||
| 398 | /* second try: */ | ||
| 399 | if (sym->st_other & ST_PE_STDCALL) { | ||
| 400 | /* try w/0 stdcall deco (windows API convention) */ | ||
| 401 | p = strrchr(s, '@'); | ||
| 402 | if (!p || s[0] != '_') | ||
| 403 | break; | ||
| 404 | strcpy(buffer, s+1)[p-s-1] = 0; | ||
| 405 | } else if (s[0] != '_') { /* try non-ansi function */ | ||
| 406 | buffer[0] = '_', strcpy(buffer + 1, s); | ||
| 407 | } else if (0 == memcmp(s, "__imp_", 6)) { /* mingw 2.0 */ | ||
| 408 | strcpy(buffer, s + 6), a = 1; | ||
| 409 | } else if (0 == memcmp(s, "_imp__", 6)) { /* mingw 3.7 */ | ||
| 410 | strcpy(buffer, s + 6), a = 1; | ||
| 411 | } else { | ||
| 412 | continue; | ||
| 413 | } | ||
| 414 | s = buffer; | ||
| 415 | } | ||
| 416 | sym_index = find_elf_sym(s1->dynsymtab_section, s); | ||
| 417 | // printf("find (%d) %d %s\n", n, sym_index, s); | ||
| 418 | if (sym_index | ||
| 419 | && ELFW(ST_TYPE)(sym->st_info) == STT_OBJECT | ||
| 420 | && 0 == (sym->st_other & ST_PE_IMPORT) | ||
| 421 | && 0 == a | ||
| 422 | ) err = -1, sym_index = 0; | ||
| 423 | } while (0 == sym_index && ++n < 2); | ||
| 424 | return n == 2 ? err : sym_index; | ||
| 425 | } | ||
| 426 | |||
| 427 | /*----------------------------------------------------------------------------*/ | ||
| 428 | 387 | ||
| 429 | static int dynarray_assoc(void **pp, int n, int key) | 388 | static int dynarray_assoc(void **pp, int n, int key) |
| 430 | { | 389 | { |
| @@ -905,12 +864,16 @@ static void pe_build_imports(struct pe_info *pe) · 474 unmodified lines | |||
| 905 | int iat_index = p->symbols[k]->iat_index; | 864 | int iat_index = p->symbols[k]->iat_index; |
| 906 | int sym_index = p->symbols[k]->sym_index; | 865 | int sym_index = p->symbols[k]->sym_index; |
| 907 | ElfW(Sym) *imp_sym = (ElfW(Sym) *)pe->s1->dynsymtab_section->data + sym_index; | 866 | ElfW(Sym) *imp_sym = (ElfW(Sym) *)pe->s1->dynsymtab_section->data + sym_index; |
| 908 | ElfW(Sym) *org_sym = (ElfW(Sym) *)symtab_section->data + iat_index; | ||
| 909 | const char *name = (char*)pe->s1->dynsymtab_section->link->data + imp_sym->st_name; | 867 | const char *name = (char*)pe->s1->dynsymtab_section->link->data + imp_sym->st_name; |
| 910 | int ordinal; | 868 | int ordinal; |
| 911 | 869 | ||
| 912 | org_sym->st_value = thk_ptr; | 870 | /* patch symbol (and possibly its underscored alias) */ |
| 913 | org_sym->st_shndx = pe->thunk->sh_num; | 871 | do { |
| 872 | ElfW(Sym) *esym = (ElfW(Sym) *)symtab_section->data + iat_index; | ||
| 873 | iat_index = esym->st_value; | ||
| 874 | esym->st_value = thk_ptr; | ||
| 875 | esym->st_shndx = pe->thunk->sh_num; | ||
| 876 | } while (iat_index); | ||
| 914 | 877 | ||
| 915 | if (dllref) | 878 | if (dllref) |
| 916 | v = 0, ordinal = imp_sym->st_value; /* ordinal from pe_load_def */ | 879 | v = 0, ordinal = imp_sym->st_value; /* ordinal from pe_load_def */ |
| @@ -1276,34 +1239,9 @@ add_section: · 359 unmodified lines | |||
| 1276 | return 0; | 1239 | return 0; |
| 1277 | } | 1240 | } |
| 1278 | 1241 | ||
| 1279 | /*----------------------------------------------------------------------------*/ | ||
| 1280 | |||
| 1281 | static int pe_isafunc(TCCState *s1, int sym_index) | ||
| 1282 | { | ||
| 1283 | Section *sr = text_section->reloc; | ||
| 1284 | ElfW_Rel *rel, *rel_end; | ||
| 1285 | ElfW(Addr)info = ELFW(R_INFO)(sym_index, R_XXX_FUNCCALL); | ||
| 1286 | #ifdef R_XXX_FUNCCALL2 | ||
| 1287 | ElfW(Addr)info2 = ELFW(R_INFO)(sym_index, R_XXX_FUNCCALL2); | ||
| 1288 | #endif | ||
| 1289 | if (!sr) | ||
| 1290 | return 0; | ||
| 1291 | rel_end = (ElfW_Rel *)(sr->data + sr->data_offset); | ||
| 1292 | for (rel = (ElfW_Rel *)sr->data; rel < rel_end; rel++) { | ||
| 1293 | if (rel->r_info == info) | ||
| 1294 | return 1; | ||
| 1295 | #ifdef R_XXX_FUNCCALL2 | ||
| 1296 | if (rel->r_info == info2) | ||
| 1297 | return 1; | ||
| 1298 | #endif | ||
| 1299 | } | ||
| 1300 | return 0; | ||
| 1301 | } | ||
| 1302 | |||
| 1303 | /*----------------------------------------------------------------------------*/ | 1242 | /*----------------------------------------------------------------------------*/ |
| 1304 | static int pe_check_symbols(struct pe_info *pe) | 1243 | static int pe_check_symbols(struct pe_info *pe) |
| 1305 | { | 1244 | { |
| 1306 | ElfW(Sym) *sym; | ||
| 1307 | int sym_index, sym_end; | 1245 | int sym_index, sym_end; |
| 1308 | int ret = 0; | 1246 | int ret = 0; |
| 1309 | TCCState *s1 = pe->s1; | 1247 | TCCState *s1 = pe->s1; |
| @@ -1312,34 +1250,54 @@ static int pe_check_symbols(struct pe_info *pe) · 2 unmodified lines | |||
| 1312 | 1250 | ||
| 1313 | sym_end = symtab_section->data_offset / sizeof(ElfW(Sym)); | 1251 | sym_end = symtab_section->data_offset / sizeof(ElfW(Sym)); |
| 1314 | for (sym_index = 1; sym_index < sym_end; ++sym_index) { | 1252 | for (sym_index = 1; sym_index < sym_end; ++sym_index) { |
| 1315 | 1253 | ElfW(Sym) *sym = (ElfW(Sym) *)symtab_section->data + sym_index; | |
| 1316 | sym = (ElfW(Sym) *)symtab_section->data + sym_index; | ||
| 1317 | if (sym->st_shndx == SHN_UNDEF) { | 1254 | if (sym->st_shndx == SHN_UNDEF) { |
| 1318 | |||
| 1319 | const char *name = (char*)symtab_section->link->data + sym->st_name; | 1255 | const char *name = (char*)symtab_section->link->data + sym->st_name; |
| 1320 | unsigned type = ELFW(ST_TYPE)(sym->st_info); | 1256 | unsigned type = ELFW(ST_TYPE)(sym->st_info); |
| 1321 | int imp_sym = pe_find_import(pe->s1, sym); | 1257 | int imp_sym; |
| 1322 | struct import_symbol *is; | 1258 | struct import_symbol *is; |
| 1323 | 1259 | ||
| 1324 | if (imp_sym <= 0) | 1260 | int _imp_, n; |
| 1325 | goto not_found; | 1261 | char buffer[200]; |
| 1262 | const char *s, *p; | ||
| 1326 | 1263 | ||
| 1327 | if (type == STT_NOTYPE) { | 1264 | n = _imp_ = 0; |
| 1328 | /* symbols from assembler have no type, find out which */ | 1265 | do { |
| 1329 | if (pe_isafunc(s1, sym_index)) | 1266 | s = pe_export_name(s1, sym); |
| 1330 | type = STT_FUNC; | 1267 | if (n) { |
| 1331 | else | 1268 | /* second try: */ |
| 1332 | type = STT_OBJECT; | 1269 | if (sym->st_other & ST_PE_STDCALL) { |
| 1333 | } | 1270 | /* try w/0 stdcall deco (windows API convention) */ |
| 1271 | p = strrchr(s, '@'); | ||
| 1272 | if (!p || s[0] != '_') | ||
| 1273 | break; | ||
| 1274 | strcpy(buffer, s+1)[p-s-1] = 0, s = buffer; | ||
| 1275 | } else if (s[0] != '_') { /* try non-ansi function */ | ||
| 1276 | buffer[0] = '_', strcpy(buffer + 1, s), s = buffer; | ||
| 1277 | } else if (0 == memcmp(s, "_imp__", 6)) { /* mingw 3.7 */ | ||
| 1278 | s += 6, _imp_ = 1; | ||
| 1279 | } else if (0 == memcmp(s, "__imp_", 6)) { /* mingw 2.0 */ | ||
| 1280 | s += 6, _imp_ = 1; | ||
| 1281 | } else { | ||
| 1282 | break; | ||
| 1283 | } | ||
| 1284 | } | ||
| 1285 | imp_sym = find_elf_sym(s1->dynsymtab_section, s); | ||
| 1286 | } while (0 == imp_sym && ++n < 2); | ||
| 1287 | |||
| 1288 | //printf("pe_find_export (%d) %4x %s\n", n, imp_sym, name); | ||
| 1289 | if (0 == imp_sym) | ||
| 1290 | continue; /* will throw the 'undefined' error in relocate_syms() */ | ||
| 1334 | 1291 | ||
| 1335 | is = pe_add_import(pe, imp_sym); | 1292 | is = pe_add_import(pe, imp_sym); |
| 1336 | 1293 | ||
| 1337 | if (type == STT_FUNC) { | 1294 | if (type == STT_FUNC |
| 1295 | /* symbols from assembler often have no type */ | ||
| 1296 | || type == STT_NOTYPE) { | ||
| 1338 | unsigned offset = is->thk_offset; | 1297 | unsigned offset = is->thk_offset; |
| 1339 | if (offset) { | 1298 | if (offset) { |
| 1340 | /* got aliased symbol, like stricmp and _stricmp */ | 1299 | /* got aliased symbol, like stricmp and _stricmp */ |
| 1341 | } else { | 1300 | } else { |
| 1342 | char buffer[100]; | ||
| 1343 | unsigned char *p; | 1301 | unsigned char *p; |
| 1344 | 1302 | ||
| 1345 | /* add a helper symbol, will be patched later in | 1303 | /* add a helper symbol, will be patched later in |
| @@ -1372,29 +1330,19 @@ static int pe_check_symbols(struct pe_info *pe) · 26 unmodified lines | |||
| 1372 | } | 1330 | } |
| 1373 | /* tcc_realloc might have altered sym's address */ | 1331 | /* tcc_realloc might have altered sym's address */ |
| 1374 | sym = (ElfW(Sym) *)symtab_section->data + sym_index; | 1332 | sym = (ElfW(Sym) *)symtab_section->data + sym_index; |
| 1375 | |||
| 1376 | /* patch the original symbol */ | 1333 | /* patch the original symbol */ |
| 1377 | sym->st_value = offset; | 1334 | sym->st_value = offset; |
| 1378 | sym->st_shndx = text_section->sh_num; | 1335 | sym->st_shndx = text_section->sh_num; |
| 1379 | sym->st_other &= ~ST_PE_EXPORT; /* do not export */ | 1336 | sym->st_other &= ~ST_PE_EXPORT; /* do not export */ |
| 1380 | continue; | ||
| 1381 | } | ||
| 1382 | 1337 | ||
| 1383 | if (type == STT_OBJECT) { /* data, ptr to that should be */ | 1338 | } else { /* STT_OBJECT */ |
| 1384 | if (0 == is->iat_index) { | 1339 | if (0 == _imp_ && 0 == (sym->st_other & ST_PE_IMPORT)) |
| 1385 | /* original symbol will be patched later in pe_build_imports */ | 1340 | ret = tcc_error_noabort("symbol '%s' is missing __declspec(dllimport)", name); |
| 1386 | is->iat_index = sym_index; | 1341 | /* original symbol will be patched later in pe_build_imports */ |
| 1387 | continue; | 1342 | sym->st_value = is->iat_index; /* chain potential alias */ |
| 1388 | } | 1343 | is->iat_index = sym_index; |
| 1389 | } | 1344 | } |
| 1390 | 1345 | ||
| 1391 | not_found: | ||
| 1392 | if (ELFW(ST_BIND)(sym->st_info) == STB_WEAK) | ||
| 1393 | /* STB_WEAK undefined symbols are accepted */ | ||
| 1394 | continue; | ||
| 1395 | ret = tcc_error_noabort("undefined symbol '%s'%s", name, | ||
| 1396 | imp_sym < 0 ? ", missing __declspec(dllimport)?":""); | ||
| 1397 | |||
| 1398 | } else if (pe->s1->rdynamic | 1346 | } else if (pe->s1->rdynamic |
| 1399 | && ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) { | 1347 | && ELFW(ST_BIND)(sym->st_info) != STB_LOCAL) { |
| 1400 | /* if -rdynamic option, then export all non local symbols */ | 1348 | /* if -rdynamic option, then export all non local symbols */ |
| @@ -1544,36 +1492,6 @@ static void pe_print_sections(TCCState *s1, const char *fname) · 143 unmodified lines | |||
| 1544 | #endif | 1492 | #endif |
| 1545 | 1493 | ||
| 1546 | /* ------------------------------------------------------------- */ | 1494 | /* ------------------------------------------------------------- */ |
| 1547 | /* helper function for load/store to insert one more indirection */ | ||
| 1548 | |||
| 1549 | #if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64 | ||
| 1550 | ST_FUNC SValue *pe_getimport(SValue *sv, SValue *v2) | ||
| 1551 | { | ||
| 1552 | int r2; | ||
| 1553 | if ((sv->r & (VT_VALMASK|VT_SYM)) != (VT_CONST|VT_SYM) || (sv->r2 != VT_CONST)) | ||
| 1554 | return sv; | ||
| 1555 | if (!sv->sym->a.dllimport) | ||
| 1556 | return sv; | ||
| 1557 | // printf("import %04x %04x %04x %s\n", sv->type.t, sv->sym->type.t, sv->r, get_tok_str(sv->sym->v, NULL)); | ||
| 1558 | memset(v2, 0, sizeof *v2); | ||
| 1559 | v2->type.t = VT_PTR; | ||
| 1560 | v2->r = VT_CONST | VT_SYM | VT_LVAL; | ||
| 1561 | v2->sym = sv->sym; | ||
| 1562 | |||
| 1563 | r2 = get_reg(RC_INT); | ||
| 1564 | load(r2, v2); | ||
| 1565 | v2->r = r2; | ||
| 1566 | if ((uint32_t)sv->c.i) { | ||
| 1567 | vpushv(v2); | ||
| 1568 | vpushi(sv->c.i); | ||
| 1569 | gen_opi('+'); | ||
| 1570 | *v2 = *vtop--; | ||
| 1571 | } | ||
| 1572 | v2->type.t = sv->type.t; | ||
| 1573 | v2->r |= sv->r & VT_LVAL; | ||
| 1574 | return v2; | ||
| 1575 | } | ||
| 1576 | #endif | ||
| 1577 | 1495 | ||
| 1578 | ST_FUNC int pe_putimport(TCCState *s1, int dllindex, const char *name, addr_t value) | 1496 | ST_FUNC int pe_putimport(TCCState *s1, int dllindex, const char *name, addr_t value) |
| 1579 | { | 1497 | { |
| @@ -1927,15 +1927,18 @@ ST_FUNC void preprocess(int is_bof) · 1926 unmodified lines | |||
| 1927 | tok_flags |= TOK_FLAG_ENDIF; | 1927 | tok_flags |= TOK_FLAG_ENDIF; |
| 1928 | } | 1928 | } |
| 1929 | break; | 1929 | break; |
| 1930 | |||
| 1930 | case TOK_LINE: | 1931 | case TOK_LINE: |
| 1931 | next_nomacro(); | 1932 | next_nomacro(); |
| 1932 | if (tok != TOK_PPNUM) { | 1933 | if (tok != TOK_PPNUM) { |
| 1933 | _line_err: | 1934 | _line_err: |
| 1934 | if (parse_flags & PARSE_FLAG_ASM_FILE) | ||
| 1935 | goto ignore; | ||
| 1936 | tcc_error("wrong #line format"); | 1935 | tcc_error("wrong #line format"); |
| 1937 | } | 1936 | } |
| 1937 | goto _line_num; | ||
| 1938 | case TOK_PPNUM: | 1938 | case TOK_PPNUM: |
| 1939 | if (parse_flags & PARSE_FLAG_ASM_FILE) | ||
| 1940 | goto ignore; | ||
| 1941 | _line_num: | ||
| 1939 | for (n = 0, q = tokc.str.data; *q; ++q) { | 1942 | for (n = 0, q = tokc.str.data; *q; ++q) { |
| 1940 | if (!isnum(*q)) | 1943 | if (!isnum(*q)) |
| 1941 | goto _line_err; | 1944 | goto _line_err; |
| @@ -1948,9 +1951,7 @@ ST_FUNC void preprocess(int is_bof) · 6 unmodified lines | |||
| 1948 | tccpp_putfile(tokc.str.data + 1); | 1951 | tccpp_putfile(tokc.str.data + 1); |
| 1949 | } else | 1952 | } else |
| 1950 | goto _line_err; | 1953 | goto _line_err; |
| 1951 | next_nomacro(); | 1954 | } |
| 1952 | } else if (parse_flags & PARSE_FLAG_ASM_FILE) | ||
| 1953 | goto ignore; | ||
| 1954 | if (file->fd > 0) | 1955 | if (file->fd > 0) |
| 1955 | total_lines += file->line_num - n; | 1956 | total_lines += file->line_num - n; |
| 1956 | file->line_num = n; | 1957 | file->line_num = n; |
| @@ -3586,7 +3587,7 @@ static void putdefs(CString *cs, const char *p) · 1629 unmodified lines | |||
| 3586 | 3587 | ||
| 3587 | static void tcc_predefs(TCCState *s1, CString *cs, int is_asm) | 3588 | static void tcc_predefs(TCCState *s1, CString *cs, int is_asm) |
| 3588 | { | 3589 | { |
| 3589 | cstr_printf(cs, "#define __TINYC__ 9%.2s\n", TCC_VERSION + 4); | 3590 | cstr_printf(cs, "#define __TINYC__ 9%.2s\n", *& TCC_VERSION + 4); |
| 3590 | putdefs(cs, target_machine_defs); | 3591 | putdefs(cs, target_machine_defs); |
| 3591 | putdefs(cs, target_os_defs); | 3592 | putdefs(cs, target_os_defs); |
| 3592 | 3593 | ||
| @@ -105,14 +105,14 @@ static void win64_del_function_table(void *); · 104 unmodified lines | |||
| 105 | #define PAGEALIGN(n) ((addr_t)n + (-(addr_t)n & (PAGESIZE-1))) | 105 | #define PAGEALIGN(n) ((addr_t)n + (-(addr_t)n & (PAGESIZE-1))) |
| 106 | 106 | ||
| 107 | #if !_WIN32 && !__APPLE__ | 107 | #if !_WIN32 && !__APPLE__ |
| 108 | //#define HAVE_SELINUX 1 | 108 | //#define CONFIG_SELINUX 1 |
| 109 | #endif | 109 | #endif |
| 110 | 110 | ||
| 111 | static int rt_mem(TCCState *s1, int size) | 111 | static int rt_mem(TCCState *s1, int size) |
| 112 | { | 112 | { |
| 113 | void *ptr; | 113 | void *ptr; |
| 114 | int ptr_diff = 0; | 114 | int ptr_diff = 0; |
| 115 | #ifdef HAVE_SELINUX | 115 | #ifdef CONFIG_SELINUX |
| 116 | /* Using mmap instead of malloc */ | 116 | /* Using mmap instead of malloc */ |
| 117 | void *prw; | 117 | void *prw; |
| 118 | char tmpfname[] = "/tmp/.tccrunXXXXXX"; | 118 | char tmpfname[] = "/tmp/.tccrunXXXXXX"; |
| @@ -185,7 +185,7 @@ ST_FUNC void tcc_run_free(TCCState *s1) · 66 unmodified lines | |||
| 185 | return; | 185 | return; |
| 186 | st_unlink(s1); | 186 | st_unlink(s1); |
| 187 | size = s1->run_size; | 187 | size = s1->run_size; |
| 188 | #ifdef HAVE_SELINUX | 188 | #ifdef CONFIG_SELINUX |
| 189 | munmap(ptr, size); | 189 | munmap(ptr, size); |
| 190 | #else | 190 | #else |
| 191 | /* unprotect memory to make it usable for malloc again */ | 191 | /* unprotect memory to make it usable for malloc again */ |
| @@ -381,7 +381,7 @@ redo: · 189 unmodified lines | |||
| 381 | if (copy == 2) { /* set permissions */ | 381 | if (copy == 2) { /* set permissions */ |
| 382 | if (n == 0) /* no data */ | 382 | if (n == 0) /* no data */ |
| 383 | continue; | 383 | continue; |
| 384 | #ifdef HAVE_SELINUX | 384 | #ifdef CONFIG_SELINUX |
| 385 | if (k == 0) /* SHF_EXECINSTR has its own mapping */ | 385 | if (k == 0) /* SHF_EXECINSTR has its own mapping */ |
| 386 | continue; | 386 | continue; |
| 387 | #endif | 387 | #endif |
| @@ -4,8 +4,8 @@ · 3 unmodified lines | |||
| 4 | 4 | ||
| 5 | TOP = .. | 5 | TOP = .. |
| 6 | include $(TOP)/Makefile | 6 | include $(TOP)/Makefile |
| 7 | VPATH = $(TOPSRC)/tests $(TOPSRC) $(TOP) | 7 | VPATH = $(TOPSRC)/tests $(TOPSRC) |
| 8 | CFLAGS := $(filter-out -g% -O%,$(CFLAGS)) -I$(TOPSRC) $(LDFLAGS) | 8 | CFLAGS := $(filter-out -g% -O%,$(CFLAGS)) -I$(TOPSRC) -I$(TOP) $(LDFLAGS) |
| 9 | 9 | ||
| 10 | # what tests to run | 10 | # what tests to run |
| 11 | TESTS = \ | 11 | TESTS = \ |
| @@ -69,7 +69,7 @@ ifneq (,$(filter FreeBSD NetBSD,$(TARGETOS))) · 57 unmodified lines | |||
| 69 | TESTS += test1 | 69 | TESTS += test1 |
| 70 | endif | 70 | endif |
| 71 | 71 | ||
| 72 | RUN_TCC = $(NATIVE_DEFINES) -run $(TOPSRC)/tcc.c $(TCCFLAGS) | 72 | RUN_TCC = -run $(TOPSRC)/tcc.c $(TCCFLAGS) |
| 73 | DISAS = objdump -d | 73 | DISAS = objdump -d |
| 74 | ifdef CONFIG_OSX | 74 | ifdef CONFIG_OSX |
| 75 | DUMPTCC = (set -x; $(TOP)/tcc -vv; otool -L $(TOP)/tcc; exit 1) | 75 | DUMPTCC = (set -x; $(TOP)/tcc -vv; otool -L $(TOP)/tcc; exit 1) |
| @@ -95,13 +95,13 @@ hello-run: ../examples/ex1.c · 19 unmodified lines | |||
| 95 | 95 | ||
| 96 | libtes%: libtcc_tes%$(EXESUF) | 96 | libtes%: libtcc_tes%$(EXESUF) |
| 97 | @echo ------------ $@ ------------ | 97 | @echo ------------ $@ ------------ |
| 98 | ./libtcc_tes$*$(EXESUF) $(TOPSRC)/tcc.c $(TCCFLAGS) $(NATIVE_DEFINES) | 98 | ./libtcc_tes$*$(EXESUF) $(TOPSRC)/tcc.c $(TCCFLAGS) |
| 99 | 99 | ||
| 100 | libtcc_test$(EXESUF): libtcc_test.c $(LIBTCC) | 100 | libtcc_test$(EXESUF): libtcc_test.c |
| 101 | $(CC) -o $@ $^ $(CFLAGS) $(LIBS) | 101 | $(CC) -o $@ $< $(CFLAGS) $(-LTCC) $(LIBS) |
| 102 | 102 | ||
| 103 | libtcc_test_mt$(EXESUF): libtcc_test_mt.c $(LIBTCC) | 103 | libtcc_test_mt$(EXESUF): libtcc_test_mt.c |
| 104 | $(CC) -o $@ $^ $(CFLAGS) $(LIBS) | 104 | $(CC) -o $@ $< $(CFLAGS) $(-LTCC) $(LIBS) |
| 105 | 105 | ||
| 106 | %-dir: | 106 | %-dir: |
| 107 | @echo ------------ $@ ------------ | 107 | @echo ------------ $@ ------------ |
| @@ -109,7 +109,7 @@ libtcc_test_mt$(EXESUF): libtcc_test_mt.c $(LIBTCC) · 1 unmodified line | |||
| 109 | 109 | ||
| 110 | # test.ref - generate using cc | 110 | # test.ref - generate using cc |
| 111 | test.ref: tcctest.c | 111 | test.ref: tcctest.c |
| 112 | $(CC) -o tcctest.gcc $< $(NATIVE_DEFINES) $(CFLAGS) -w -O0 -std=gnu99 -fno-omit-frame-pointer | 112 | $(CC) -o tcctest.gcc $< $(CFLAGS) -w -O0 -std=gnu99 -fno-omit-frame-pointer |
| 113 | ./tcctest.gcc > $@ | 113 | ./tcctest.gcc > $@ |
| 114 | 114 | ||
| 115 | # auto test | 115 | # auto test |
| @@ -161,23 +161,23 @@ test4_static: tcctest.c test.ref · 45 unmodified lines | |||
| 161 | # use tcc to create libtcc.so/.dll and the tcc(.exe) frontend and run them | 161 | # use tcc to create libtcc.so/.dll and the tcc(.exe) frontend and run them |
| 162 | dlltest: | 162 | dlltest: |
| 163 | @echo ------------ $@ ------------ | 163 | @echo ------------ $@ ------------ |
| 164 | $(TCC) $(NATIVE_DEFINES) -DLIBTCC_AS_DLL $(TOPSRC)/libtcc.c $(LIBS) -shared -o libtcc2$(DLLSUF) | 164 | $(TCC) -DLIBTCC_AS_DLL $(TOPSRC)/libtcc.c $(LIBS) -shared -o libtcc2$(DLLSUF) |
| 165 | $(TCC) $(NATIVE_DEFINES) -DONE_SOURCE=0 $(TOPSRC)/tcc.c libtcc2$(DLLSUF) $(LIBS) -Wl,-rpath=. -o tcc2$(EXESUF) | 165 | $(TCC) -DONE_SOURCE=0 $(TOPSRC)/tcc.c libtcc2$(DLLSUF) $(LIBS) -Wl,-rpath=. -o tcc2$(EXESUF) |
| 166 | ./tcc2$(EXESUF) $(TCCFLAGS) $(RUN_TCC) -run $(TOPSRC)/examples/ex1.c | 166 | ./tcc2$(EXESUF) $(TCCFLAGS) $(RUN_TCC) -run $(TOPSRC)/examples/ex1.c |
| 167 | ifeq (,$(filter Darwin WIN32,$(TARGETOS))) | 167 | ifeq (,$(filter Darwin WIN32,$(TARGETOS))) |
| 168 | @echo ------------ $@ with PIC ------------ | 168 | @echo ------------ $@ with PIC ------------ |
| 169 | $(CC) $(CFLAGS) -fPIC $(NATIVE_DEFINES) -DLIBTCC_AS_DLL -c $(TOPSRC)/libtcc.c | 169 | $(CC) $(CFLAGS) -fPIC -DLIBTCC_AS_DLL -c $(TOPSRC)/libtcc.c |
| 170 | $(TCC) libtcc.o $(LIBS) -shared -o libtcc2$(DLLSUF) | 170 | $(TCC) libtcc.o $(LIBS) -shared -o libtcc2$(DLLSUF) |
| 171 | $(TCC) $(NATIVE_DEFINES) -DONE_SOURCE=0 $(TOPSRC)/tcc.c libtcc2$(DLLSUF) $(LIBS) -Wl,-rpath=. -o tcc2$(EXESUF) | 171 | $(TCC) -DONE_SOURCE=0 $(TOPSRC)/tcc.c libtcc2$(DLLSUF) $(LIBS) -Wl,-rpath=. -o tcc2$(EXESUF) |
| 172 | ./tcc2$(EXESUF) $(TCCFLAGS) $(RUN_TCC) -run $(TOPSRC)/examples/ex1.c | 172 | ./tcc2$(EXESUF) $(TCCFLAGS) $(RUN_TCC) -run $(TOPSRC)/examples/ex1.c |
| 173 | endif | 173 | endif |
| 174 | @rm tcc2$(EXESUF) libtcc2$(DLLSUF) | 174 | @rm tcc2$(EXESUF) libtcc2$(DLLSUF) |
| 175 | 175 | ||
| 176 | memtest: | 176 | memtest: |
| 177 | @echo ------------ $@ ------------ | 177 | @echo ------------ $@ ------------ |
| 178 | $(CC) $(CFLAGS) $(NATIVE_DEFINES) -DMEM_DEBUG=2 $(TOPSRC)/tcc.c $(LIBS) -o memtest-tcc$(EXESUF) | 178 | $(CC) $(CFLAGS) -DMEM_DEBUG=2 $(TOPSRC)/tcc.c $(LIBS) -o memtest-tcc$(EXESUF) |
| 179 | ./memtest-tcc$(EXESUF) $(TCCFLAGS) $(NATIVE_DEFINES) $(TOPSRC)/tcc.c $(LIBS) | 179 | ./memtest-tcc$(EXESUF) $(TCCFLAGS) $(TOPSRC)/tcc.c $(LIBS) |
| 180 | ./memtest-tcc$(EXESUF) $(TCCFLAGS) $(NATIVE_DEFINES) -run $(TOPSRC)/tcc.c $(TCCFLAGS) -w $(TOPSRC)/tests/tcctest.c | 180 | ./memtest-tcc$(EXESUF) $(TCCFLAGS) -run $(TOPSRC)/tcc.c $(TCCFLAGS) -w $(TOPSRC)/tests/tcctest.c |
| 181 | @echo OK | 181 | @echo OK |
| 182 | 182 | ||
| 183 | # memory and bound check auto test | 183 | # memory and bound check auto test |
| @@ -204,9 +204,9 @@ btest: boundtest.c · 20 unmodified lines | |||
| 204 | 204 | ||
| 205 | tccb: | 205 | tccb: |
| 206 | @echo ------------ $@ ------------ | 206 | @echo ------------ $@ ------------ |
| 207 | $(TCC) -b $(TOPSRC)/tcc.c $(TCCFLAGS) $(NATIVE_DEFINES) -o tccb1.exe | 207 | $(TCC) -b $(TOPSRC)/tcc.c $(TCCFLAGS) -o tccb1.exe |
| 208 | mv tccb1.exe tccb2.exe | 208 | mv tccb1.exe tccb2.exe |
| 209 | ./tccb2.exe -b $(TOPSRC)/tcc.c $(TCCFLAGS) $(NATIVE_DEFINES) -o tccb1.exe | 209 | ./tccb2.exe -b $(TOPSRC)/tcc.c $(TCCFLAGS) -o tccb1.exe |
| 210 | cmp -s tccb1.exe tccb2.exe && echo "Exe Bound-Test OK" | 210 | cmp -s tccb1.exe tccb2.exe && echo "Exe Bound-Test OK" |
| 211 | 211 | ||
| 212 | 212 | ||
| @@ -221,7 +221,7 @@ speedtest: ex2 ex3 · 8 unmodified lines | |||
| 221 | weaktest: tcctest.c test.ref | 221 | weaktest: tcctest.c test.ref |
| 222 | @echo ------------ $@ ------------ | 222 | @echo ------------ $@ ------------ |
| 223 | $(TCC) -c $< -o weaktest.tcc.o | 223 | $(TCC) -c $< -o weaktest.tcc.o |
| 224 | $(CC) -c $< -o weaktest.gcc.o $(NATIVE_DEFINES) $(CFLAGS) -w -O0 -std=gnu99 -fno-omit-frame-pointer | 224 | $(CC) -c $< -o weaktest.gcc.o $(CFLAGS) -w -O0 -std=gnu99 -fno-omit-frame-pointer |
| 225 | objdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.tcc.o.txt | 225 | objdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.tcc.o.txt |
| 226 | objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt | 226 | objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt |
| 227 | diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK" | 227 | diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK" |
| @@ -250,11 +250,11 @@ asmtest2: MAYBE_RUN_TCC = $(RUN_TCC) · 22 unmodified lines | |||
| 250 | 250 | ||
| 251 | # Check that code generated by libtcc is binary compatible with | 251 | # Check that code generated by libtcc is binary compatible with |
| 252 | # that generated by CC | 252 | # that generated by CC |
| 253 | abitest-cc.exe: abitest.c $(LIBTCC) | 253 | abitest-cc.exe: abitest.c |
| 254 | $(CC) -o $@ $^ $(CFLAGS) $(LIBS) -w | 254 | $(CC) -o $@ $^ $(CFLAGS) $(-LTCC) $(LIBS) -w |
| 255 | 255 | ||
| 256 | abitest-tcc.exe: abitest.c libtcc.c | 256 | abitest-tcc.exe: abitest.c libtcc.c |
| 257 | $(TCC) -o $@ $^ $(NATIVE_DEFINES) $(LIBS) | 257 | $(TCC) -o $@ $^ $(LIBS) |
| 258 | 258 | ||
| 259 | abitest-% : abitest-%.exe | 259 | abitest-% : abitest-%.exe |
| 260 | @echo ------------ $@ ------------ | 260 | @echo ------------ $@ ------------ |
| @@ -318,7 +318,7 @@ CROSS-TGTS = \ · 57 unmodified lines | |||
| 318 | 318 | ||
| 319 | define CROSS-COMPILE | 319 | define CROSS-COMPILE |
| 320 | @echo " . $(1)" | 320 | @echo " . $(1)" |
| 321 | $(TCC) $(DEF-$1) -DTCC_CROSS_TEST -run $(TOPSRC)/tcc.c \ | 321 | $(TCC) $(DEF-$1) -DCONFIG_TCC_CROSS -DTCC_CROSS_TEST -run $(TOPSRC)/tcc.c \ |
| 322 | -c $(if $(findstring c67,$1),$(filter %/ex3.c,$^),$<) -w $(TCCFLAGS) | 322 | -c $(if $(findstring c67,$1),$(filter %/ex3.c,$^),$<) -w $(TCCFLAGS) |
| 323 | 323 | ||
| 324 | endef | 324 | endef |
| @@ -364,11 +364,6 @@ void load(int r, SValue *sv) · 363 unmodified lines | |||
| 364 | int v, t, ft, fc, fr; | 364 | int v, t, ft, fc, fr; |
| 365 | SValue v1; | 365 | SValue v1; |
| 366 | 366 | ||
| 367 | #ifdef TCC_TARGET_PE | ||
| 368 | SValue v2; | ||
| 369 | sv = pe_getimport(sv, &v2); | ||
| 370 | #endif | ||
| 371 | |||
| 372 | fr = sv->r; | 367 | fr = sv->r; |
| 373 | ft = sv->type.t & ~VT_DEFSIGN; | 368 | ft = sv->type.t & ~VT_DEFSIGN; |
| 374 | fc = sv->c.i; | 369 | fc = sv->c.i; |
| @@ -573,11 +568,6 @@ void store(int r, SValue *v) · 198 unmodified lines | |||
| 573 | /* store the REX prefix in this variable when PIC is enabled */ | 568 | /* store the REX prefix in this variable when PIC is enabled */ |
| 574 | int pic = 0; | 569 | int pic = 0; |
| 575 | 570 | ||
| 576 | #ifdef TCC_TARGET_PE | ||
| 577 | SValue v2; | ||
| 578 | v = pe_getimport(v, &v2); | ||
| 579 | #endif | ||
| 580 | |||
| 581 | fr = v->r & VT_VALMASK; | 571 | fr = v->r & VT_VALMASK; |
| 582 | ft = v->type.t; | 572 | ft = v->type.t; |
| 583 | fc = v->c.i; | 573 | fc = v->c.i; |