1
0
Fork 0

tccelf: load libtcc1.a from library path

... rather than from tccdir.  Also allows to load cross
versions of bcheck.o etc. (if we would build them which
we currently don't).

18 insertions(+), 24 deletions(-)
This commit is contained in:
grischka 2022-07-23 17:19:56 +02:00
parent d653cf01f3
commit e460f7dbb2
5 changed files with 18 additions and 24 deletions

View File

@ -172,10 +172,10 @@ DEFINES += $(DEF-$(or $(findstring win,$T),unx))
ifneq ($(X),)
ifeq ($(CONFIG_WIN32),yes)
DEF-win += -DTCC_LIBTCC1="\"$(X)libtcc1.a\""
DEF-unx += -DTCC_LIBTCC1="\"lib/$(X)libtcc1.a\""
DEF-win += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
DEF-unx += -DCONFIG_TCC_CROSSPREFIX="\"lib/$X\""
else
DEF-all += -DTCC_LIBTCC1="\"$(X)libtcc1.a\""
DEF-all += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\""
endif
endif

View File

@ -1167,14 +1167,24 @@ static int tcc_add_library_internal(TCCState *s, const char *fmt,
return -1;
}
#ifndef TCC_TARGET_MACHO
/* find and load a dll. Return non zero if not found */
ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags)
{
return tcc_add_library_internal(s, "%s/%s", filename, flags,
s->library_paths, s->nb_library_paths);
}
/* find [cross-]libtcc1.a and tcc helper objects in library path */
ST_FUNC void tcc_add_support(TCCState *s1, const char *filename)
{
#ifdef CONFIG_TCC_CROSSPREFIX
char buf[100];
snprintf(buf, sizeof buf, "%s%s", CONFIG_TCC_CROSSPREFIX, filename);
filename = buf;
#endif
if (tcc_add_dll(s1, filename, 0) < 0)
tcc_error_noabort("%s not found", filename);
}
#if !defined TCC_TARGET_PE && !defined TCC_TARGET_MACHO
ST_FUNC int tcc_add_crt(TCCState *s1, const char *filename)

9
tcc.h
View File

@ -203,8 +203,7 @@ extern long double strtold (const char *__nptr, char **__endptr);
# endif
#endif
#if !defined TCC_IS_NATIVE \
|| (defined CONFIG_TCC_BACKTRACE && CONFIG_TCC_BACKTRACE==0)
#if defined CONFIG_TCC_BACKTRACE && CONFIG_TCC_BACKTRACE==0
# undef CONFIG_TCC_BACKTRACE
#else
# define CONFIG_TCC_BACKTRACE 1 /* enable builtin stack backtraces */
@ -285,7 +284,8 @@ extern long double strtold (const char *__nptr, char **__endptr);
# define CONFIG_TCC_LIBPATHS "{B}/lib"
# else
# define CONFIG_TCC_LIBPATHS \
ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \
"{B}" \
":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \
":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \
":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR)
# endif
@ -1264,9 +1264,8 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
#ifndef ELF_OBJ_ONLY
ST_FUNC int tcc_add_crt(TCCState *s, const char *filename);
#endif
#ifndef TCC_TARGET_MACHO
ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags);
#endif
ST_FUNC void tcc_add_support(TCCState *s1, const char *filename);
#ifdef CONFIG_TCC_BCHECK
ST_FUNC void tcc_add_bcheck(TCCState *s1);
#endif

View File

@ -1299,15 +1299,6 @@ static void add_init_array_defines(TCCState *s1, const char *section_name)
set_global_sym(s1, buf, s, end_offset);
}
#ifndef TCC_TARGET_PE
static void tcc_add_support(TCCState *s1, const char *filename)
{
char buf[1024];
snprintf(buf, sizeof(buf), "%s/%s", s1->tcc_lib_path, filename);
tcc_add_file(s1, buf);
}
#endif
ST_FUNC void add_array (TCCState *s1, const char *sec, int c)
{
Section *s;

View File

@ -1858,12 +1858,6 @@ ST_FUNC void pe_add_unwind_data(unsigned start, unsigned end, unsigned stack)
#define PE_STDSYM(n,s) "_" n s
#endif
static void tcc_add_support(TCCState *s1, const char *filename)
{
if (tcc_add_dll(s1, filename, 0) < 0)
tcc_error_noabort("%s not found", filename);
}
static void pe_add_runtime(TCCState *s1, struct pe_info *pe)
{
const char *start_symbol;