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
158158 endif
159159
160160 # --------------------------------------------
161−
162−T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown)
161+T = $(or $(CROSS_TARGET),$(NATIVE_TARGET))
163162 X = $(if $(CROSS_TARGET),$(CROSS_TARGET)-)
164163
164+ifneq ($(T),$(NATIVE_TARGET))
165+$(if $(DEF-$T),,$(error error: unknown target: '$T'))
166+ifneq ($(CONFIG_WIN32),yes)
167+DEF-win = -DCONFIG_TCCDIR="\"$(tccdir)/win32\""
168+endif
169+# some default config for cross compilers
170+TRIPLET-i386 = i686-linux-gnu
171+TRIPLET-x86_64 = x86_64-linux-gnu
172+TRIPLET-arm = arm-linux-gnueabihf
173+TRIPLET-arm64 = aarch64-linux-gnu
174+TRIPLET-riscv64 = riscv64-linux-gnu
175+ifneq ($(TRIPLET-$T),)
176+# assume support files in "/usr/<triplet>"
177+ROOT-$T = /usr/$(TRIPLET-$T)
178+INC-$T = {B}/include:{R}/include
179+LIB-$T = {R}/lib:{B}
180+CRT-$T = {R}/lib
181+endif
165182 DEFINES += $(DEF-$T)
166183 DEFINES += $(if $(ROOT-$T),-DCONFIG_SYSROOT="\"$(ROOT-$T)\"")
167184 DEFINES += $(if $(CRT-$T),-DCONFIG_TCC_CRTPREFIX="\"$(CRT-$T)\"")
@@ -169,36 +186,17 @@ DEFINES += $(if $(LIB-$T),-DCONFIG_TCC_LIBPATHS="\"$(LIB-$T)\"") · 1 unmodified line
169186 DEFINES += $(if $(INC-$T),-DCONFIG_TCC_SYSINCLUDEPATHS="\"$(INC-$T)\"")
170187 DEFINES += $(if $(ELF-$T),-DCONFIG_TCC_ELFINTERP="\"$(ELF-$T)\"")
171188 DEFINES += $(DEF-$(or $(findstring win,$T),unx))
172−
173−ifneq ($(X),)
174−$(if $(DEF-$T),,$(error error: unknown target: '$T'))
175−DEF-$(NATIVE_TARGET) =
176−DEF-$T += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
177−ifneq ($(CONFIG_WIN32),yes)
178−DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\""
179−endif
180−else
181−# using values from config.h
182−DEF-$(NATIVE_TARGET) =
189+DEFINES += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
183190 endif
184191
185192 # include custom configuration (see make help)
186193 -include config-extra.mak
187194
188−ifneq ($(T),$(NATIVE_TARGET))
189−# assume support files for cross-targets in "/usr/<triplet>" by default
190−TRIPLET-i386 ?= i686-linux-gnu
191−TRIPLET-x86_64 ?= x86_64-linux-gnu
192−TRIPLET-arm ?= arm-linux-gnueabi
193−TRIPLET-arm64 ?= aarch64-linux-gnu
194−TRIPLET-riscv64 ?= riscv64-linux-gnu
195−MARCH-i386 ?= i386-linux-gnu
196−MARCH-$T ?= $(TRIPLET-$T)
197−TR = $(if $(TRIPLET-$T),$T,ignored)
198−CRT-$(TR) ?= /usr/$(TRIPLET-$T)/lib
199−LIB-$(TR) ?= {B}:/usr/$(TRIPLET-$T)/lib:/usr/lib/$(MARCH-$T)
200−INC-$(TR) ?= {B}/include:/usr/$(TRIPLET-$T)/include:/usr/include
201−endif
195+# so one can use: make EXTRA-DEFS=...
196+DEFINES += $(EXTRA-DEFS)
197+
198+# find config.h with 'out of tree' builds
199+DEFINES += -I$(TOP)
202200
203201 CORE_FILES = tcc.c tcctools.c libtcc.c tccpp.c tccgen.c tccdbg.c tccelf.c tccasm.c tccrun.c
204202 CORE_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
209207 x86_64-osx_FILES = $(x86_64_FILES) tccmacho.c
210208 arm_FILES = $(CORE_FILES) arm-gen.c arm-link.c arm-asm.c arm-tok.h
211209 arm-wince_FILES = $(arm_FILES) tccpe.c
212−arm-eabihf_FILES = $(arm_FILES)
213210 arm-fpa_FILES = $(arm_FILES)
214211 arm-fpa-ld_FILES = $(arm_FILES)
215212 arm-vfp_FILES = $(arm_FILES)
@@ -241,7 +238,6 @@ $(CROSS_TARGET)-tcc.o : DEFINES += -DONE_SOURCE=0 · 25 unmodified lines
241238 endif
242239 # native tcc always made from tcc.o and libtcc.[so|a]
243240 tcc.o : DEFINES += -DONE_SOURCE=0
244−DEFINES += -I$(TOP)
245241
246242 GITHASH:=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo no)
247243 ifneq ($(GITHASH),no)
@@ -340,7 +336,7 @@ FORCE: · 92 unmodified lines
340336 # some versions of gnu-make do not recognize 'command' as a shell builtin
341337 WHICH = sh -c 'command -v $1'
342338
343−run-if = $(if $(shell $(call WHICH,$1)),$S $1 $2)
339+run-if = $(if $(shell $(call WHICH,$1)),$S $1 $2,@echo "(skipping $@ - no $1)")
344340 S = $(if $(findstring yes,$(SILENT)),@$(info * $@))
345341
346342 # --------------------------------------------------------------------------
@@ -501,14 +497,14 @@ distclean: clean · 154 unmodified lines
501497 help:
502498 @echo "make"
503499 @echo " build native compiler (from separate objects)"
504− @echo "make cross"
505− @echo " build cross compilers (from one source)"
506500 @echo "make ONE_SOURCE=no/yes SILENT=no/yes"
507501 @echo " force building from separate/one object(s), less/more silently"
508502 @echo "make cross-TARGET"
509503 @echo " build one specific cross compiler for 'TARGET'. Currently supported:"
510504 @echo " $(wordlist 1,8,$(TCC_X))"
511505 @echo " $(wordlist 9,99,$(TCC_X))"
506+ @echo "make cross"
507+ @echo " build all cross compilers"
512508 @echo "make test"
513509 @echo " run all tests"
514510 @echo "make tests2.all / make tests2.37 / make tests2.37+"
arm-gen.c+3−17
@@ -133,11 +133,8 @@ enum { · 132 unmodified lines
133133
134134 #define CHAR_IS_UNSIGNED
135135
136−#ifdef TCC_ARM_HARDFLOAT
137−# define ARM_FLOAT_ABI ARM_HARD_FLOAT
138−#else
139−# define ARM_FLOAT_ABI ARM_SOFTFP_FLOAT
140−#endif
136+#define ARM_SOFTFP_FLOAT 0
137+#define ARM_HARD_FLOAT 1
141138
142139 /******************************************************/
143140 #else /* ! TARGET_DEFS_ONLY */
@@ -160,8 +157,6 @@ ST_DATA const char * const target_machine_defs = · 16 unmodified lines
160157 #endif
161158 ;
162159
163−enum float_abi float_abi;
164−
165160 ST_DATA const int reg_classes[NB_REGS] = {
166161 /* r0 */ RC_INT | RC_R0,
167162 /* r1 */ RC_INT | RC_R1,
@@ -180,6 +175,7 @@ ST_DATA const int reg_classes[NB_REGS] = { · 12 unmodified lines
180175 #endif
181176 };
182177
178+static int float_abi;
183179 static int func_sub_sp_offset, last_itod_magic;
184180 static int leaffunc;
185181
@@ -241,16 +237,6 @@ static int regmask(int r) { · 55 unmodified lines
241237
242238 /******************************************************/
243239
244−#if defined(TCC_ARM_EABI) && !defined(CONFIG_TCC_ELFINTERP)
245−const 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−
254240 void o(uint32_t i)
255241 {
256242 /* this is a good place to start adding big-endian support*/
arm-link.c+0−5
@@ -18,11 +18,6 @@ · 17 unmodified lines
1818 #define PCRELATIVE_DLLPLT 1
1919 #define RELOCATE_DLLPLT 1
2020
21−enum float_abi {
22− ARM_SOFTFP_FLOAT,
23− ARM_HARD_FLOAT,
24−};
25−
2621 #else /* !TARGET_DEFS_ONLY */
2722
2823 #include "tcc.h"
configure+11−12
@@ -35,13 +35,11 @@ mingw32="no" · 34 unmodified lines
3535 LIBSUF=".a"
3636 EXESUF=""
3737 DLLSUF=".so"
38−tcc_usrinclude=""
3938 tcc_sysincludepaths=""
4039 tcc_libpaths=""
4140 tcc_crtprefix=""
4241 tcc_elfinterp=""
4342 triplet=
44−tcc_lddir=
4543 confvars=
4644 suggest="yes"
4745 gcc_major=0
@@ -53,6 +51,7 @@ cpuver= · 5 unmodified lines
5351 dwarf=
5452 targetos=
5553 build_cross=
54+quiet=
5655
5756 # use CC/AR from environment when set
5857 test -n "$CC" && cc="$CC"
@@ -160,8 +159,6 @@ for opt do · 101 unmodified lines
160159 ;;
161160 --debug) confvars_set debug
162161 ;;
163− --with-libgcc) confvars_set libgcc
164− ;;
165162 --with-selinux) confvars_set selinux
166163 ;;
167164 --tcc-switches=*) assign_opt "$opt" tcc_switches
@@ -174,6 +171,8 @@ for opt do · 6 unmodified lines
174171 ;;
175172 --help|-h) show_help="yes"
176173 ;;
174+ -q) quiet=yes
175+ ;;
177176 *) echo "configure: WARNING: unrecognized option $opt"
178177 ;;
179178 esac
@@ -197,6 +196,7 @@ Standard options: · 17 unmodified lines
197196 --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
198197 --mandir=DIR man documentation in DIR [SHAREDIR/man]
199198 --infodir=DIR info documentation in DIR [SHAREDIR/info]
199+ -q be quiet
200200
201201 Advanced options (experts only):
202202 --source-path=PATH path of source code [$source_path]
@@ -210,9 +210,8 @@ Advanced options (experts only): · 7 unmodified lines
210210 --disable-static make libtcc.so instead of libtcc.a
211211 --enable-static make libtcc.a instead of libtcc.dll (win32)
212212 --disable-rpath disable use of -rpath with libtcc.so
213− --with-libgcc use libgcc_s.so.1 instead of libtcc1.a
214213 --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')
216215
217216 --sysincludepaths=... specify system include paths, colon separated
218217 --libpaths=... specify system library paths, colon separated
@@ -367,6 +366,7 @@ case $targetos in · 148 unmodified lines
367366 cc=`command -v cc`
368367 cc=`readlink $cc || echo clang`
369368 tcc_usrinclude="`xcrun --show-sdk-path`/usr/include"
369+ default tcc_sysincludepaths "{B}/include:$tcc_usrinclude"
370370 if test "${confvars%new_macho*}" = "${confvars}"; then
371371 # if new_macho was not specified and (known) ver <= 10, use old (=no)
372372 osxver=$(sw_vers -productVersion 2>/dev/null) # X.Y.Z
@@ -478,7 +478,8 @@ if test -z "$build_cross"; then · 105 unmodified lines
478478 if test -z "$triplet"; then
479479 case $cpu in x86_64|arm64|riscv64)
480480 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"
482483 fi
483484 esac
484485 fi
@@ -552,6 +553,7 @@ fi · 67 unmodified lines
552553
553554 fcho() { if test -n "$2"; then echo "$1$2"; fi }
554555
556+if test -z "$quiet"; then
555557 fcho "Binary directory " "$bindir"
556558 fcho "TinyCC directory " "$tccdir"
557559 fcho "Library directory " "$libdir"
@@ -560,7 +562,6 @@ fcho "Manual directory " "$mandir" · 2 unmodified lines
560562 fcho "Info directory " "$infodir"
561563 fcho "Doc directory " "$docdir"
562564 fcho "Target root prefix " "$sysroot"
563−fcho "/usr/include dir " "$tcc_usrinclude"
564565 echo "Source path $source_path"
565566 echo "Build OS $(uname -m -s)"
566567 echo "C compiler $cc ($gcc_major.$gcc_minor)"
@@ -574,6 +575,7 @@ fcho "Elfinterp " "$tcc_elfinterp" · 7 unmodified lines
574575 fcho "Switches " "$tcc_switches"
575576 fcho "Config " "${confvars# }"
576577 echo "Creating config.mak and config.h"
578+fi
577579
578580 version=$(head "$source_path/VERSION")
579581
@@ -691,7 +693,6 @@ for v in $cpu $confvars ; do · 111 unmodified lines
691693 esac
692694 ;;
693695 # other
694− CONFIG_libgcc=yes) print_num CONFIG_USE_LIBGCC 1 ;;
695696 CONFIG_selinux=yes) print_num CONFIG_SELINUX 1 ;;
696697 CONFIG_pie=yes) print_num CONFIG_TCC_PIE 1 ;;
697698 CONFIG_pic=yes) print_num CONFIG_TCC_PIC 1 ;;
@@ -706,13 +707,11 @@ for v in $cpu $confvars ; do · 8 unmodified lines
706707 esac
707708 done
708709
709−print_str CONFIG_USR_INCLUDE "$tcc_usrinclude"
710710 print_str CONFIG_TCC_SYSINCLUDEPATHS "$tcc_sysincludepaths"
711711 print_str CONFIG_TCC_LIBPATHS "$tcc_libpaths"
712712 print_str CONFIG_TCC_CRTPREFIX "$tcc_crtprefix"
713713 print_str CONFIG_TCC_ELFINTERP "$tcc_elfinterp"
714714 print_str CONFIG_TCC_SWITCHES "$tcc_switches"
715−print_str CONFIG_LDDIR "$tcc_lddir"
716715 print_str CONFIG_TRIPLET "$triplet"
717716 print_str CONFIG_OS_RELEASE "$os_release"
718717 echo "#endif" >> $TMPH && echo >> $TMPH
@@ -724,7 +723,7 @@ print_num CONFIG_TCC_PREDEFS "$predefs" · 5 unmodified lines
724723 diff $TMPH config.h >/dev/null 2>&1
725724 if test $? -ne 0 ; then
726725 mv -f $TMPH config.h
727−else
726+elif test -z "$quiet"; then
728727 echo "config.h is unchanged"
729728 fi
730729
libtcc.c+24−16
@@ -896,8 +896,8 @@ LIBTCCAPI TCCState *tcc_new(void) · 895 unmodified lines
896896 #if defined TCC_TARGET_MACHO /* || defined TCC_TARGET_PE */
897897 s->leading_underscore = 1;
898898 #endif
899−#ifdef TCC_TARGET_ARM
900− s->float_abi = ARM_FLOAT_ABI;
899+#ifdef TCC_ARM_HARDFLOAT
900+ s->float_abi = ARM_HARD_FLOAT;
901901 #endif
902902 #ifdef CONFIG_NEW_DTAGS
903903 s->enable_new_dtags = 1;
@@ -995,10 +995,12 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type) · 91 unmodified lines
995995 /* allow linking with system dll's directly */
996996 tcc_add_systemdir(s);
997997 # endif
998+
998999 #elif defined TCC_TARGET_MACHO
9991000 # ifdef TCC_IS_NATIVE
10001001 tcc_add_macos_sdkpath(s);
10011002 # endif
1003+
10021004 #else
10031005 /* paths for crt objects */
10041006 tcc_split_path(s, &s->crt_paths, &s->nb_crt_paths, CONFIG_TCC_CRTPREFIX);
@@ -1362,10 +1364,11 @@ struct lopt { · 357 unmodified lines
13621364 /* match linker option */
13631365 static int link_option(struct lopt *o, const char *q)
13641366 {
1365− const char *p = o->opt;
1367+ const char *p;
13661368 int c;
1367−
1369+redo:
13681370 /* there should be 1 or 2 dashes */
1371+ p = o->opt;
13691372 if (*p++ != '-')
13701373 return 0;
13711374 if (*p == '-')
@@ -1378,16 +1381,22 @@ static int link_option(struct lopt *o, const char *q) · 6 unmodified lines
13781381 goto succ; /* -Wl,-opt=arg */
13791382 ++q;
13801383 }
1381− if (c == '=' || c == ':') {
1382− if (*p == '\0') {
1384+ if (*p == '\0') {
1385+ if (c == '|')
1386+ goto succ;
1387+ if (c == '=' || c == ':') {
13831388 if (o->s->link_optind + 1 < o->s->link_argc) {
13841389 p = o->s->link_argv[++o->s->link_optind];
13851390 goto succ; /* -Wl,-opt,arg */
13861391 }
13871392 o->match = 1; /* -Wl,-opt -Wl,arg */
1388− } else if (c == ':')
1389− goto succ; /* -Wl,-Iarg */
1390− }
1393+ return 0;
1394+ }
1395+ } else if (c == ':')
1396+ goto succ; /* -Wl,-Iarg */
1397+ while (*q)
1398+ if (*q++ == '|')
1399+ goto redo;
13911400 return 0;
13921401 succ:
13931402 o->arg = p;
@@ -1415,9 +1424,9 @@ static int tcc_set_linker(TCCState *s, const char *optarg) · 21 unmodified lines
14151424 s->symbolic = 1;
14161425 } else if (link_option(&o, "nostdlib")) {
14171426 s->nostdlib_paths = 1;
1418− } else if (link_option(&o, "e=") || link_option(&o, "entry=")) {
1427+ } else if (link_option(&o, "e=|entry=")) {
14191428 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=")) {
14211430 s->text_addr = strtoull(o.arg, &end, 16);
14221431 s->has_text_addr = 1;
14231432 } else if (link_option(&o, "init=")) {
@@ -1446,18 +1455,17 @@ static int tcc_set_linker(TCCState *s, const char *optarg) · 22 unmodified lines
14461455 #endif
14471456 else
14481457 goto err;
1449− } else if (link_option(&o, "export-all-symbols")
1450− || link_option(&o, "export-dynamic")) {
1458+ } else if (link_option(&o, "export-all-symbols|export-dynamic|E")) {
14511459 s->rdynamic = 1;
14521460 } else if (link_option(&o, "rpath=")) {
14531461 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:")) {
14551463 tcc_set_str(&s->elfint, o.arg);
14561464 } else if (link_option(&o, "enable-new-dtags")) {
14571465 s->enable_new_dtags = 1;
14581466 } else if (link_option(&o, "section-alignment=")) {
14591467 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=")) {
14611469 tcc_set_str(&s->soname, o.arg);
14621470 } else if (link_option(&o, "whole-archive")) {
14631471 s->filetype |= AFF_WHOLE_ARCHIVE;
@@ -2024,7 +2032,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int *pargc, char ***pargv) · 560 unmodified lines
20242032 s->float_abi = ARM_HARD_FLOAT;
20252033 else
20262034 return tcc_error_noabort("unsupported float abi '%s'", optarg);
2027− break;
2035+ continue;
20282036 #endif
20292037 case TCC_OPTION_m:
20302038 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
226226 printf("libtcc1:\n %s/%s\n", s->library_paths[0], CONFIG_TCC_CROSSPREFIX TCC_LIBTCC1);
227227 #ifdef TCC_TARGET_UNIX
228228 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);
230230 #endif
231231 }
232232
tcc.h+14−30
@@ -252,15 +252,14 @@ extern long double strtold (const char *__nptr, char **__endptr); · 251 unmodified lines
252252 #ifndef CONFIG_SYSROOT
253253 # define CONFIG_SYSROOT ""
254254 #endif
255+
255256 #if !defined CONFIG_TCCDIR && !defined _WIN32
256257 # define CONFIG_TCCDIR "/usr/local/lib/tcc"
257258 #endif
258−#ifndef CONFIG_LDDIR
259−# define CONFIG_LDDIR "lib"
260−#endif
259+
261260 #ifdef CONFIG_TRIPLET
262261 # define USE_TRIPLET(s) s "/" CONFIG_TRIPLET
263−# define ALSO_TRIPLET(s) USE_TRIPLET(s) ":" s
262+# define ALSO_TRIPLET(s) USE_TRIPLET(s) PATHSEP s
264263 #else
265264 # define USE_TRIPLET(s) s
266265 # define ALSO_TRIPLET(s) s
@@ -268,11 +267,8 @@ extern long double strtold (const char *__nptr, char **__endptr); · 1 unmodified line
268267
269268 /* path to find crt1.o, crti.o and crtn.o */
270269 #ifndef CONFIG_TCC_CRTPREFIX
271−# define CONFIG_TCC_CRTPREFIX USE_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR)
272−#endif
273−
274−#ifndef CONFIG_USR_INCLUDE
275−# define CONFIG_USR_INCLUDE "/usr/include"
270+# define CONFIG_TCC_CRTPREFIX \
271+ USE_TRIPLET(CONFIG_SYSROOT "/usr/lib")
276272 #endif
277273
278274 /* 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
280276 /* system include paths */
281277 #ifndef CONFIG_TCC_SYSINCLUDEPATHS
282278 # 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"
284281 # else
285282 # define CONFIG_TCC_SYSINCLUDEPATHS \
286− "{B}/include" \
287− ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \
288− ":" ALSO_TRIPLET(CONFIG_SYSROOT CONFIG_USR_INCLUDE)
283+ "{B}/include" PATHSEP ALSO_TRIPLET(CONFIG_SYSROOT "/usr/include")
289284 # endif
290285 #endif
291286
292287 /* library search paths */
293288 #ifndef CONFIG_TCC_LIBPATHS
294289 # if defined TCC_TARGET_PE || defined _WIN32
295−# define CONFIG_TCC_LIBPATHS "{B}/lib"
290+# define CONFIG_TCC_LIBPATHS \
291+ "{B}/lib"
296292 # else
297293 # define CONFIG_TCC_LIBPATHS \
298− "{B}" \
299− ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \
300− ":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \
301− ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR)
294+ "{B}" PATHSEP ALSO_TRIPLET(CONFIG_SYSROOT "/usr/lib")
302295 # endif
303296 #endif
304297
@@ -314,28 +307,19 @@ extern long double strtold (const char *__nptr, char **__endptr); · 9 unmodified lines
314307 # define CONFIG_TCC_ELFINTERP "/lib64/ld-linux-x86-64.so.2"
315308 # elif defined(TCC_TARGET_RISCV64)
316309 # define CONFIG_TCC_ELFINTERP "/lib/ld-linux-riscv64-lp64d.so.1"
317−# elif defined(TCC_ARM_EABI)
318−# define DEFAULT_ELFINTERP(s) default_elfinterp(s)
310+# elif defined(TCC_TARGET_ARM)
311+# define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.3"
312+# define CONFIG_TCC_ELFINTERP_ARMHF "/lib/ld-linux-armhf.so.3"
319313 # else
320314 # define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.2"
321315 # endif
322316 #endif
323317
324−/* var elf_interp dans *-gen.c */
325−#ifndef DEFAULT_ELFINTERP
326−# define DEFAULT_ELFINTERP(s) CONFIG_TCC_ELFINTERP
327−#endif
328−
329318 /* (target specific) libtcc1.a */
330319 #ifndef TCC_LIBTCC1
331320 # define TCC_LIBTCC1 "libtcc1.a"
332321 #endif
333322
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−
339323 /* <cross-prefix-to->libtcc1.a */
340324 #ifndef CONFIG_TCC_CROSSPREFIX
341325 # define CONFIG_TCC_CROSSPREFIX ""
tccelf.c+16−9
@@ -110,6 +110,21 @@ ST_FUNC void tccelf_new(TCCState *s) · 109 unmodified lines
110110 if (s->elf_entryname)
111111 set_global_sym(s, s->elf_entryname, NULL, 0); /* SHN_UNDEF */
112112 #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 */
113128 }
114129
115130 ST_FUNC void free_section(Section *s)
@@ -2939,18 +2954,10 @@ static int elf_output_file(TCCState *s1, const char *filename) · 2823 unmodified lines
29392954
29402955 if (!s1->static_link) {
29412956 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);
29492957 /* add interpreter section only if executable */
29502958 interp = new_section(s1, ".interp", SHT_PROGBITS, SHF_ALLOC);
29512959 interp->sh_addralign = 1;
2952− ptr = section_ptr_add(interp, 1 + strlen(elfint));
2953− strcpy(ptr, elfint);
2960+ put_elf_str(interp, s1->elfint);
29542961 dyninf.interp = interp;
29552962 }
29562963

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