Skip to content

Commit 79ba990

Browse files
author
grischka
committed
2 reverts & 1 small fix
Revert "tccelf: Fix static linking with musl" - Do not use abort() inside of libtcc1.a instead. - This reverts commit 43c7708. Revert "Make bound checking faster." - a few percent speedup from anyway superslow bcheck build does not justify the extra .o file with 200kb, IMO - This reverts commit 0fb5430. Also: - tccelf.c: initialize local 'execstack'
1 parent 772dc70 commit 79ba990

7 files changed

Lines changed: 19 additions & 29 deletions

File tree

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ IR = $(IM) mkdir -p $2 && cp -r $1/. $2
372372
IM = @echo "-> $2 : $1" ;
373373
BINCHECK = $(if $(wildcard $(PROGS) *-tcc$(EXESUF)),,@echo "Makefile: nothing found to install" && exit 1)
374374

375-
EXTRA_O = runmain.o bt-exe.o bt-dll.o bt-log.o bcheck.o bcheck_run.o
375+
EXTRA_O = runmain.o bt-exe.o bt-dll.o bt-log.o bcheck.o
376376

377377
# install progs & libs
378378
install-unx:

‎lib/Makefile‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ Cbc = $(Cbt)$(subst yes,,$(CONFIG_bcheck))
5353
$(Nat)COMMON_O += runmain.o tcov.o
5454
$(Cbt)COMMON_O += bt-exe.o bt-log.o
5555
$(Cbt)WIN_O += bt-dll.o
56-
$(Cbc)COMMON_O += bcheck.o bcheck_run.o
56+
$(Cbc)COMMON_O += bcheck.o
5757

5858
# not in libtcc1.a
59-
EXTRA_O = runmain.o bt-exe.o bt-dll.o bt-log.o bcheck.o bcheck_run.o
59+
EXTRA_O = runmain.o bt-exe.o bt-dll.o bt-log.o bcheck.o
6060

6161
OBJ-i386 = $(I386_O) pic86.o $(LIN_O)
6262
OBJ-x86_64 = $(X86_64_O) va_list.o $(LIN_O)
@@ -95,8 +95,6 @@ $(TOP)/%.o : %.c $(TCC)
9595
$S$(XCC) -c $< -o $@ $(XFLAGS)
9696

9797
$(TOP)/bcheck.o : XFLAGS += $(BFLAGS)
98-
$(TOP)/bcheck_run.o : bcheck.c $(TCC)
99-
$S$(XCC) -c bcheck.c -o $@ $(XFLAGS) $(BFLAGS) -DBCHECK_RUN
10098

10199
$(X)crt1w.o : crt1.c
102100
$(X)wincrt1w.o : wincrt1.c

‎lib/bcheck.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,13 @@ static pthread_spinlock_t bounds_spin;
161161
#define HAVE_SIGNAL (1)
162162
#define HAVE_SIGACTION (1)
163163
#define HAVE_FORK (1)
164-
#if defined(__APPLE__) || defined(__arm__) || defined(__GNUC__) || defined(BCHECK_RUN)
165-
#define HAVE_TLS_FUNC (1)
166-
#define HAVE_TLS_VAR (0)
167-
#else
164+
#if 0 /* !defined(__APPLE__) && defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) */
165+
/* TLS never supported with -run */
168166
#define HAVE_TLS_FUNC (0)
169167
#define HAVE_TLS_VAR (1)
168+
#else
169+
#define HAVE_TLS_FUNC (1)
170+
#define HAVE_TLS_VAR (0)
170171
#endif
171172
#if defined CONFIG_TCC_MUSL || defined __ANDROID__
172173
# undef HAVE_CTYPE

‎lib/va_list.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#if defined __x86_64__
44

55
/* Avoid include files, they may not be available when cross compiling */
6-
extern void abort(void);
6+
/* Also avoid reference to libc */
7+
/* extern void abort(void); */
8+
#define abort() (*(void**)0 = 0)
79

810
/* This should be in sync with our include/stdarg.h */
911
enum __va_arg_type {

‎tccelf.c‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,10 +1839,7 @@ ST_FUNC void tcc_add_runtime(TCCState *s1)
18391839

18401840
#ifdef CONFIG_TCC_BCHECK
18411841
if (s1->do_bounds_check && s1->output_type != TCC_OUTPUT_DLL) {
1842-
if (s1->output_type == TCC_OUTPUT_MEMORY)
1843-
tcc_add_support(s1, "bcheck_run.o");
1844-
else
1845-
tcc_add_support(s1, "bcheck.o");
1842+
tcc_add_support(s1, "bcheck.o");
18461843
# if !(TARGETOS_OpenBSD || TARGETOS_NetBSD)
18471844
tcc_add_library(s1, "dl");
18481845
# endif
@@ -1873,10 +1870,8 @@ ST_FUNC void tcc_add_runtime(TCCState *s1)
18731870
#if defined TCC_TARGET_ARM && TARGETOS_FreeBSD
18741871
tcc_add_library(s1, "gcc_s"); // unwind code
18751872
#endif
1876-
if (TCC_LIBTCC1[0]) {
1873+
if (TCC_LIBTCC1[0])
18771874
tcc_add_support(s1, TCC_LIBTCC1);
1878-
tcc_add_library(s1, "c");
1879-
}
18801875
#ifndef TCC_TARGET_MACHO
18811876
if (s1->output_type != TCC_OUTPUT_MEMORY)
18821877
tccelf_add_crtend(s1);
@@ -2417,7 +2412,7 @@ static int layout_sections(TCCState *s1, int *sec_order, struct dyn_inf *d)
24172412
Section *s;
24182413
addr_t addr, tmp, align, s_align, base;
24192414
ElfW(Phdr) *ph = NULL, *ph2;
2420-
int i, f, n, phnum, phfill, execstack;
2415+
int i, f, n, phnum, phfill, execstack = 0;
24212416
int file_offset;
24222417

24232418
/* compute number of program headers */
@@ -2555,10 +2550,9 @@ static int layout_sections(TCCState *s1, int *sec_order, struct dyn_inf *d)
25552550
if (d->interp)
25562551
fill_phdr(&d->phdr[1], PT_INTERP, d->interp);
25572552
if (execstack) {
2558-
fill_phdr(&d->phdr[execstack], PT_GNU_STACK, NULL);
2559-
d->phdr[execstack].p_flags =
2560-
PF_R | PF_W | (s1->seen_execstack & SHF_EXECINSTR ? PF_X : 0);
2561-
d->phdr[execstack].p_align = 16;
2553+
ph = fill_phdr(&d->phdr[execstack], PT_GNU_STACK, NULL);
2554+
ph->p_flags = PF_R | PF_W | (s1->seen_execstack & SHF_EXECINSTR ? PF_X : 0);
2555+
ph->p_align = 16;
25622556
}
25632557
if (phfill) {
25642558
ph = &d->phdr[0];

‎tccpe.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,12 +2131,8 @@ static void pe_add_runtime(TCCState *s1, struct pe_info *pe)
21312131
#ifdef CONFIG_TCC_BACKTRACE
21322132
if (s1->do_backtrace) {
21332133
#ifdef CONFIG_TCC_BCHECK
2134-
if (s1->do_bounds_check && s1->output_type != TCC_OUTPUT_DLL) {
2135-
if (s1->output_type == TCC_OUTPUT_MEMORY)
2136-
tcc_add_support(s1, "bcheck_run.o");
2137-
else
2138-
tcc_add_support(s1, "bcheck.o");
2139-
}
2134+
if (s1->do_bounds_check && s1->output_type != TCC_OUTPUT_DLL)
2135+
tcc_add_support(s1, "bcheck.o");
21402136
#endif
21412137
if (s1->output_type == TCC_OUTPUT_EXE)
21422138
tcc_add_support(s1, "bt-exe.o");

‎win32/build-tcc.bat‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ exit /B %ERRORLEVEL%
201201
.\%1tcc -B. -c ../lib/builtin.c
202202
.\%1tcc -ar lib/%1libtcc1.a %LIBTCC1%.o crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o winex.o chkstk.o alloca.o alloca-bt.o stdatomic.o atomic.o builtin.o
203203
.\%1tcc -B. -c ../lib/bcheck.c -o lib/%1bcheck.o -bt -I..
204-
.\%1tcc -B. -c ../lib/bcheck.c -o lib/%1bcheck_run.o -bt -I.. -DBCHECK_RUN
205204
.\%1tcc -B. -c ../lib/bt-exe.c -o lib/%1bt-exe.o
206205
.\%1tcc -B. -c ../lib/bt-log.c -o lib/%1bt-log.o
207206
.\%1tcc -B. -c ../lib/bt-dll.c -o lib/%1bt-dll.o

0 commit comments

Comments
 (0)