History

configure & tcc.h: include & lib searchpath cleanup

configure: - remove CONFIG_USE_LIBGCC, --with-libgcc - remove CONFIG_LDDIR - remove CONFIG_USR_INCLUDE - add -q switch for quiet (=no) output tcc.h: - remove /usr/local/include&lib search paths arm-gen.c: - remove default_elfinterp() function tccelf.c: - setup the ELF-interp in tccelf_new()

grischka committed 9 months ago

Commit 6daf1611 parent 923fba88 files · +97 −122Browse files

Unified · Split

8 files
  1. Makefile +28 −32
  2. arm-gen.c +3 −17
  3. arm-link.c +0 −5
  4. configure +11 −12
  5. libtcc.c +24 −16
  6. tcc.c +1 −1
  7. tcc.h +14 −30
  8. tccelf.c +16 −9
Makefile+28−32
@@ -158,10 +158,27 @@ all : cross · 157 unmodified lines
158endif158endif
159 159
160# --------------------------------------------160# --------------------------------------------
161 161T = $(or $(CROSS_TARGET),$(NATIVE_TARGET))
162T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown)
163X = $(if $(CROSS_TARGET),$(CROSS_TARGET)-)162X = $(if $(CROSS_TARGET),$(CROSS_TARGET)-)
164 163
164ifneq ($(T),$(NATIVE_TARGET))
165$(if $(DEF-$T),,$(error error: unknown target: '$T'))
166ifneq ($(CONFIG_WIN32),yes)
167DEF-win = -DCONFIG_TCCDIR="\"$(tccdir)/win32\""
168endif
169# some default config for cross compilers
170TRIPLET-i386 = i686-linux-gnu
171TRIPLET-x86_64 = x86_64-linux-gnu
172TRIPLET-arm = arm-linux-gnueabihf
173TRIPLET-arm64 = aarch64-linux-gnu
174TRIPLET-riscv64 = riscv64-linux-gnu
175ifneq ($(TRIPLET-$T),)
176# assume support files in "/usr/<triplet>"
177ROOT-$T = /usr/$(TRIPLET-$T)
178INC-$T = {B}/include:{R}/include
179LIB-$T = {R}/lib:{B}
180CRT-$T = {R}/lib
181endif
165DEFINES += $(DEF-$T)182DEFINES += $(DEF-$T)
166DEFINES += $(if $(ROOT-$T),-DCONFIG_SYSROOT="\"$(ROOT-$T)\"")183DEFINES += $(if $(ROOT-$T),-DCONFIG_SYSROOT="\"$(ROOT-$T)\"")
167DEFINES += $(if $(CRT-$T),-DCONFIG_TCC_CRTPREFIX="\"$(CRT-$T)\"")184DEFINES += $(if $(CRT-$T),-DCONFIG_TCC_CRTPREFIX="\"$(CRT-$T)\"")
@@ -169,36 +186,17 @@ DEFINES += $(if $(LIB-$T),-DCONFIG_TCC_LIBPATHS="\"$(LIB-$T)\"") · 1 unmodified line
169DEFINES += $(if $(INC-$T),-DCONFIG_TCC_SYSINCLUDEPATHS="\"$(INC-$T)\"")186DEFINES += $(if $(INC-$T),-DCONFIG_TCC_SYSINCLUDEPATHS="\"$(INC-$T)\"")
170DEFINES += $(if $(ELF-$T),-DCONFIG_TCC_ELFINTERP="\"$(ELF-$T)\"")187DEFINES += $(if $(ELF-$T),-DCONFIG_TCC_ELFINTERP="\"$(ELF-$T)\"")
171DEFINES += $(DEF-$(or $(findstring win,$T),unx))188DEFINES += $(DEF-$(or $(findstring win,$T),unx))
172 189DEFINES += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
173ifneq ($(X),)
174$(if $(DEF-$T),,$(error error: unknown target: '$T'))
175DEF-$(NATIVE_TARGET) =
176DEF-$T += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
177ifneq ($(CONFIG_WIN32),yes)
178DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\""
179endif
180else
181# using values from config.h
182DEF-$(NATIVE_TARGET) =
183endif190endif
184 191
185# include custom configuration (see make help)192# include custom configuration (see make help)
186-include config-extra.mak193-include config-extra.mak
187 194
188ifneq ($(T),$(NATIVE_TARGET))195# so one can use: make EXTRA-DEFS=...
189# assume support files for cross-targets in "/usr/<triplet>" by default196DEFINES += $(EXTRA-DEFS)
190TRIPLET-i386 ?= i686-linux-gnu197
191TRIPLET-x86_64 ?= x86_64-linux-gnu198# find config.h with 'out of tree' builds
192TRIPLET-arm ?= arm-linux-gnueabi199DEFINES += -I$(TOP)
193TRIPLET-arm64 ?= aarch64-linux-gnu
194TRIPLET-riscv64 ?= riscv64-linux-gnu
195MARCH-i386 ?= i386-linux-gnu
196MARCH-$T ?= $(TRIPLET-$T)
197TR = $(if $(TRIPLET-$T),$T,ignored)
198CRT-$(TR) ?= /usr/$(TRIPLET-$T)/lib
199LIB-$(TR) ?= {B}:/usr/$(TRIPLET-$T)/lib:/usr/lib/$(MARCH-$T)
200INC-$(TR) ?= {B}/include:/usr/$(TRIPLET-$T)/include:/usr/include
201endif
202 200
203CORE_FILES = tcc.c tcctools.c libtcc.c tccpp.c tccgen.c tccdbg.c tccelf.c tccasm.c tccrun.c201CORE_FILES = tcc.c tcctools.c libtcc.c tccpp.c tccgen.c tccdbg.c tccelf.c tccasm.c tccrun.c
204CORE_FILES += tcc.h config.h libtcc.h tcctok.h202CORE_FILES += tcc.h config.h libtcc.h tcctok.h
@@ -209,7 +207,6 @@ x86_64-win32_FILES = $(x86_64_FILES) tccpe.c · 4 unmodified lines
209x86_64-osx_FILES = $(x86_64_FILES) tccmacho.c207x86_64-osx_FILES = $(x86_64_FILES) tccmacho.c
210arm_FILES = $(CORE_FILES) arm-gen.c arm-link.c arm-asm.c arm-tok.h208arm_FILES = $(CORE_FILES) arm-gen.c arm-link.c arm-asm.c arm-tok.h
211arm-wince_FILES = $(arm_FILES) tccpe.c209arm-wince_FILES = $(arm_FILES) tccpe.c
212arm-eabihf_FILES = $(arm_FILES)
213arm-fpa_FILES = $(arm_FILES)210arm-fpa_FILES = $(arm_FILES)
214arm-fpa-ld_FILES = $(arm_FILES)211arm-fpa-ld_FILES = $(arm_FILES)
215arm-vfp_FILES = $(arm_FILES)212arm-vfp_FILES = $(arm_FILES)
@@ -241,7 +238,6 @@ $(CROSS_TARGET)-tcc.o : DEFINES += -DONE_SOURCE=0 · 25 unmodified lines
241endif238endif
242# native tcc always made from tcc.o and libtcc.[so|a]239# native tcc always made from tcc.o and libtcc.[so|a]
243tcc.o : DEFINES += -DONE_SOURCE=0240tcc.o : DEFINES += -DONE_SOURCE=0
244DEFINES += -I$(TOP)
245 241
246GITHASH:=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo no)242GITHASH:=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo no)
247ifneq ($(GITHASH),no)243ifneq ($(GITHASH),no)
@@ -340,7 +336,7 @@ FORCE: · 92 unmodified lines
340# some versions of gnu-make do not recognize 'command' as a shell builtin336# some versions of gnu-make do not recognize 'command' as a shell builtin
341WHICH = sh -c 'command -v $1'337WHICH = sh -c 'command -v $1'
342 338
343run-if = $(if $(shell $(call WHICH,$1)),$S $1 $2)339run-if = $(if $(shell $(call WHICH,$1)),$S $1 $2,@echo "(skipping $@ - no $1)")
344S = $(if $(findstring yes,$(SILENT)),@$(info * $@))340S = $(if $(findstring yes,$(SILENT)),@$(info * $@))
345 341
346# --------------------------------------------------------------------------342# --------------------------------------------------------------------------
@@ -501,14 +497,14 @@ distclean: clean · 154 unmodified lines
501help:497help:
502 @echo "make"498 @echo "make"
503 @echo " build native compiler (from separate objects)"499 @echo " build native compiler (from separate objects)"
504 @echo "make cross"
505 @echo " build cross compilers (from one source)"
506 @echo "make ONE_SOURCE=no/yes SILENT=no/yes"500 @echo "make ONE_SOURCE=no/yes SILENT=no/yes"
507 @echo " force building from separate/one object(s), less/more silently"501 @echo " force building from separate/one object(s), less/more silently"
508 @echo "make cross-TARGET"502 @echo "make cross-TARGET"
509 @echo " build one specific cross compiler for 'TARGET'. Currently supported:"503 @echo " build one specific cross compiler for 'TARGET'. Currently supported:"
510 @echo " $(wordlist 1,8,$(TCC_X))"504 @echo " $(wordlist 1,8,$(TCC_X))"
511 @echo " $(wordlist 9,99,$(TCC_X))"505 @echo " $(wordlist 9,99,$(TCC_X))"
506 @echo "make cross"
507 @echo " build all cross compilers"
512 @echo "make test"508 @echo "make test"
513 @echo " run all tests"509 @echo " run all tests"
514 @echo "make tests2.all / make tests2.37 / make tests2.37+"510 @echo "make tests2.all / make tests2.37 / make tests2.37+"
arm-gen.c+3−17
@@ -133,11 +133,8 @@ enum { · 132 unmodified lines
133 133
134#define CHAR_IS_UNSIGNED134#define CHAR_IS_UNSIGNED
135 135
136#ifdef TCC_ARM_HARDFLOAT136#define ARM_SOFTFP_FLOAT 0
137# define ARM_FLOAT_ABI ARM_HARD_FLOAT137#define ARM_HARD_FLOAT 1
138#else
139# define ARM_FLOAT_ABI ARM_SOFTFP_FLOAT
140#endif
141 138
142/******************************************************/139/******************************************************/
143#else /* ! TARGET_DEFS_ONLY */140#else /* ! TARGET_DEFS_ONLY */
@@ -160,8 +157,6 @@ ST_DATA const char * const target_machine_defs = · 16 unmodified lines
160#endif157#endif
161 ;158 ;
162 159
163enum float_abi float_abi;
164
165ST_DATA const int reg_classes[NB_REGS] = {160ST_DATA const int reg_classes[NB_REGS] = {
166 /* r0 */ RC_INT | RC_R0,161 /* r0 */ RC_INT | RC_R0,
167 /* r1 */ RC_INT | RC_R1,162 /* r1 */ RC_INT | RC_R1,
@@ -180,6 +175,7 @@ ST_DATA const int reg_classes[NB_REGS] = { · 12 unmodified lines
180#endif175#endif
181};176};
182 177
178static int float_abi;
183static int func_sub_sp_offset, last_itod_magic;179static int func_sub_sp_offset, last_itod_magic;
184static int leaffunc;180static int leaffunc;
185 181
@@ -241,16 +237,6 @@ static int regmask(int r) { · 55 unmodified lines
241 237
242/******************************************************/238/******************************************************/
243 239
244#if defined(TCC_ARM_EABI) && !defined(CONFIG_TCC_ELFINTERP)
245const char *default_elfinterp(struct TCCState *s)
246{
247 if (s->float_abi == ARM_HARD_FLOAT)
248 return "/lib/ld-linux-armhf.so.3";
249 else
250 return "/lib/ld-linux.so.3";
251}
252#endif
253
254void o(uint32_t i)240void o(uint32_t i)
255{241{
256 /* this is a good place to start adding big-endian support*/242 /* this is a good place to start adding big-endian support*/
arm-link.c+0−5
@@ -18,11 +18,6 @@ · 17 unmodified lines
18#define PCRELATIVE_DLLPLT 118#define PCRELATIVE_DLLPLT 1
19#define RELOCATE_DLLPLT 119#define RELOCATE_DLLPLT 1
20 20
21enum float_abi {
22 ARM_SOFTFP_FLOAT,
23 ARM_HARD_FLOAT,
24};
25
26#else /* !TARGET_DEFS_ONLY */21#else /* !TARGET_DEFS_ONLY */
27 22
28#include "tcc.h"23#include "tcc.h"
configure+11−12
@@ -35,13 +35,11 @@ mingw32="no" · 34 unmodified lines
35LIBSUF=".a"35LIBSUF=".a"
36EXESUF=""36EXESUF=""
37DLLSUF=".so"37DLLSUF=".so"
38tcc_usrinclude=""
39tcc_sysincludepaths=""38tcc_sysincludepaths=""
40tcc_libpaths=""39tcc_libpaths=""
41tcc_crtprefix=""40tcc_crtprefix=""
42tcc_elfinterp=""41tcc_elfinterp=""
43triplet=42triplet=
44tcc_lddir=
45confvars=43confvars=
46suggest="yes"44suggest="yes"
47gcc_major=045gcc_major=0
@@ -53,6 +51,7 @@ cpuver= · 5 unmodified lines
53dwarf=51dwarf=
54targetos=52targetos=
55build_cross=53build_cross=
54quiet=
56 55
57# use CC/AR from environment when set56# use CC/AR from environment when set
58test -n "$CC" && cc="$CC"57test -n "$CC" && cc="$CC"
@@ -160,8 +159,6 @@ for opt do · 101 unmodified lines
160 ;;159 ;;
161 --debug) confvars_set debug160 --debug) confvars_set debug
162 ;;161 ;;
163 --with-libgcc) confvars_set libgcc
164 ;;
165 --with-selinux) confvars_set selinux162 --with-selinux) confvars_set selinux
166 ;;163 ;;
167 --tcc-switches=*) assign_opt "$opt" tcc_switches164 --tcc-switches=*) assign_opt "$opt" tcc_switches
@@ -174,6 +171,8 @@ for opt do · 6 unmodified lines
174 ;;171 ;;
175 --help|-h) show_help="yes"172 --help|-h) show_help="yes"
176 ;;173 ;;
174 -q) quiet=yes
175 ;;
177 *) echo "configure: WARNING: unrecognized option $opt"176 *) echo "configure: WARNING: unrecognized option $opt"
178 ;;177 ;;
179 esac178 esac
@@ -197,6 +196,7 @@ Standard options: · 17 unmodified lines
197 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]196 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
198 --mandir=DIR man documentation in DIR [SHAREDIR/man]197 --mandir=DIR man documentation in DIR [SHAREDIR/man]
199 --infodir=DIR info documentation in DIR [SHAREDIR/info]198 --infodir=DIR info documentation in DIR [SHAREDIR/info]
199 -q be quiet
200 200
201Advanced options (experts only):201Advanced options (experts only):
202 --source-path=PATH path of source code [$source_path]202 --source-path=PATH path of source code [$source_path]
@@ -210,9 +210,8 @@ Advanced options (experts only): · 7 unmodified lines
210 --disable-static make libtcc.so instead of libtcc.a210 --disable-static make libtcc.so instead of libtcc.a
211 --enable-static make libtcc.a instead of libtcc.dll (win32)211 --enable-static make libtcc.a instead of libtcc.dll (win32)
212 --disable-rpath disable use of -rpath with libtcc.so212 --disable-rpath disable use of -rpath with libtcc.so
213 --with-libgcc use libgcc_s.so.1 instead of libtcc1.a
214 --with-selinux use mmap for executable memory (tcc -run)213 --with-selinux use mmap for executable memory (tcc -run)
215 --enable-cross build cross compilers (see also 'make help')214 --enable-cross build all cross compilers (see also 'make help')
216 215
217 --sysincludepaths=... specify system include paths, colon separated216 --sysincludepaths=... specify system include paths, colon separated
218 --libpaths=... specify system library paths, colon separated217 --libpaths=... specify system library paths, colon separated
@@ -367,6 +366,7 @@ case $targetos in · 148 unmodified lines
367 cc=`command -v cc`366 cc=`command -v cc`
368 cc=`readlink $cc || echo clang`367 cc=`readlink $cc || echo clang`
369 tcc_usrinclude="`xcrun --show-sdk-path`/usr/include"368 tcc_usrinclude="`xcrun --show-sdk-path`/usr/include"
369 default tcc_sysincludepaths "{B}/include:$tcc_usrinclude"
370 if test "${confvars%new_macho*}" = "${confvars}"; then370 if test "${confvars%new_macho*}" = "${confvars}"; then
371 # if new_macho was not specified and (known) ver <= 10, use old (=no)371 # if new_macho was not specified and (known) ver <= 10, use old (=no)
372 osxver=$(sw_vers -productVersion 2>/dev/null) # X.Y.Z372 osxver=$(sw_vers -productVersion 2>/dev/null) # X.Y.Z
@@ -478,7 +478,8 @@ if test -z "$build_cross"; then · 105 unmodified lines
478 if test -z "$triplet"; then478 if test -z "$triplet"; then
479 case $cpu in x86_64|arm64|riscv64)479 case $cpu in x86_64|arm64|riscv64)
480 if test -f "/usr/lib64/crti.o" ; then480 if test -f "/usr/lib64/crti.o" ; then
481 tcc_lddir="lib64"481 default tcc_libpaths "{B}:/usr/lib64"
482 default tcc_crtprefix "/usr/lib64"
482 fi483 fi
483 esac484 esac
484 fi485 fi
@@ -552,6 +553,7 @@ fi · 67 unmodified lines
552 553
553fcho() { if test -n "$2"; then echo "$1$2"; fi }554fcho() { if test -n "$2"; then echo "$1$2"; fi }
554 555
556if test -z "$quiet"; then
555fcho "Binary directory " "$bindir"557fcho "Binary directory " "$bindir"
556fcho "TinyCC directory " "$tccdir"558fcho "TinyCC directory " "$tccdir"
557fcho "Library directory " "$libdir"559fcho "Library directory " "$libdir"
@@ -560,7 +562,6 @@ fcho "Manual directory " "$mandir" · 2 unmodified lines
560fcho "Info directory " "$infodir"562fcho "Info directory " "$infodir"
561fcho "Doc directory " "$docdir"563fcho "Doc directory " "$docdir"
562fcho "Target root prefix " "$sysroot"564fcho "Target root prefix " "$sysroot"
563fcho "/usr/include dir " "$tcc_usrinclude"
564echo "Source path $source_path"565echo "Source path $source_path"
565echo "Build OS $(uname -m -s)"566echo "Build OS $(uname -m -s)"
566echo "C compiler $cc ($gcc_major.$gcc_minor)"567echo "C compiler $cc ($gcc_major.$gcc_minor)"
@@ -574,6 +575,7 @@ fcho "Elfinterp " "$tcc_elfinterp" · 7 unmodified lines
574fcho "Switches " "$tcc_switches"575fcho "Switches " "$tcc_switches"
575fcho "Config " "${confvars# }"576fcho "Config " "${confvars# }"
576echo "Creating config.mak and config.h"577echo "Creating config.mak and config.h"
578fi
577 579
578version=$(head "$source_path/VERSION")580version=$(head "$source_path/VERSION")
579 581
@@ -691,7 +693,6 @@ for v in $cpu $confvars ; do · 111 unmodified lines
691 esac693 esac
692 ;;694 ;;
693 # other695 # other
694 CONFIG_libgcc=yes) print_num CONFIG_USE_LIBGCC 1 ;;
695 CONFIG_selinux=yes) print_num CONFIG_SELINUX 1 ;;696 CONFIG_selinux=yes) print_num CONFIG_SELINUX 1 ;;
696 CONFIG_pie=yes) print_num CONFIG_TCC_PIE 1 ;;697 CONFIG_pie=yes) print_num CONFIG_TCC_PIE 1 ;;
697 CONFIG_pic=yes) print_num CONFIG_TCC_PIC 1 ;;698 CONFIG_pic=yes) print_num CONFIG_TCC_PIC 1 ;;
@@ -706,13 +707,11 @@ for v in $cpu $confvars ; do · 8 unmodified lines
706 esac707 esac
707done708done
708 709
709print_str CONFIG_USR_INCLUDE "$tcc_usrinclude"
710print_str CONFIG_TCC_SYSINCLUDEPATHS "$tcc_sysincludepaths"710print_str CONFIG_TCC_SYSINCLUDEPATHS "$tcc_sysincludepaths"
711print_str CONFIG_TCC_LIBPATHS "$tcc_libpaths"711print_str CONFIG_TCC_LIBPATHS "$tcc_libpaths"
712print_str CONFIG_TCC_CRTPREFIX "$tcc_crtprefix"712print_str CONFIG_TCC_CRTPREFIX "$tcc_crtprefix"
713print_str CONFIG_TCC_ELFINTERP "$tcc_elfinterp"713print_str CONFIG_TCC_ELFINTERP "$tcc_elfinterp"
714print_str CONFIG_TCC_SWITCHES "$tcc_switches"714print_str CONFIG_TCC_SWITCHES "$tcc_switches"
715print_str CONFIG_LDDIR "$tcc_lddir"
716print_str CONFIG_TRIPLET "$triplet"715print_str CONFIG_TRIPLET "$triplet"
717print_str CONFIG_OS_RELEASE "$os_release"716print_str CONFIG_OS_RELEASE "$os_release"
718echo "#endif" >> $TMPH && echo >> $TMPH717echo "#endif" >> $TMPH && echo >> $TMPH
@@ -724,7 +723,7 @@ print_num CONFIG_TCC_PREDEFS "$predefs" · 5 unmodified lines
724diff $TMPH config.h >/dev/null 2>&1723diff $TMPH config.h >/dev/null 2>&1
725if test $? -ne 0 ; then724if test $? -ne 0 ; then
726 mv -f $TMPH config.h725 mv -f $TMPH config.h
727else726elif test -z "$quiet"; then
728 echo "config.h is unchanged"727 echo "config.h is unchanged"
729fi728fi
730 729
libtcc.c+24−16
@@ -896,8 +896,8 @@ LIBTCCAPI TCCState *tcc_new(void) · 895 unmodified lines
896#if defined TCC_TARGET_MACHO /* || defined TCC_TARGET_PE */896#if defined TCC_TARGET_MACHO /* || defined TCC_TARGET_PE */
897 s->leading_underscore = 1;897 s->leading_underscore = 1;
898#endif898#endif
899#ifdef TCC_TARGET_ARM899#ifdef TCC_ARM_HARDFLOAT
900 s->float_abi = ARM_FLOAT_ABI;900 s->float_abi = ARM_HARD_FLOAT;
901#endif901#endif
902#ifdef CONFIG_NEW_DTAGS902#ifdef CONFIG_NEW_DTAGS
903 s->enable_new_dtags = 1;903 s->enable_new_dtags = 1;
@@ -995,10 +995,12 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type) · 91 unmodified lines
995 /* allow linking with system dll's directly */995 /* allow linking with system dll's directly */
996 tcc_add_systemdir(s);996 tcc_add_systemdir(s);
997# endif997# endif
998
998#elif defined TCC_TARGET_MACHO999#elif defined TCC_TARGET_MACHO
999# ifdef TCC_IS_NATIVE1000# ifdef TCC_IS_NATIVE
1000 tcc_add_macos_sdkpath(s);1001 tcc_add_macos_sdkpath(s);
1001# endif1002# endif
1003
1002#else1004#else
1003 /* paths for crt objects */1005 /* paths for crt objects */
1004 tcc_split_path(s, &s->crt_paths, &s->nb_crt_paths, CONFIG_TCC_CRTPREFIX);1006 tcc_split_path(s, &s->crt_paths, &s->nb_crt_paths, CONFIG_TCC_CRTPREFIX);
@@ -1362,10 +1364,11 @@ struct lopt { · 357 unmodified lines
1362/* match linker option */1364/* match linker option */
1363static int link_option(struct lopt *o, const char *q)1365static int link_option(struct lopt *o, const char *q)
1364{1366{
1365 const char *p = o->opt;1367 const char *p;
1366 int c;1368 int c;
1367 1369redo:
1368 /* there should be 1 or 2 dashes */1370 /* there should be 1 or 2 dashes */
1371 p = o->opt;
1369 if (*p++ != '-')1372 if (*p++ != '-')
1370 return 0;1373 return 0;
1371 if (*p == '-')1374 if (*p == '-')
@@ -1378,16 +1381,22 @@ static int link_option(struct lopt *o, const char *q) · 6 unmodified lines
1378 goto succ; /* -Wl,-opt=arg */1381 goto succ; /* -Wl,-opt=arg */
1379 ++q;1382 ++q;
1380 }1383 }
1381 if (c == '=' || c == ':') {1384 if (*p == '\0') {
1382 if (*p == '\0') {1385 if (c == '|')
1386 goto succ;
1387 if (c == '=' || c == ':') {
1383 if (o->s->link_optind + 1 < o->s->link_argc) {1388 if (o->s->link_optind + 1 < o->s->link_argc) {
1384 p = o->s->link_argv[++o->s->link_optind];1389 p = o->s->link_argv[++o->s->link_optind];
1385 goto succ; /* -Wl,-opt,arg */1390 goto succ; /* -Wl,-opt,arg */
1386 }1391 }
1387 o->match = 1; /* -Wl,-opt -Wl,arg */1392 o->match = 1; /* -Wl,-opt -Wl,arg */
1388 } else if (c == ':')1393 return 0;
1389 goto succ; /* -Wl,-Iarg */1394 }
1390 }1395 } else if (c == ':')
1396 goto succ; /* -Wl,-Iarg */
1397 while (*q)
1398 if (*q++ == '|')
1399 goto redo;
1391 return 0;1400 return 0;
1392succ:1401succ:
1393 o->arg = p;1402 o->arg = p;
@@ -1415,9 +1424,9 @@ static int tcc_set_linker(TCCState *s, const char *optarg) · 21 unmodified lines
1415 s->symbolic = 1;1424 s->symbolic = 1;
1416 } else if (link_option(&o, "nostdlib")) {1425 } else if (link_option(&o, "nostdlib")) {
1417 s->nostdlib_paths = 1;1426 s->nostdlib_paths = 1;
1418 } else if (link_option(&o, "e=") || link_option(&o, "entry=")) {1427 } else if (link_option(&o, "e=|entry=")) {
1419 tcc_set_str(&s->elf_entryname, o.arg);1428 tcc_set_str(&s->elf_entryname, o.arg);
1420 } else if (link_option(&o, "image-base=") || link_option(&o, "Ttext=")) {1429 } else if (link_option(&o, "image-base=|Ttext=")) {
1421 s->text_addr = strtoull(o.arg, &end, 16);1430 s->text_addr = strtoull(o.arg, &end, 16);
1422 s->has_text_addr = 1;1431 s->has_text_addr = 1;
1423 } else if (link_option(&o, "init=")) {1432 } else if (link_option(&o, "init=")) {
@@ -1446,18 +1455,17 @@ static int tcc_set_linker(TCCState *s, const char *optarg) · 22 unmodified lines
1446#endif1455#endif
1447 else1456 else
1448 goto err;1457 goto err;
1449 } else if (link_option(&o, "export-all-symbols")1458 } else if (link_option(&o, "export-all-symbols|export-dynamic|E")) {
1450 || link_option(&o, "export-dynamic")) {
1451 s->rdynamic = 1;1459 s->rdynamic = 1;
1452 } else if (link_option(&o, "rpath=")) {1460 } else if (link_option(&o, "rpath=")) {
1453 tcc_concat_str(&s->rpath, o.arg, ':');1461 tcc_concat_str(&s->rpath, o.arg, ':');
1454 } else if (link_option(&o, "dynamic-linker=") || link_option(&o, "I:")) {1462 } else if (link_option(&o, "dynamic-linker=|I:")) {
1455 tcc_set_str(&s->elfint, o.arg);1463 tcc_set_str(&s->elfint, o.arg);
1456 } else if (link_option(&o, "enable-new-dtags")) {1464 } else if (link_option(&o, "enable-new-dtags")) {
1457 s->enable_new_dtags = 1;1465 s->enable_new_dtags = 1;
1458 } else if (link_option(&o, "section-alignment=")) {1466 } else if (link_option(&o, "section-alignment=")) {
1459 s->section_align = strtoul(o.arg, &end, 16);1467 s->section_align = strtoul(o.arg, &end, 16);
1460 } else if (link_option(&o, "soname=") || link_option(&o, "install_name=")) {1468 } else if (link_option(&o, "soname=|install_name=")) {
1461 tcc_set_str(&s->soname, o.arg);1469 tcc_set_str(&s->soname, o.arg);
1462 } else if (link_option(&o, "whole-archive")) {1470 } else if (link_option(&o, "whole-archive")) {
1463 s->filetype |= AFF_WHOLE_ARCHIVE;1471 s->filetype |= AFF_WHOLE_ARCHIVE;
@@ -2024,7 +2032,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int *pargc, char ***pargv) · 560 unmodified lines
2024 s->float_abi = ARM_HARD_FLOAT;2032 s->float_abi = ARM_HARD_FLOAT;
2025 else2033 else
2026 return tcc_error_noabort("unsupported float abi '%s'", optarg);2034 return tcc_error_noabort("unsupported float abi '%s'", optarg);
2027 break;2035 continue;
2028#endif2036#endif
2029 case TCC_OPTION_m:2037 case TCC_OPTION_m:
2030 if (set_flag(s, options_m, optarg) < 0) {2038 if (set_flag(s, options_m, optarg) < 0) {
tcc.c+1−1
@@ -226,7 +226,7 @@ static void print_search_dirs(TCCState *s) · 225 unmodified lines
226 printf("libtcc1:\n %s/%s\n", s->library_paths[0], CONFIG_TCC_CROSSPREFIX TCC_LIBTCC1);226 printf("libtcc1:\n %s/%s\n", s->library_paths[0], CONFIG_TCC_CROSSPREFIX TCC_LIBTCC1);
227#ifdef TCC_TARGET_UNIX227#ifdef TCC_TARGET_UNIX
228 print_dirs("crt", s->crt_paths, s->nb_crt_paths);228 print_dirs("crt", s->crt_paths, s->nb_crt_paths);
229 printf("elfinterp:\n %s\n", DEFAULT_ELFINTERP(s));229 printf("elfinterp:\n %s\n", s->elfint);
230#endif230#endif
231}231}
232 232
tcc.h+14−30
@@ -252,15 +252,14 @@ extern long double strtold (const char *__nptr, char **__endptr); · 251 unmodified lines
252#ifndef CONFIG_SYSROOT252#ifndef CONFIG_SYSROOT
253# define CONFIG_SYSROOT ""253# define CONFIG_SYSROOT ""
254#endif254#endif
255
255#if !defined CONFIG_TCCDIR && !defined _WIN32256#if !defined CONFIG_TCCDIR && !defined _WIN32
256# define CONFIG_TCCDIR "/usr/local/lib/tcc"257# define CONFIG_TCCDIR "/usr/local/lib/tcc"
257#endif258#endif
258#ifndef CONFIG_LDDIR259
259# define CONFIG_LDDIR "lib"
260#endif
261#ifdef CONFIG_TRIPLET260#ifdef CONFIG_TRIPLET
262# define USE_TRIPLET(s) s "/" CONFIG_TRIPLET261# define USE_TRIPLET(s) s "/" CONFIG_TRIPLET
263# define ALSO_TRIPLET(s) USE_TRIPLET(s) ":" s262# define ALSO_TRIPLET(s) USE_TRIPLET(s) PATHSEP s
264#else263#else
265# define USE_TRIPLET(s) s264# define USE_TRIPLET(s) s
266# define ALSO_TRIPLET(s) s265# define ALSO_TRIPLET(s) s
@@ -268,11 +267,8 @@ extern long double strtold (const char *__nptr, char **__endptr); · 1 unmodified line
268 267
269/* path to find crt1.o, crti.o and crtn.o */268/* path to find crt1.o, crti.o and crtn.o */
270#ifndef CONFIG_TCC_CRTPREFIX269#ifndef CONFIG_TCC_CRTPREFIX
271# define CONFIG_TCC_CRTPREFIX USE_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR)270# define CONFIG_TCC_CRTPREFIX \
272#endif271 USE_TRIPLET(CONFIG_SYSROOT "/usr/lib")
273
274#ifndef CONFIG_USR_INCLUDE
275# define CONFIG_USR_INCLUDE "/usr/include"
276#endif272#endif
277 273
278/* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */274/* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */
@@ -280,25 +276,22 @@ extern long double strtold (const char *__nptr, char **__endptr); · 1 unmodified line
280/* system include paths */276/* system include paths */
281#ifndef CONFIG_TCC_SYSINCLUDEPATHS277#ifndef CONFIG_TCC_SYSINCLUDEPATHS
282# if defined TCC_TARGET_PE || defined _WIN32278# if defined TCC_TARGET_PE || defined _WIN32
283# define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include"PATHSEP"{B}/include/winapi"279# define CONFIG_TCC_SYSINCLUDEPATHS \
280 "{B}/include" PATHSEP "{B}/include/winapi"
284# else281# else
285# define CONFIG_TCC_SYSINCLUDEPATHS \282# define CONFIG_TCC_SYSINCLUDEPATHS \
286 "{B}/include" \283 "{B}/include" PATHSEP ALSO_TRIPLET(CONFIG_SYSROOT "/usr/include")
287 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \
288 ":" ALSO_TRIPLET(CONFIG_SYSROOT CONFIG_USR_INCLUDE)
289# endif284# endif
290#endif285#endif
291 286
292/* library search paths */287/* library search paths */
293#ifndef CONFIG_TCC_LIBPATHS288#ifndef CONFIG_TCC_LIBPATHS
294# if defined TCC_TARGET_PE || defined _WIN32289# if defined TCC_TARGET_PE || defined _WIN32
295# define CONFIG_TCC_LIBPATHS "{B}/lib"290# define CONFIG_TCC_LIBPATHS \
291 "{B}/lib"
296# else292# else
297# define CONFIG_TCC_LIBPATHS \293# define CONFIG_TCC_LIBPATHS \
298 "{B}" \294 "{B}" PATHSEP ALSO_TRIPLET(CONFIG_SYSROOT "/usr/lib")
299 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \
300 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \
301 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR)
302# endif295# endif
303#endif296#endif
304 297
@@ -314,28 +307,19 @@ extern long double strtold (const char *__nptr, char **__endptr); · 9 unmodified lines
314# define CONFIG_TCC_ELFINTERP "/lib64/ld-linux-x86-64.so.2"307# define CONFIG_TCC_ELFINTERP "/lib64/ld-linux-x86-64.so.2"
315# elif defined(TCC_TARGET_RISCV64)308# elif defined(TCC_TARGET_RISCV64)
316# define CONFIG_TCC_ELFINTERP "/lib/ld-linux-riscv64-lp64d.so.1"309# define CONFIG_TCC_ELFINTERP "/lib/ld-linux-riscv64-lp64d.so.1"
317# elif defined(TCC_ARM_EABI)310# elif defined(TCC_TARGET_ARM)
318# define DEFAULT_ELFINTERP(s) default_elfinterp(s)311# define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.3"
312# define CONFIG_TCC_ELFINTERP_ARMHF "/lib/ld-linux-armhf.so.3"
319# else313# else
320# define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.2"314# define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.2"
321# endif315# endif
322#endif316#endif
323 317
324/* var elf_interp dans *-gen.c */
325#ifndef DEFAULT_ELFINTERP
326# define DEFAULT_ELFINTERP(s) CONFIG_TCC_ELFINTERP
327#endif
328
329/* (target specific) libtcc1.a */318/* (target specific) libtcc1.a */
330#ifndef TCC_LIBTCC1319#ifndef TCC_LIBTCC1
331# define TCC_LIBTCC1 "libtcc1.a"320# define TCC_LIBTCC1 "libtcc1.a"
332#endif321#endif
333 322
334/* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */
335#if defined CONFIG_USE_LIBGCC && !defined TCC_LIBGCC
336#define TCC_LIBGCC USE_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) "/libgcc_s.so.1"
337#endif
338
339/* <cross-prefix-to->libtcc1.a */323/* <cross-prefix-to->libtcc1.a */
340#ifndef CONFIG_TCC_CROSSPREFIX324#ifndef CONFIG_TCC_CROSSPREFIX
341# define CONFIG_TCC_CROSSPREFIX ""325# define CONFIG_TCC_CROSSPREFIX ""
tccelf.c+16−9
@@ -110,6 +110,21 @@ ST_FUNC void tccelf_new(TCCState *s) · 109 unmodified lines
110 if (s->elf_entryname)110 if (s->elf_entryname)
111 set_global_sym(s, s->elf_entryname, NULL, 0); /* SHN_UNDEF */111 set_global_sym(s, s->elf_entryname, NULL, 0); /* SHN_UNDEF */
112#endif112#endif
113
114#ifndef ELF_OBJ_ONLY
115 if (NULL == s->elfint && s1->output_type != TCC_OUTPUT_OBJ) {
116 const char *p = CONFIG_TCC_ELFINTERP;
117#ifdef TCC_TARGET_ARM
118 if (s->float_abi == ARM_HARD_FLOAT)
119 p = CONFIG_TCC_ELFINTERP_ARMHF;
120#endif
121#if defined TCC_IS_NATIVE && defined TARGETOS_BSD
122 /* see commit 55cb2170cd5ce77a7d76dcaf462fad2707281605 */
123 { const char *e = getenv("LD_SO"); if (e) p = e; }
124#endif
125 s->elfint = tcc_strdup(p);
126 }
127#endif /* ndef ELF_OBJ_ONLY */
113}128}
114 129
115ST_FUNC void free_section(Section *s)130ST_FUNC void free_section(Section *s)
@@ -2939,18 +2954,10 @@ static int elf_output_file(TCCState *s1, const char *filename) · 2823 unmodified lines
2939 2954
2940 if (!s1->static_link) {2955 if (!s1->static_link) {
2941 if (file_type & TCC_OUTPUT_EXE) {2956 if (file_type & TCC_OUTPUT_EXE) {
2942 char *ptr;
2943 /* allow override the dynamic loader */
2944 const char *elfint = s1->elfint;
2945 if (elfint == NULL)
2946 elfint = getenv("LD_SO");
2947 if (elfint == NULL)
2948 elfint = DEFAULT_ELFINTERP(s1);
2949 /* add interpreter section only if executable */2957 /* add interpreter section only if executable */
2950 interp = new_section(s1, ".interp", SHT_PROGBITS, SHF_ALLOC);2958 interp = new_section(s1, ".interp", SHT_PROGBITS, SHF_ALLOC);
2951 interp->sh_addralign = 1;2959 interp->sh_addralign = 1;
2952 ptr = section_ptr_add(interp, 1 + strlen(elfint));2960 put_elf_str(interp, s1->elfint);
2953 strcpy(ptr, elfint);
2954 dyninf.interp = interp;2961 dyninf.interp = interp;
2955 }2962 }
2956 2963

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t