On Sunday 06 September 2026 19:29:27 Zhongteng Gui wrote:
> On 2026/09/06 19:14, Pali Rohár wrote:
> > Ok, I have figured out, where is the problem.
> >
> > There is additional injection of the atexit call from object file:
> > /lib/gcc/{target}/{version}/crtbegin.o
> > which symbols are referenced from another object file:
> > /lib/gcc/{target}/{version}/crtend.o
> >
> >
> > Note that in my setup there are two crtbegin.o and two crtend.o files:
> >
> > /usr/i686-w64-mingw32/lib/crtbegin.o
> > /usr/lib/gcc/i686-w64-mingw32/$GCCVER/crtbegin.o
> >
> > The first one comes from mingw-w64 sources mingw-w64-crt/crt/crtbegin.c
> > And second one from gcc sources libgcc/config/i386/cygming-crtbegin.c
> >
> > And seems that for some setups is gcc using the first one (from
> > mingw-w64 repo) and for others is using second one (from gcc repo).
> >
> > This is really a pain to figure out that the source code on which I'm
> > looking is not the one from which was generated the problematic object
> > file.
> >
> >
> > I do not know how to easily figure out which crtbegin.o file is going to
> > be linked into final test executable. So I would suggest to skip that
> > new test on gcc builds and let it enabled only for clang for now, where
> > is passing.
>
> Just FYI, GCC will generally prioritize its bundled files, unless explicitly
> overridden with `-B`. You can use `gcc -print-search-dirs` and see the
> `libraries:` to verify this. And, even if you added `-B`, e.g. `gcc -B<path>
> -print-search-dirs`, gcc will first search `<path>/<CHOST>/<ver>/`, then
> `<path>` itself, then the default search path (with the first one end with
> `lib/gcc/<CHOST>/<ver>/`).
I see. But this is unsuitable inside the automated test itself (so test
could figure out if it itself should skipped or not).
> >
> > Source code of these gcc files are there:
> > https://github.com/gnutools/gcc/blob/master/libgcc/config/i386/cygming-crtbegin.c
> > https://github.com/gnutools/gcc/blob/master/libgcc/config/i386/cygming-crtend.c
> >
> > As can be seen the atexit call is inside the #if DEFAULT_USE_CXA_ATEXIT
> > and the referenced function named __gcc_deregister_frame has whole code
> > inside the #if DWARF2_UNWIND_INFO.
> >
> > So I would suggest to extend the #if condition for the atexit call to
> > something like: #if DEFAULT_USE_CXA_ATEXIT && DWARF2_UNWIND_INFO which
> > would prevent calling atexit in cases when callback is doing nothing.
> > And this also prevents injecting of atexit for non-dwarf builds. Dwarf
> > is mostly used only for 32-bit x86 mingw-w64 targets (others are SEH).
> >
> >
>
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public