History

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(-)

grischka committed 4 years ago

Commit e460f7d1 parent d653cf05 files · +18 −24Browse files

Unified · Split

5 files
  1. Makefile +3 −3
  2. libtcc.c +11 −1
  3. tcc.h +4 −5
  4. tccelf.c +0 −9
  5. tccpe.c +0 −6
Makefile+3−3
@@ -172,10 +172,10 @@ DEFINES += $(DEF-$(or $(findstring win,$T),unx)) · 171 unmodified lines
172 172
173ifneq ($(X),)173ifneq ($(X),)
174ifeq ($(CONFIG_WIN32),yes)174ifeq ($(CONFIG_WIN32),yes)
175DEF-win += -DTCC_LIBTCC1="\"$(X)libtcc1.a\""175DEF-win += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
176DEF-unx += -DTCC_LIBTCC1="\"lib/$(X)libtcc1.a\""176DEF-unx += -DCONFIG_TCC_CROSSPREFIX="\"lib/$X\""
177else177else
178DEF-all += -DTCC_LIBTCC1="\"$(X)libtcc1.a\""178DEF-all += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
179DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\""179DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\""
180endif180endif
181endif181endif
libtcc.c+11−1
@@ -1167,14 +1167,24 @@ static int tcc_add_library_internal(TCCState *s, const char *fmt, · 1166 unmodified lines
1167 return -1;1167 return -1;
1168}1168}
1169 1169
1170#ifndef TCC_TARGET_MACHO
1171/* find and load a dll. Return non zero if not found */1170/* find and load a dll. Return non zero if not found */
1172ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags)1171ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags)
1173{1172{
1174 return tcc_add_library_internal(s, "%s/%s", filename, flags,1173 return tcc_add_library_internal(s, "%s/%s", filename, flags,
1175 s->library_paths, s->nb_library_paths);1174 s->library_paths, s->nb_library_paths);
1176}1175}
1176
1177/* find [cross-]libtcc1.a and tcc helper objects in library path */
1178ST_FUNC void tcc_add_support(TCCState *s1, const char *filename)
1179{
1180#ifdef CONFIG_TCC_CROSSPREFIX
1181 char buf[100];
1182 snprintf(buf, sizeof buf, "%s%s", CONFIG_TCC_CROSSPREFIX, filename);
1183 filename = buf;
1177#endif1184#endif
1185 if (tcc_add_dll(s1, filename, 0) < 0)
1186 tcc_error_noabort("%s not found", filename);
1187}
1178 1188
1179#if !defined TCC_TARGET_PE && !defined TCC_TARGET_MACHO1189#if !defined TCC_TARGET_PE && !defined TCC_TARGET_MACHO
1180ST_FUNC int tcc_add_crt(TCCState *s1, const char *filename)1190ST_FUNC int tcc_add_crt(TCCState *s1, const char *filename)
tcc.h+4−5
@@ -203,8 +203,7 @@ extern long double strtold (const char *__nptr, char **__endptr); · 202 unmodified lines
203# endif203# endif
204#endif204#endif
205 205
206#if !defined TCC_IS_NATIVE \206#if defined CONFIG_TCC_BACKTRACE && CONFIG_TCC_BACKTRACE==0
207 || (defined CONFIG_TCC_BACKTRACE && CONFIG_TCC_BACKTRACE==0)
208# undef CONFIG_TCC_BACKTRACE207# undef CONFIG_TCC_BACKTRACE
209#else208#else
210# define CONFIG_TCC_BACKTRACE 1 /* enable builtin stack backtraces */209# define CONFIG_TCC_BACKTRACE 1 /* enable builtin stack backtraces */
@@ -285,7 +284,8 @@ extern long double strtold (const char *__nptr, char **__endptr); · 74 unmodified lines
285# define CONFIG_TCC_LIBPATHS "{B}/lib"284# define CONFIG_TCC_LIBPATHS "{B}/lib"
286# else285# else
287# define CONFIG_TCC_LIBPATHS \286# define CONFIG_TCC_LIBPATHS \
288 ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \287 "{B}" \
288 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \
289 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \289 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \
290 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR)290 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR)
291# endif291# endif
@@ -1264,9 +1264,8 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) · 972 unmodified lines
1264#ifndef ELF_OBJ_ONLY1264#ifndef ELF_OBJ_ONLY
1265ST_FUNC int tcc_add_crt(TCCState *s, const char *filename);1265ST_FUNC int tcc_add_crt(TCCState *s, const char *filename);
1266#endif1266#endif
1267#ifndef TCC_TARGET_MACHO
1268ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags);1267ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags);
1269#endif1268ST_FUNC void tcc_add_support(TCCState *s1, const char *filename);
1270#ifdef CONFIG_TCC_BCHECK1269#ifdef CONFIG_TCC_BCHECK
1271ST_FUNC void tcc_add_bcheck(TCCState *s1);1270ST_FUNC void tcc_add_bcheck(TCCState *s1);
1272#endif1271#endif
tccelf.c+0−9
@@ -1299,15 +1299,6 @@ static void add_init_array_defines(TCCState *s1, const char *section_name) · 1298 unmodified lines
1299 set_global_sym(s1, buf, s, end_offset);1299 set_global_sym(s1, buf, s, end_offset);
1300}1300}
1301 1301
1302#ifndef TCC_TARGET_PE
1303static void tcc_add_support(TCCState *s1, const char *filename)
1304{
1305 char buf[1024];
1306 snprintf(buf, sizeof(buf), "%s/%s", s1->tcc_lib_path, filename);
1307 tcc_add_file(s1, buf);
1308}
1309#endif
1310
1311ST_FUNC void add_array (TCCState *s1, const char *sec, int c)1302ST_FUNC void add_array (TCCState *s1, const char *sec, int c)
1312{1303{
1313 Section *s;1304 Section *s;
tccpe.c+0−6
@@ -1858,12 +1858,6 @@ ST_FUNC void pe_add_unwind_data(unsigned start, unsigned end, unsigned stack) · 1857 unmodified lines
1858#define PE_STDSYM(n,s) "_" n s1858#define PE_STDSYM(n,s) "_" n s
1859#endif1859#endif
1860 1860
1861static void tcc_add_support(TCCState *s1, const char *filename)
1862{
1863 if (tcc_add_dll(s1, filename, 0) < 0)
1864 tcc_error_noabort("%s not found", filename);
1865}
1866
1867static void pe_add_runtime(TCCState *s1, struct pe_info *pe)1861static void pe_add_runtime(TCCState *s1, struct pe_info *pe)
1868{1862{
1869 const char *start_symbol;1863 const char *start_symbol;

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