mirror of
git://repo.or.cz/tinycc.git
synced 2026-06-17 15:44:18 +08:00
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()
This commit is contained in:
parent
923fba83f1
commit
6daf1617ef
60
Makefile
60
Makefile
@ -158,10 +158,27 @@ all : cross
|
||||
endif
|
||||
|
||||
# --------------------------------------------
|
||||
|
||||
T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown)
|
||||
T = $(or $(CROSS_TARGET),$(NATIVE_TARGET))
|
||||
X = $(if $(CROSS_TARGET),$(CROSS_TARGET)-)
|
||||
|
||||
ifneq ($(T),$(NATIVE_TARGET))
|
||||
$(if $(DEF-$T),,$(error error: unknown target: '$T'))
|
||||
ifneq ($(CONFIG_WIN32),yes)
|
||||
DEF-win = -DCONFIG_TCCDIR="\"$(tccdir)/win32\""
|
||||
endif
|
||||
# some default config for cross compilers
|
||||
TRIPLET-i386 = i686-linux-gnu
|
||||
TRIPLET-x86_64 = x86_64-linux-gnu
|
||||
TRIPLET-arm = arm-linux-gnueabihf
|
||||
TRIPLET-arm64 = aarch64-linux-gnu
|
||||
TRIPLET-riscv64 = riscv64-linux-gnu
|
||||
ifneq ($(TRIPLET-$T),)
|
||||
# assume support files in "/usr/<triplet>"
|
||||
ROOT-$T = /usr/$(TRIPLET-$T)
|
||||
INC-$T = {B}/include:{R}/include
|
||||
LIB-$T = {R}/lib:{B}
|
||||
CRT-$T = {R}/lib
|
||||
endif
|
||||
DEFINES += $(DEF-$T)
|
||||
DEFINES += $(if $(ROOT-$T),-DCONFIG_SYSROOT="\"$(ROOT-$T)\"")
|
||||
DEFINES += $(if $(CRT-$T),-DCONFIG_TCC_CRTPREFIX="\"$(CRT-$T)\"")
|
||||
@ -169,36 +186,17 @@ DEFINES += $(if $(LIB-$T),-DCONFIG_TCC_LIBPATHS="\"$(LIB-$T)\"")
|
||||
DEFINES += $(if $(INC-$T),-DCONFIG_TCC_SYSINCLUDEPATHS="\"$(INC-$T)\"")
|
||||
DEFINES += $(if $(ELF-$T),-DCONFIG_TCC_ELFINTERP="\"$(ELF-$T)\"")
|
||||
DEFINES += $(DEF-$(or $(findstring win,$T),unx))
|
||||
|
||||
ifneq ($(X),)
|
||||
$(if $(DEF-$T),,$(error error: unknown target: '$T'))
|
||||
DEF-$(NATIVE_TARGET) =
|
||||
DEF-$T += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
|
||||
ifneq ($(CONFIG_WIN32),yes)
|
||||
DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\""
|
||||
endif
|
||||
else
|
||||
# using values from config.h
|
||||
DEF-$(NATIVE_TARGET) =
|
||||
DEFINES += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
|
||||
endif
|
||||
|
||||
# include custom configuration (see make help)
|
||||
-include config-extra.mak
|
||||
|
||||
ifneq ($(T),$(NATIVE_TARGET))
|
||||
# assume support files for cross-targets in "/usr/<triplet>" by default
|
||||
TRIPLET-i386 ?= i686-linux-gnu
|
||||
TRIPLET-x86_64 ?= x86_64-linux-gnu
|
||||
TRIPLET-arm ?= arm-linux-gnueabi
|
||||
TRIPLET-arm64 ?= aarch64-linux-gnu
|
||||
TRIPLET-riscv64 ?= riscv64-linux-gnu
|
||||
MARCH-i386 ?= i386-linux-gnu
|
||||
MARCH-$T ?= $(TRIPLET-$T)
|
||||
TR = $(if $(TRIPLET-$T),$T,ignored)
|
||||
CRT-$(TR) ?= /usr/$(TRIPLET-$T)/lib
|
||||
LIB-$(TR) ?= {B}:/usr/$(TRIPLET-$T)/lib:/usr/lib/$(MARCH-$T)
|
||||
INC-$(TR) ?= {B}/include:/usr/$(TRIPLET-$T)/include:/usr/include
|
||||
endif
|
||||
# so one can use: make EXTRA-DEFS=...
|
||||
DEFINES += $(EXTRA-DEFS)
|
||||
|
||||
# find config.h with 'out of tree' builds
|
||||
DEFINES += -I$(TOP)
|
||||
|
||||
CORE_FILES = tcc.c tcctools.c libtcc.c tccpp.c tccgen.c tccdbg.c tccelf.c tccasm.c tccrun.c
|
||||
CORE_FILES += tcc.h config.h libtcc.h tcctok.h
|
||||
@ -209,7 +207,6 @@ x86_64-win32_FILES = $(x86_64_FILES) tccpe.c
|
||||
x86_64-osx_FILES = $(x86_64_FILES) tccmacho.c
|
||||
arm_FILES = $(CORE_FILES) arm-gen.c arm-link.c arm-asm.c arm-tok.h
|
||||
arm-wince_FILES = $(arm_FILES) tccpe.c
|
||||
arm-eabihf_FILES = $(arm_FILES)
|
||||
arm-fpa_FILES = $(arm_FILES)
|
||||
arm-fpa-ld_FILES = $(arm_FILES)
|
||||
arm-vfp_FILES = $(arm_FILES)
|
||||
@ -241,7 +238,6 @@ $(CROSS_TARGET)-tcc.o : DEFINES += -DONE_SOURCE=0
|
||||
endif
|
||||
# native tcc always made from tcc.o and libtcc.[so|a]
|
||||
tcc.o : DEFINES += -DONE_SOURCE=0
|
||||
DEFINES += -I$(TOP)
|
||||
|
||||
GITHASH:=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo no)
|
||||
ifneq ($(GITHASH),no)
|
||||
@ -340,7 +336,7 @@ FORCE:
|
||||
# some versions of gnu-make do not recognize 'command' as a shell builtin
|
||||
WHICH = sh -c 'command -v $1'
|
||||
|
||||
run-if = $(if $(shell $(call WHICH,$1)),$S $1 $2)
|
||||
run-if = $(if $(shell $(call WHICH,$1)),$S $1 $2,@echo "(skipping $@ - no $1)")
|
||||
S = $(if $(findstring yes,$(SILENT)),@$(info * $@))
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
@ -501,14 +497,14 @@ distclean: clean
|
||||
help:
|
||||
@echo "make"
|
||||
@echo " build native compiler (from separate objects)"
|
||||
@echo "make cross"
|
||||
@echo " build cross compilers (from one source)"
|
||||
@echo "make ONE_SOURCE=no/yes SILENT=no/yes"
|
||||
@echo " force building from separate/one object(s), less/more silently"
|
||||
@echo "make cross-TARGET"
|
||||
@echo " build one specific cross compiler for 'TARGET'. Currently supported:"
|
||||
@echo " $(wordlist 1,8,$(TCC_X))"
|
||||
@echo " $(wordlist 9,99,$(TCC_X))"
|
||||
@echo "make cross"
|
||||
@echo " build all cross compilers"
|
||||
@echo "make test"
|
||||
@echo " run all tests"
|
||||
@echo "make tests2.all / make tests2.37 / make tests2.37+"
|
||||
|
||||
20
arm-gen.c
20
arm-gen.c
@ -133,11 +133,8 @@ enum {
|
||||
|
||||
#define CHAR_IS_UNSIGNED
|
||||
|
||||
#ifdef TCC_ARM_HARDFLOAT
|
||||
# define ARM_FLOAT_ABI ARM_HARD_FLOAT
|
||||
#else
|
||||
# define ARM_FLOAT_ABI ARM_SOFTFP_FLOAT
|
||||
#endif
|
||||
#define ARM_SOFTFP_FLOAT 0
|
||||
#define ARM_HARD_FLOAT 1
|
||||
|
||||
/******************************************************/
|
||||
#else /* ! TARGET_DEFS_ONLY */
|
||||
@ -160,8 +157,6 @@ ST_DATA const char * const target_machine_defs =
|
||||
#endif
|
||||
;
|
||||
|
||||
enum float_abi float_abi;
|
||||
|
||||
ST_DATA const int reg_classes[NB_REGS] = {
|
||||
/* r0 */ RC_INT | RC_R0,
|
||||
/* r1 */ RC_INT | RC_R1,
|
||||
@ -180,6 +175,7 @@ ST_DATA const int reg_classes[NB_REGS] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
static int float_abi;
|
||||
static int func_sub_sp_offset, last_itod_magic;
|
||||
static int leaffunc;
|
||||
|
||||
@ -241,16 +237,6 @@ static int regmask(int r) {
|
||||
|
||||
/******************************************************/
|
||||
|
||||
#if defined(TCC_ARM_EABI) && !defined(CONFIG_TCC_ELFINTERP)
|
||||
const char *default_elfinterp(struct TCCState *s)
|
||||
{
|
||||
if (s->float_abi == ARM_HARD_FLOAT)
|
||||
return "/lib/ld-linux-armhf.so.3";
|
||||
else
|
||||
return "/lib/ld-linux.so.3";
|
||||
}
|
||||
#endif
|
||||
|
||||
void o(uint32_t i)
|
||||
{
|
||||
/* this is a good place to start adding big-endian support*/
|
||||
|
||||
@ -18,11 +18,6 @@
|
||||
#define PCRELATIVE_DLLPLT 1
|
||||
#define RELOCATE_DLLPLT 1
|
||||
|
||||
enum float_abi {
|
||||
ARM_SOFTFP_FLOAT,
|
||||
ARM_HARD_FLOAT,
|
||||
};
|
||||
|
||||
#else /* !TARGET_DEFS_ONLY */
|
||||
|
||||
#include "tcc.h"
|
||||
|
||||
23
configure
vendored
23
configure
vendored
@ -35,13 +35,11 @@ mingw32="no"
|
||||
LIBSUF=".a"
|
||||
EXESUF=""
|
||||
DLLSUF=".so"
|
||||
tcc_usrinclude=""
|
||||
tcc_sysincludepaths=""
|
||||
tcc_libpaths=""
|
||||
tcc_crtprefix=""
|
||||
tcc_elfinterp=""
|
||||
triplet=
|
||||
tcc_lddir=
|
||||
confvars=
|
||||
suggest="yes"
|
||||
gcc_major=0
|
||||
@ -53,6 +51,7 @@ cpuver=
|
||||
dwarf=
|
||||
targetos=
|
||||
build_cross=
|
||||
quiet=
|
||||
|
||||
# use CC/AR from environment when set
|
||||
test -n "$CC" && cc="$CC"
|
||||
@ -160,8 +159,6 @@ for opt do
|
||||
;;
|
||||
--debug) confvars_set debug
|
||||
;;
|
||||
--with-libgcc) confvars_set libgcc
|
||||
;;
|
||||
--with-selinux) confvars_set selinux
|
||||
;;
|
||||
--tcc-switches=*) assign_opt "$opt" tcc_switches
|
||||
@ -174,6 +171,8 @@ for opt do
|
||||
;;
|
||||
--help|-h) show_help="yes"
|
||||
;;
|
||||
-q) quiet=yes
|
||||
;;
|
||||
*) echo "configure: WARNING: unrecognized option $opt"
|
||||
;;
|
||||
esac
|
||||
@ -197,6 +196,7 @@ Standard options:
|
||||
--docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
|
||||
--mandir=DIR man documentation in DIR [SHAREDIR/man]
|
||||
--infodir=DIR info documentation in DIR [SHAREDIR/info]
|
||||
-q be quiet
|
||||
|
||||
Advanced options (experts only):
|
||||
--source-path=PATH path of source code [$source_path]
|
||||
@ -210,9 +210,8 @@ Advanced options (experts only):
|
||||
--disable-static make libtcc.so instead of libtcc.a
|
||||
--enable-static make libtcc.a instead of libtcc.dll (win32)
|
||||
--disable-rpath disable use of -rpath with libtcc.so
|
||||
--with-libgcc use libgcc_s.so.1 instead of libtcc1.a
|
||||
--with-selinux use mmap for executable memory (tcc -run)
|
||||
--enable-cross build cross compilers (see also 'make help')
|
||||
--enable-cross build all cross compilers (see also 'make help')
|
||||
|
||||
--sysincludepaths=... specify system include paths, colon separated
|
||||
--libpaths=... specify system library paths, colon separated
|
||||
@ -367,6 +366,7 @@ case $targetos in
|
||||
cc=`command -v cc`
|
||||
cc=`readlink $cc || echo clang`
|
||||
tcc_usrinclude="`xcrun --show-sdk-path`/usr/include"
|
||||
default tcc_sysincludepaths "{B}/include:$tcc_usrinclude"
|
||||
if test "${confvars%new_macho*}" = "${confvars}"; then
|
||||
# if new_macho was not specified and (known) ver <= 10, use old (=no)
|
||||
osxver=$(sw_vers -productVersion 2>/dev/null) # X.Y.Z
|
||||
@ -478,7 +478,8 @@ if test -z "$build_cross"; then
|
||||
if test -z "$triplet"; then
|
||||
case $cpu in x86_64|arm64|riscv64)
|
||||
if test -f "/usr/lib64/crti.o" ; then
|
||||
tcc_lddir="lib64"
|
||||
default tcc_libpaths "{B}:/usr/lib64"
|
||||
default tcc_crtprefix "/usr/lib64"
|
||||
fi
|
||||
esac
|
||||
fi
|
||||
@ -552,6 +553,7 @@ fi
|
||||
|
||||
fcho() { if test -n "$2"; then echo "$1$2"; fi }
|
||||
|
||||
if test -z "$quiet"; then
|
||||
fcho "Binary directory " "$bindir"
|
||||
fcho "TinyCC directory " "$tccdir"
|
||||
fcho "Library directory " "$libdir"
|
||||
@ -560,7 +562,6 @@ fcho "Manual directory " "$mandir"
|
||||
fcho "Info directory " "$infodir"
|
||||
fcho "Doc directory " "$docdir"
|
||||
fcho "Target root prefix " "$sysroot"
|
||||
fcho "/usr/include dir " "$tcc_usrinclude"
|
||||
echo "Source path $source_path"
|
||||
echo "Build OS $(uname -m -s)"
|
||||
echo "C compiler $cc ($gcc_major.$gcc_minor)"
|
||||
@ -574,6 +575,7 @@ fcho "Elfinterp " "$tcc_elfinterp"
|
||||
fcho "Switches " "$tcc_switches"
|
||||
fcho "Config " "${confvars# }"
|
||||
echo "Creating config.mak and config.h"
|
||||
fi
|
||||
|
||||
version=$(head "$source_path/VERSION")
|
||||
|
||||
@ -691,7 +693,6 @@ for v in $cpu $confvars ; do
|
||||
esac
|
||||
;;
|
||||
# other
|
||||
CONFIG_libgcc=yes) print_num CONFIG_USE_LIBGCC 1 ;;
|
||||
CONFIG_selinux=yes) print_num CONFIG_SELINUX 1 ;;
|
||||
CONFIG_pie=yes) print_num CONFIG_TCC_PIE 1 ;;
|
||||
CONFIG_pic=yes) print_num CONFIG_TCC_PIC 1 ;;
|
||||
@ -706,13 +707,11 @@ for v in $cpu $confvars ; do
|
||||
esac
|
||||
done
|
||||
|
||||
print_str CONFIG_USR_INCLUDE "$tcc_usrinclude"
|
||||
print_str CONFIG_TCC_SYSINCLUDEPATHS "$tcc_sysincludepaths"
|
||||
print_str CONFIG_TCC_LIBPATHS "$tcc_libpaths"
|
||||
print_str CONFIG_TCC_CRTPREFIX "$tcc_crtprefix"
|
||||
print_str CONFIG_TCC_ELFINTERP "$tcc_elfinterp"
|
||||
print_str CONFIG_TCC_SWITCHES "$tcc_switches"
|
||||
print_str CONFIG_LDDIR "$tcc_lddir"
|
||||
print_str CONFIG_TRIPLET "$triplet"
|
||||
print_str CONFIG_OS_RELEASE "$os_release"
|
||||
echo "#endif" >> $TMPH && echo >> $TMPH
|
||||
@ -724,7 +723,7 @@ print_num CONFIG_TCC_PREDEFS "$predefs"
|
||||
diff $TMPH config.h >/dev/null 2>&1
|
||||
if test $? -ne 0 ; then
|
||||
mv -f $TMPH config.h
|
||||
else
|
||||
elif test -z "$quiet"; then
|
||||
echo "config.h is unchanged"
|
||||
fi
|
||||
|
||||
|
||||
34
libtcc.c
34
libtcc.c
@ -896,8 +896,8 @@ LIBTCCAPI TCCState *tcc_new(void)
|
||||
#if defined TCC_TARGET_MACHO /* || defined TCC_TARGET_PE */
|
||||
s->leading_underscore = 1;
|
||||
#endif
|
||||
#ifdef TCC_TARGET_ARM
|
||||
s->float_abi = ARM_FLOAT_ABI;
|
||||
#ifdef TCC_ARM_HARDFLOAT
|
||||
s->float_abi = ARM_HARD_FLOAT;
|
||||
#endif
|
||||
#ifdef CONFIG_NEW_DTAGS
|
||||
s->enable_new_dtags = 1;
|
||||
@ -995,10 +995,12 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type)
|
||||
/* allow linking with system dll's directly */
|
||||
tcc_add_systemdir(s);
|
||||
# endif
|
||||
|
||||
#elif defined TCC_TARGET_MACHO
|
||||
# ifdef TCC_IS_NATIVE
|
||||
tcc_add_macos_sdkpath(s);
|
||||
# endif
|
||||
|
||||
#else
|
||||
/* paths for crt objects */
|
||||
tcc_split_path(s, &s->crt_paths, &s->nb_crt_paths, CONFIG_TCC_CRTPREFIX);
|
||||
@ -1362,10 +1364,11 @@ struct lopt {
|
||||
/* match linker option */
|
||||
static int link_option(struct lopt *o, const char *q)
|
||||
{
|
||||
const char *p = o->opt;
|
||||
const char *p;
|
||||
int c;
|
||||
|
||||
redo:
|
||||
/* there should be 1 or 2 dashes */
|
||||
p = o->opt;
|
||||
if (*p++ != '-')
|
||||
return 0;
|
||||
if (*p == '-')
|
||||
@ -1378,16 +1381,22 @@ static int link_option(struct lopt *o, const char *q)
|
||||
goto succ; /* -Wl,-opt=arg */
|
||||
++q;
|
||||
}
|
||||
if (c == '=' || c == ':') {
|
||||
if (*p == '\0') {
|
||||
if (c == '|')
|
||||
goto succ;
|
||||
if (c == '=' || c == ':') {
|
||||
if (o->s->link_optind + 1 < o->s->link_argc) {
|
||||
p = o->s->link_argv[++o->s->link_optind];
|
||||
goto succ; /* -Wl,-opt,arg */
|
||||
}
|
||||
o->match = 1; /* -Wl,-opt -Wl,arg */
|
||||
return 0;
|
||||
}
|
||||
} else if (c == ':')
|
||||
goto succ; /* -Wl,-Iarg */
|
||||
}
|
||||
while (*q)
|
||||
if (*q++ == '|')
|
||||
goto redo;
|
||||
return 0;
|
||||
succ:
|
||||
o->arg = p;
|
||||
@ -1415,9 +1424,9 @@ static int tcc_set_linker(TCCState *s, const char *optarg)
|
||||
s->symbolic = 1;
|
||||
} else if (link_option(&o, "nostdlib")) {
|
||||
s->nostdlib_paths = 1;
|
||||
} else if (link_option(&o, "e=") || link_option(&o, "entry=")) {
|
||||
} else if (link_option(&o, "e=|entry=")) {
|
||||
tcc_set_str(&s->elf_entryname, o.arg);
|
||||
} else if (link_option(&o, "image-base=") || link_option(&o, "Ttext=")) {
|
||||
} else if (link_option(&o, "image-base=|Ttext=")) {
|
||||
s->text_addr = strtoull(o.arg, &end, 16);
|
||||
s->has_text_addr = 1;
|
||||
} else if (link_option(&o, "init=")) {
|
||||
@ -1446,18 +1455,17 @@ static int tcc_set_linker(TCCState *s, const char *optarg)
|
||||
#endif
|
||||
else
|
||||
goto err;
|
||||
} else if (link_option(&o, "export-all-symbols")
|
||||
|| link_option(&o, "export-dynamic")) {
|
||||
} else if (link_option(&o, "export-all-symbols|export-dynamic|E")) {
|
||||
s->rdynamic = 1;
|
||||
} else if (link_option(&o, "rpath=")) {
|
||||
tcc_concat_str(&s->rpath, o.arg, ':');
|
||||
} else if (link_option(&o, "dynamic-linker=") || link_option(&o, "I:")) {
|
||||
} else if (link_option(&o, "dynamic-linker=|I:")) {
|
||||
tcc_set_str(&s->elfint, o.arg);
|
||||
} else if (link_option(&o, "enable-new-dtags")) {
|
||||
s->enable_new_dtags = 1;
|
||||
} else if (link_option(&o, "section-alignment=")) {
|
||||
s->section_align = strtoul(o.arg, &end, 16);
|
||||
} else if (link_option(&o, "soname=") || link_option(&o, "install_name=")) {
|
||||
} else if (link_option(&o, "soname=|install_name=")) {
|
||||
tcc_set_str(&s->soname, o.arg);
|
||||
} else if (link_option(&o, "whole-archive")) {
|
||||
s->filetype |= AFF_WHOLE_ARCHIVE;
|
||||
@ -2024,7 +2032,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int *pargc, char ***pargv)
|
||||
s->float_abi = ARM_HARD_FLOAT;
|
||||
else
|
||||
return tcc_error_noabort("unsupported float abi '%s'", optarg);
|
||||
break;
|
||||
continue;
|
||||
#endif
|
||||
case TCC_OPTION_m:
|
||||
if (set_flag(s, options_m, optarg) < 0) {
|
||||
|
||||
2
tcc.c
2
tcc.c
@ -226,7 +226,7 @@ static void print_search_dirs(TCCState *s)
|
||||
printf("libtcc1:\n %s/%s\n", s->library_paths[0], CONFIG_TCC_CROSSPREFIX TCC_LIBTCC1);
|
||||
#ifdef TCC_TARGET_UNIX
|
||||
print_dirs("crt", s->crt_paths, s->nb_crt_paths);
|
||||
printf("elfinterp:\n %s\n", DEFAULT_ELFINTERP(s));
|
||||
printf("elfinterp:\n %s\n", s->elfint);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
44
tcc.h
44
tcc.h
@ -252,15 +252,14 @@ extern long double strtold (const char *__nptr, char **__endptr);
|
||||
#ifndef CONFIG_SYSROOT
|
||||
# define CONFIG_SYSROOT ""
|
||||
#endif
|
||||
|
||||
#if !defined CONFIG_TCCDIR && !defined _WIN32
|
||||
# define CONFIG_TCCDIR "/usr/local/lib/tcc"
|
||||
#endif
|
||||
#ifndef CONFIG_LDDIR
|
||||
# define CONFIG_LDDIR "lib"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TRIPLET
|
||||
# define USE_TRIPLET(s) s "/" CONFIG_TRIPLET
|
||||
# define ALSO_TRIPLET(s) USE_TRIPLET(s) ":" s
|
||||
# define ALSO_TRIPLET(s) USE_TRIPLET(s) PATHSEP s
|
||||
#else
|
||||
# define USE_TRIPLET(s) s
|
||||
# define ALSO_TRIPLET(s) s
|
||||
@ -268,11 +267,8 @@ extern long double strtold (const char *__nptr, char **__endptr);
|
||||
|
||||
/* path to find crt1.o, crti.o and crtn.o */
|
||||
#ifndef CONFIG_TCC_CRTPREFIX
|
||||
# define CONFIG_TCC_CRTPREFIX USE_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USR_INCLUDE
|
||||
# define CONFIG_USR_INCLUDE "/usr/include"
|
||||
# define CONFIG_TCC_CRTPREFIX \
|
||||
USE_TRIPLET(CONFIG_SYSROOT "/usr/lib")
|
||||
#endif
|
||||
|
||||
/* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */
|
||||
@ -280,25 +276,22 @@ extern long double strtold (const char *__nptr, char **__endptr);
|
||||
/* system include paths */
|
||||
#ifndef CONFIG_TCC_SYSINCLUDEPATHS
|
||||
# if defined TCC_TARGET_PE || defined _WIN32
|
||||
# define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include"PATHSEP"{B}/include/winapi"
|
||||
# define CONFIG_TCC_SYSINCLUDEPATHS \
|
||||
"{B}/include" PATHSEP "{B}/include/winapi"
|
||||
# else
|
||||
# define CONFIG_TCC_SYSINCLUDEPATHS \
|
||||
"{B}/include" \
|
||||
":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \
|
||||
":" ALSO_TRIPLET(CONFIG_SYSROOT CONFIG_USR_INCLUDE)
|
||||
"{B}/include" PATHSEP ALSO_TRIPLET(CONFIG_SYSROOT "/usr/include")
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* library search paths */
|
||||
#ifndef CONFIG_TCC_LIBPATHS
|
||||
# if defined TCC_TARGET_PE || defined _WIN32
|
||||
# define CONFIG_TCC_LIBPATHS "{B}/lib"
|
||||
# define CONFIG_TCC_LIBPATHS \
|
||||
"{B}/lib"
|
||||
# else
|
||||
# define CONFIG_TCC_LIBPATHS \
|
||||
"{B}" \
|
||||
":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \
|
||||
":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \
|
||||
":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR)
|
||||
"{B}" PATHSEP ALSO_TRIPLET(CONFIG_SYSROOT "/usr/lib")
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -314,28 +307,19 @@ extern long double strtold (const char *__nptr, char **__endptr);
|
||||
# define CONFIG_TCC_ELFINTERP "/lib64/ld-linux-x86-64.so.2"
|
||||
# elif defined(TCC_TARGET_RISCV64)
|
||||
# define CONFIG_TCC_ELFINTERP "/lib/ld-linux-riscv64-lp64d.so.1"
|
||||
# elif defined(TCC_ARM_EABI)
|
||||
# define DEFAULT_ELFINTERP(s) default_elfinterp(s)
|
||||
# elif defined(TCC_TARGET_ARM)
|
||||
# define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.3"
|
||||
# define CONFIG_TCC_ELFINTERP_ARMHF "/lib/ld-linux-armhf.so.3"
|
||||
# else
|
||||
# define CONFIG_TCC_ELFINTERP "/lib/ld-linux.so.2"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* var elf_interp dans *-gen.c */
|
||||
#ifndef DEFAULT_ELFINTERP
|
||||
# define DEFAULT_ELFINTERP(s) CONFIG_TCC_ELFINTERP
|
||||
#endif
|
||||
|
||||
/* (target specific) libtcc1.a */
|
||||
#ifndef TCC_LIBTCC1
|
||||
# define TCC_LIBTCC1 "libtcc1.a"
|
||||
#endif
|
||||
|
||||
/* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */
|
||||
#if defined CONFIG_USE_LIBGCC && !defined TCC_LIBGCC
|
||||
#define TCC_LIBGCC USE_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) "/libgcc_s.so.1"
|
||||
#endif
|
||||
|
||||
/* <cross-prefix-to->libtcc1.a */
|
||||
#ifndef CONFIG_TCC_CROSSPREFIX
|
||||
# define CONFIG_TCC_CROSSPREFIX ""
|
||||
|
||||
25
tccelf.c
25
tccelf.c
@ -110,6 +110,21 @@ ST_FUNC void tccelf_new(TCCState *s)
|
||||
if (s->elf_entryname)
|
||||
set_global_sym(s, s->elf_entryname, NULL, 0); /* SHN_UNDEF */
|
||||
#endif
|
||||
|
||||
#ifndef ELF_OBJ_ONLY
|
||||
if (NULL == s->elfint && s1->output_type != TCC_OUTPUT_OBJ) {
|
||||
const char *p = CONFIG_TCC_ELFINTERP;
|
||||
#ifdef TCC_TARGET_ARM
|
||||
if (s->float_abi == ARM_HARD_FLOAT)
|
||||
p = CONFIG_TCC_ELFINTERP_ARMHF;
|
||||
#endif
|
||||
#if defined TCC_IS_NATIVE && defined TARGETOS_BSD
|
||||
/* see commit 55cb2170cd5ce77a7d76dcaf462fad2707281605 */
|
||||
{ const char *e = getenv("LD_SO"); if (e) p = e; }
|
||||
#endif
|
||||
s->elfint = tcc_strdup(p);
|
||||
}
|
||||
#endif /* ndef ELF_OBJ_ONLY */
|
||||
}
|
||||
|
||||
ST_FUNC void free_section(Section *s)
|
||||
@ -2939,18 +2954,10 @@ static int elf_output_file(TCCState *s1, const char *filename)
|
||||
|
||||
if (!s1->static_link) {
|
||||
if (file_type & TCC_OUTPUT_EXE) {
|
||||
char *ptr;
|
||||
/* allow override the dynamic loader */
|
||||
const char *elfint = s1->elfint;
|
||||
if (elfint == NULL)
|
||||
elfint = getenv("LD_SO");
|
||||
if (elfint == NULL)
|
||||
elfint = DEFAULT_ELFINTERP(s1);
|
||||
/* add interpreter section only if executable */
|
||||
interp = new_section(s1, ".interp", SHT_PROGBITS, SHF_ALLOC);
|
||||
interp->sh_addralign = 1;
|
||||
ptr = section_ptr_add(interp, 1 + strlen(elfint));
|
||||
strcpy(ptr, elfint);
|
||||
put_elf_str(interp, s1->elfint);
|
||||
dyninf.interp = interp;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user