Hi, I'm using the latest commit up to now, I created a simple hello
world example, compiled it and ran it, however it seg faulted. Output
below:
# ./a.out
Segmentation fault (core dumped)
Using strace I was able to id the problem:
# strace a.out
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
execve("/bin/a.out", 0x5dfabbb57420, 0x7ffe3d340c30) = -1 ENOENT (No
such file or directory)
SYS_20(0x2, 0x7ffe3d3406c0, 0x2, 0x7f1eb10458c0, 0x7fffffff, NULLstrace: ) = 8
SYS_20(0x2, 0x7ffe3d3407a0, 0x2, 0x7f1eb10458c0, 0x7fffffff, NULLexec
a.out) = 10
SYS_20(0x2, 0x7ffe3d3406c0, 0x2, 0x7f1eb10458c0, 0x7fffffff, NULL: No
such file or directory) = 27
SYS_20(0x2, 0x7ffe3d340930, 0x2, 0x7f1eb10458c0, 0x7fffffff, NULL
) = 1
exit_group(127+++ stopped with 19 +++
The execve call is using the wrong path! Since a.out is not in /bin.
Calling ld to run a.out gives the correct result:
# strace ld ./a.out
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
execve("/bin/ld", 0x65330c419420, 0x7ffd5df5de38) = 0
[stopped 1407 (5)]
arch_prctl(4098, 0x7d3d66b32b68) = 0
set_tid_address(0x7d3d66b32fd0) = 34645
open("./a.out", 32768, O_RDONLY, 0) = 3
read(3, "\x7fELF\x02\x01\x01", 960) = 960
mmap(0x400000, 6295552, PROT_READ, MAP_PRIVATE, 3, 0) = 0x400000
mmap(0x600000, 4096, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 3, 0)
= 0x600000
mmap(0x800000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
0) = 0x800000
mmap(0xa00000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3,
0) = 0xa00000
close(3) = 0
brk(NULL) = 0x555569277000
brk(0x555569279000) = 0x555569279000
mmap(0x555569277000, 4096, PROT_NONE,
MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0) = 0x555569277000
mprotect(0x7d3d66b2f000, 4096, PROT_READ) = 0
ioctl(1, TIOCGWINSZ, {ws_row=83, ws_col=171, ws_xpixel=1372,
ws_ypixel=1415}) = 0
SYS_20(0x1, 0x7ffcf7278f70, 0x2, 0x10, 0x7d3d66b302c0, 0x800518hello from lin0
) = 16
exit_group(16+++ stopped with 19 +++
I'm not sure if this is a compiler issue. I'm using musl 1.2.5 on
x86_64,
my tcc -vv output is:
tcc version 0.9.28rc 2024-10-05 mob@6ddc45c0 (x86_64 Linux)
install: //lib/tcc
include:
/include
libraries:
/lib
libtcc1:
/lib/libtcc1.a
crt:
/lib
elfinterp:
/lib/libc.so
Can I have some help please?
Thanks!
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel