Skip to content

Commit 5ec0e6f

Browse files
author
grischka
committed
some reverts & fixes
workflow: - revert 'pinact for security' for readability from 831c3fa tccpp.c: - remove code that allows tcc to parse numbers incorrectly (*) from 829c848 tccgen.c: - Revert "Relaxed the 'incompatible pointer type' warning a bit" (*) from d9ec17d. tccrun.c: - remove support for -nostdlib -run for simplicity, we require "main" with tcc -run always tccpp.c: - Revert "Free all preprocessor memmory in case of error." from c96f0ca Remove TinyAlloc->limit instead. Thus it can do also bigger allocs. Big TokenStrings (like 200kb+ when compiling tcc) may come from inline functions or from large initializers. Makefile/configure: - use --config-pie for configuring tcc output only - use -fPIC with clang-x86_64 to avoid 32-bit relocs libtcc.c: - fix "tcc file.c -run" i.e. -run as last argument i386-gen.c: - PIC refactor (*) sorry, but code in tcc should have a minimum of generic relevance
1 parent 518279d commit 5ec0e6f

24 files changed

+298
-740
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@ jobs:
99
runs-on: ubuntu-22.04
1010
timeout-minutes: 2
1111
steps:
12-
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
12+
- uses: actions/checkout@v4
1313
- name: make & test tcc (x86_64-linux)
1414
run: ./configure && make && make test -k
1515

1616
test-x86_64-osx:
1717
runs-on: macos-15-intel
1818
timeout-minutes: 2
1919
steps:
20-
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
20+
- uses: actions/checkout@v4
2121
- name: make & test tcc (x86_64-osx)
2222
run: ./configure && make && make test -k
2323

2424
test-aarch64-osx:
2525
runs-on: macos-15
2626
timeout-minutes: 2
2727
steps:
28-
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
28+
- uses: actions/checkout@v4
2929
- name: make & test tcc (aarch64-osx)
3030
run: ./configure && make && make test -k
3131

3232
test-x86_64-win32:
3333
runs-on: windows-2025
3434
timeout-minutes: 6
3535
steps:
36-
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
36+
- uses: actions/checkout@v4
3737
- name: make & test tcc (x86_64-win32)
3838
shell: cmd
3939
run: |
@@ -44,7 +44,7 @@ jobs:
4444
C:\msys64\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-x86_64-gcc"
4545
echo ::endgroup::
4646
C:\msys64\usr\bin\bash -l -c "./configure && make && make test -k"
47-
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
47+
- uses: ilammy/msvc-dev-cmd@v1
4848
with:
4949
arch: amd64
5050
- name: build with MSVC (x86_64-win32)
@@ -61,7 +61,7 @@ jobs:
6161
runs-on: windows-2025
6262
timeout-minutes: 6
6363
steps:
64-
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
64+
- uses: actions/checkout@v4
6565
- name: make & test tcc (i386-win32)
6666
shell: cmd
6767
run: |
@@ -72,7 +72,7 @@ jobs:
7272
C:\msys64\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-i686-gcc"
7373
echo ::endgroup::
7474
C:\msys64\usr\bin\bash -l -c "./configure && make && make test -k"
75-
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
75+
- uses: ilammy/msvc-dev-cmd@v1
7676
with:
7777
arch: x86
7878
- name: build with MSVC (i386-win32)
@@ -89,8 +89,8 @@ jobs:
8989
runs-on: ubuntu-22.04
9090
timeout-minutes: 8
9191
steps:
92-
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
93-
- uses: uraimo/run-on-arch-action@d94c13912ea685de38fccc1109385b83fd79427d # v3.0.1
92+
- uses: actions/checkout@v4
93+
- uses: uraimo/run-on-arch-action@v3
9494
name: make & test tcc (armv7-linux)
9595
with:
9696
arch: armv7
@@ -107,8 +107,8 @@ jobs:
107107
runs-on: ubuntu-22.04
108108
timeout-minutes: 8
109109
steps:
110-
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
111-
- uses: uraimo/run-on-arch-action@d94c13912ea685de38fccc1109385b83fd79427d # v3.0.1
110+
- uses: actions/checkout@v4
111+
- uses: uraimo/run-on-arch-action@v3
112112
name: make & test tcc (aarch64-linux)
113113
with:
114114
arch: aarch64
@@ -125,8 +125,8 @@ jobs:
125125
runs-on: ubuntu-22.04
126126
timeout-minutes: 8
127127
steps:
128-
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
129-
- uses: uraimo/run-on-arch-action@d94c13912ea685de38fccc1109385b83fd79427d # v3.0.1
128+
- uses: actions/checkout@v4
129+
- uses: uraimo/run-on-arch-action@v3
130130
name: make & test tcc (riscv64-linux)
131131
with:
132132
arch: riscv64

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ CFLAGS += $(CPPFLAGS)
2424
VPATH = $(TOPSRC)
2525
-LTCC = $(TOP)/$(LIBTCC)
2626

27-
ifeq ($(CONFIG_pie),yes)
28-
CFLAGS += -fPIE
29-
LDFLAGS += -pie
30-
endif
31-
3227
ifdef CONFIG_WIN32
3328
CFG = -win
3429
ifneq ($(CONFIG_static),yes)
@@ -296,6 +291,11 @@ tcc_p$(EXESUF): $($T_FILES)
296291
libtcc.a: $(LIBTCC_OBJ)
297292
$S$(AR) rcs $@ $^
298293

294+
ifeq ($(CC_NAME)-$(ARCH),clang-x86_64)
295+
# avoid 32-bit relocations in libtcc.a for its usage with tcc -run
296+
libtcc.a: override CFLAGS += -fPIC
297+
endif
298+
299299
# dynamic libtcc library
300300
libtcc.so: $(LIBTCC_OBJ)
301301
$S$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LIBS) $(LDFLAGS)
@@ -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 run_nostdlib.o bt-exe.o bt-dll.o bt-log.o bcheck.o get_pc_thunk.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:
@@ -394,7 +394,7 @@ endif
394394
# uninstall
395395
uninstall-unx:
396396
@rm -fv $(addprefix "$(bindir)/",$(PROGS) $(PROGS_CROSS))
397-
@rm -fv $(addprefix "$(libdir)/", libtcc*.a libtcc*.so libtcc.dylib,$P)
397+
@rm -fv $(addprefix "$(libdir)/", libtcc*.a libtcc*.so libtcc.dylib)
398398
@rm -fv $(addprefix "$(includedir)/", libtcc.h)
399399
@rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
400400
@rm -fv "$(docdir)/tcc-doc.html"

arm-asm.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,8 @@ ST_FUNC void g(int c)
149149
if (nocode_wanted)
150150
return;
151151
ind1 = ind + 1;
152-
if ((unsigned)ind1 > cur_text_section->data_allocated) {
153-
if (ind1 < 0)
154-
tcc_error("program too big");
152+
if (ind1 > cur_text_section->data_allocated)
155153
section_realloc(cur_text_section, ind1);
156-
}
157154
cur_text_section->data[ind] = c;
158155
ind = ind1;
159156
}

arm-gen.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,8 @@ void o(uint32_t i)
257257
if (!cur_text_section)
258258
tcc_error("compiler error! This happens f.ex. if the compiler\n"
259259
"can't evaluate constant expressions outside of a function.");
260-
if ((unsigned)ind1 > cur_text_section->data_allocated) {
261-
if (ind1 < 0)
262-
tcc_error("program too big");
260+
if (ind1 > cur_text_section->data_allocated)
263261
section_realloc(cur_text_section, ind1);
264-
}
265262
cur_text_section->data[ind++] = i&255;
266263
i>>=8;
267264
cur_text_section->data[ind++] = i&255;

arm64-asm.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,8 @@ ST_FUNC void g(int c)
3131
if (nocode_wanted)
3232
return;
3333
ind1 = ind + 1;
34-
if ((unsigned)ind1 > cur_text_section->data_allocated) {
35-
if (ind1 < 0)
36-
tcc_error("program too big");
34+
if (ind1 > cur_text_section->data_allocated)
3735
section_realloc(cur_text_section, ind1);
38-
}
3936
cur_text_section->data[ind] = c;
4037
ind = ind1;
4138
}

arm64-gen.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,8 @@ ST_FUNC void o(unsigned int c)
117117
int ind1 = ind + 4;
118118
if (nocode_wanted)
119119
return;
120-
if ((unsigned)ind1 > cur_text_section->data_allocated) {
121-
if (ind1 < 0)
122-
tcc_error("program too big");
120+
if (ind1 > cur_text_section->data_allocated)
123121
section_realloc(cur_text_section, ind1);
124-
}
125122
write32le(cur_text_section->data + ind, c);
126123
ind = ind1;
127124
}

c67-gen.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,8 @@ void C67_g(int c)
195195
fprintf(f, " %08X", c);
196196
#endif
197197
ind1 = ind + 4;
198-
if ((unsigned)ind1 > (int) cur_text_section->data_allocated) {
199-
if (ind1 < 0)
200-
tcc_error("program too big");
198+
if (ind1 > (int) cur_text_section->data_allocated)
201199
section_realloc(cur_text_section, ind1);
202-
}
203200
cur_text_section->data[ind] = c & 0xff;
204201
cur_text_section->data[ind + 1] = (c >> 8) & 0xff;
205202
cur_text_section->data[ind + 2] = (c >> 16) & 0xff;

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Advanced options (experts only):
230230
--config-new_dtags=yes use new ELF DTAGs (DT_RUNPATH instead of DT_RPATH)
231231
--config-codesign=no do not use codesign on apple to sign executables
232232
--config-dwarf=x use dwarf debug info instead of stabs (x=2..5)
233-
--config-pie compile with pie
233+
--config-pie let tcc generate position independent executables
234234
235235
Cross build options (experimental):
236236
--cpu=CPU target CPU [$cpu]

0 commit comments

Comments
 (0)