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
172172
173173 ifneq ($(X),)
174174 ifeq ($(CONFIG_WIN32),yes)
175−DEF-win += -DTCC_LIBTCC1="\"$(X)libtcc1.a\""
176−DEF-unx += -DTCC_LIBTCC1="\"lib/$(X)libtcc1.a\""
175+DEF-win += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
176+DEF-unx += -DCONFIG_TCC_CROSSPREFIX="\"lib/$X\""
177177 else
178−DEF-all += -DTCC_LIBTCC1="\"$(X)libtcc1.a\""
178+DEF-all += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
179179 DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\""
180180 endif
181181 endif
libtcc.c+11−1
@@ -1167,14 +1167,24 @@ static int tcc_add_library_internal(TCCState *s, const char *fmt, · 1166 unmodified lines
11671167 return -1;
11681168 }
11691169
1170−#ifndef TCC_TARGET_MACHO
11711170 /* find and load a dll. Return non zero if not found */
11721171 ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags)
11731172 {
11741173 return tcc_add_library_internal(s, "%s/%s", filename, flags,
11751174 s->library_paths, s->nb_library_paths);
11761175 }
1176+
1177+/* find [cross-]libtcc1.a and tcc helper objects in library path */
1178+ST_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;
11771184 #endif
1185+ if (tcc_add_dll(s1, filename, 0) < 0)
1186+ tcc_error_noabort("%s not found", filename);
1187+}
11781188
11791189 #if !defined TCC_TARGET_PE && !defined TCC_TARGET_MACHO
11801190 ST_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
203203 # endif
204204 #endif
205205
206−#if !defined TCC_IS_NATIVE \
207− || (defined CONFIG_TCC_BACKTRACE && CONFIG_TCC_BACKTRACE==0)
206+#if defined CONFIG_TCC_BACKTRACE && CONFIG_TCC_BACKTRACE==0
208207 # undef CONFIG_TCC_BACKTRACE
209208 #else
210209 # 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
285284 # define CONFIG_TCC_LIBPATHS "{B}/lib"
286285 # else
287286 # define CONFIG_TCC_LIBPATHS \
288− ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \
287+ "{B}" \
288+ ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \
289289 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \
290290 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR)
291291 # endif
@@ -1264,9 +1264,8 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) · 972 unmodified lines
12641264 #ifndef ELF_OBJ_ONLY
12651265 ST_FUNC int tcc_add_crt(TCCState *s, const char *filename);
12661266 #endif
1267−#ifndef TCC_TARGET_MACHO
12681267 ST_FUNC int tcc_add_dll(TCCState *s, const char *filename, int flags);
1269−#endif
1268+ST_FUNC void tcc_add_support(TCCState *s1, const char *filename);
12701269 #ifdef CONFIG_TCC_BCHECK
12711270 ST_FUNC void tcc_add_bcheck(TCCState *s1);
12721271 #endif
tccelf.c+0−9
@@ -1299,15 +1299,6 @@ static void add_init_array_defines(TCCState *s1, const char *section_name) · 1298 unmodified lines
12991299 set_global_sym(s1, buf, s, end_offset);
13001300 }
13011301
1302−#ifndef TCC_TARGET_PE
1303−static 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−
13111302 ST_FUNC void add_array (TCCState *s1, const char *sec, int c)
13121303 {
13131304 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
18581858 #define PE_STDSYM(n,s) "_" n s
18591859 #endif
18601860
1861−static 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−
18671861 static void pe_add_runtime(TCCState *s1, struct pe_info *pe)
18681862 {
18691863 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