A little update on the faulty cross compiler; the problem is most certainly not in the MinGW-w64 libraries, as I swapped the libraries between the reference and faulty toolchains and the results were the same. This leaves the linker...
I tried different Binutils versions and found something interesting; Binutils 2.35.1 and older "successfully" link non-working executables without displaying an error, however later Binutils versions fail to link executables at all and show this error: /opt/mingw-w64/x86_64-w64-mingw32/lib/crt2.o:crtexe.c:(.xdata+0x2c): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32NB against symbol `__C_specific_handler' defined in .text section in /opt/mingw-w64/x86_64-w64-mingw32/lib/libmsvcrt.a(libmsvcrt_defs00071.o) /opt/mingw-w64/x86_64-w64-mingw32/lib/crt2.o:crtexe.c:(.xdata+0x34): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32NB against `.text' /opt/mingw-w64/x86_64-w64-mingw32/lib/crt2.o:crtexe.c:(.xdata+0x38): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32NB against `.text' /opt/mingw-w64/x86_64-w64-mingw32/lib/crt2.o:crtexe.c:(.xdata+0x3c): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32NB against symbol `_gnu_exception_handler' defined in .text section in /opt/mingw-w64/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-crt_handler.o) /opt/mingw-w64/x86_64-w64-mingw32/lib/crt2.o:crtexe.c:(.xdata+0x40): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32NB against `.text' /opt/mingw-w64/x86_64-w64-mingw32/lib/crt2.o:crtexe.c:(.xdata+0x50): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32NB against symbol `__C_specific_handler' defined in .text section in /opt/mingw-w64/x86_64-w64-mingw32/lib/libmsvcrt.a(libmsvcrt_defs00071.o) /opt/mingw-w64/x86_64-w64-mingw32/lib/crt2.o:crtexe.c:(.xdata+0x58): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32NB against `.text' /opt/mingw-w64/x86_64-w64-mingw32/lib/crt2.o:crtexe.c:(.xdata+0x5c): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32NB against `.text' /opt/mingw-w64/x86_64-w64-mingw32/lib/crt2.o:crtexe.c:(.xdata+0x60): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32NB against symbol `_gnu_exception_handler' defined in .text section in /opt/mingw-w64/x86_64-w64-mingw32/lib/libmingw32.a(lib64_libmingw32_a-crt_handler.o) /opt/mingw-w64/x86_64-w64-mingw32/lib/crt2.o:crtexe.c:(.xdata+0x64): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32NB against `.text' /opt/mingw-w64/x86_64-w64-mingw32/lib/crt2.o:crtexe.c:(.pdata+0x0): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status Searches suggest using the flag -mcmodel=medium or -mcmodel=large however neither made a difference... Any ideas? May 29, 2024, 15:14 by its...@tu...: > I did some tests to determine at which stage (compilation, assembly, linking) > the faulty toolchain creates invalid output. This C program (hi.c) is what I > used for testing: > > int main(void) {return 0;} > > 1. Compilation -- `gcc -S file.c` (successful): > With input hi.c, I used the faulty toolchain to create hi.s, and the > reference toolchain to create hi.ref.s, then I compiled both .s files using > the reference toolchain into executables. Both executables worked. > > 2. Assembly -- `as file.s` (successful): > With input hi.s, I used the faulty toolchain to create a.out, and the > reference toolchain to create a.ref.out, then I compiled both .out files > using the reference toolchain into executables. Both executables worked. > > 3. Linking -- `gcc file.out` (FAILED): > With input a.out, I used the faulty toolchain to create a.exe, and the > reference toolchain to create a.ref.exe. Only a.ref.exe worked, which means > there's a problem in the linking stage. After inspecting the full linking > command with -v I found both toolchains are using almost the exact same > flags. The reference toolchain uses a slightly different ordering of -l flags > and adds 2 extra flags (-lgcc_eh -lpthread), however rearranging the -l flags > and removing the 2 extra flags to match the faulty toolchain had no effect. > This means both toolchains are using the correct linking command. > > This leads me to believe that the problem comes from the MinGW-w64 libraries > or the linker (or both)... How can I debug this? > > > _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public