[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] musl dynamic loader libc.so miscompiled with tcc - Re: re
From: |
Michael Ackermann |
Subject: |
[Tinycc-devel] musl dynamic loader libc.so miscompiled with tcc - Re: regression testing with a complete i486-tcc-linux-musl.iso distribution |
Date: |
Fri, 22 Nov 2024 23:16:14 +0000 |
Hi Yao Zi,
thanks for the hint.
For verification of musl-1.2.2 compilation/linking with i386-tcc i've applied
the patch https://www.openwall.com/lists/musl/2024/09/15/1
which didn't yield a working libc.so dynamic loader yet.
I've noticed another iregularity, that is:
- when compiled/linked with latest i386-tcc
# file libc.so
libc.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV),
static-pie linked, not stripped
- which doesn't correspond to gcc-4.7/binutils emitted shared object
# file libc.so
/usr/lib/libc.so: ELF 32-bit LSB shared object, Intel 80386, version 1
(SYSV), dynamically linked, stripped
It is unknown why i386-tcc emits an elf static-pie; which when executed faults:
# ./libc.so
Illegal instruction
The 01-libc_so-snippet.log snippet is attached which shows the linking command
issued with i386-tcc to emit libc.so
(the full ebuild.log file is 2.8MiB in size hence not attached)
Since static linking is fully supported with anything else that is needed for
further testing, the dynamic loader problem doesn't block my work currently.
Hence it isn't the most urgent concern. Reminder, it would only be python that
needed dynamic linking, and there was various other problems with python/libffi
when using i386-tcc compiler/linker. Hence for i486-tcc-linux-musl.iso release
dynamic linking is not considered for immediate support yet.
aggi
On 2024-11-17 18:27, Yao Zi via Tinycc-devel wrote:
> On Fri, Nov 15, 2024 at 06:27:20PM +0000, Michael Ackermann via Tinycc-devel
> wrote:
> > FYI:
> > That is, for regression testing tcc which would have prevented me wasting
> > weeks
> > of bisecting, it is now possible:
> > - to regularly compile/link/boot linux-2.4 x86
> > - and a complete set of ~500 packages that i can support with tcc already
> > (removed all direct and transitive c++ dependencies, among other patches)
>
> Excellent work! A distro entirely built by TinyCC is really a cool
> thing.
>
> > Furthermore i cannot support dynamic-linking with tcc yet, because
> > musl-libc libc.so dynamic loader crashes when compiled/linked with tcc
>
> I had got dynamic linker of musl working on x86_64. The crashes I
> encountered are mostly caused by calls to libc routines in an early
> stage.
>
> For example, TinyCC may emit calls to memcpy() for assignments between
> structures, which is handled in tccgen.c: vstore(). This works most of
> the time, but in the early stage of a dynamic linker, all these symbols
> including memcpy() may have not been relocated, so such a call will jump
> to a dummy address and segfaults.
>
> GCC always emits a stos sequence in this case, which doesn't cause a
> problem. I have done some similar "optimization" for TinyCC x86_64 to
> eliminate the calls, see gen_struct_copy(): x86_64-gen.c. (I'm sorry
> my original implementation was buggy and ugly....)
>
> Another problem is the dynamic loader of musl cannot not handle a
> zero-sized PT_LOAD segment correctly. I've sent an upstream patch[1] for
> it, but there hasn't been any response.
>
> Hope these helps.
>
> > (bootstrappable.org got some patches for musl-libc for support with tcc
> > statically linked);
> > Hence i have to re-bundle what's currently maintained for tcc without
> > ebuilds/portage/crossdev (python needs dynamic linking and fails with tcc),
> > statically linked.
> > Once the distribution is ready and available as a stable(!) baseline i'll
> > summarize ISSUES, so these can be re-produced and verified against it easily
> > without duplicate efforts.
> >
> > Grischka, if that's ok and doesn't cause too much confusion,
> > i would appreciate if efforts are coordinated to avoid future regressions
> > that
> > required bi-secting accross more than 100 commits;
> > for example release tag for 0.9.27 dates back 7 years already, and 0.9.28
> > seems
> > not sufficiently stabilized yet.
> > Anyway, too i am planning to converge and re-integrate the tcc-toolchain
> > system profile that i got with bootstrappable.org
> > That is, currently i cannot publish yet, since it is too much cleanup work
> > remaining to finalize a complete i486-tcc-linux-musl.iso distribution to
> > work
> > and test with, and i rather keep tcc synced to latest HEAD for this ;)
>
> Looking forward to the release! I'm really interested in such a
> distribution.
>
> Cheers,
> Yao Zi
>
> [1]: https://www.openwall.com/lists/musl/2024/09/15/1
>
> _______________________________________________
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
--
01-libc_so-snippet.log
Description: Text document
signature.asc
Description: Digital signature
- [Tinycc-devel] severe regression in TCC compiling and linking kernel since may 2022, Michael Ackermann, 2024/11/12
- Re: [Tinycc-devel] severe regression in TCC compiling and linking kernel since may 2022, Vad Rulezz, 2024/11/12
- Re: [Tinycc-devel] severe regression in TCC compiling and linking kernel since may 2022, Michael Ackermann, 2024/11/12
- Re: [Tinycc-devel] severe regression in TCC compiling and linking kernel since may 2022, Vad Rulezz, 2024/11/12
- Re: [Tinycc-devel] severe regression in TCC compiling and linking kernel since may 2022, grischka, 2024/11/13
- [Tinycc-devel] regression testing with a complete i486-tcc-linux-musl.iso distribution, Michael Ackermann, 2024/11/15
- Message not available
- Message not available
- Re: [Tinycc-devel] regression testing with a complete i486-tcc-linux-musl.iso distribution, Michael Ackermann, 2024/11/16
- Re: [Tinycc-devel] regression testing with a complete i486-tcc-linux-musl.iso distribution, gz8cx4, 2024/11/17
- Re: [Tinycc-devel] regression testing with a complete i486-tcc-linux-musl.iso distribution, Yao Zi, 2024/11/17
- [Tinycc-devel] musl dynamic loader libc.so miscompiled with tcc - Re: regression testing with a complete i486-tcc-linux-musl.iso distribution,
Michael Ackermann <=