Open Blackhex opened 2 months ago
Interesting: fprintf itself is part of the C standard library, using it in a C++ program might indirectly trigger the initialization of parts of the C++ standard library. Constructors etc.
@Blackhex it might be worth taking a look at .init_array or the ctors list in the c++ output. Looking at the disam, ctors looks the same for both but a little weird for c++
0000000140008d78 <__CTOR_LIST__>:
140008d78: ffffffff .inst 0xffffffff ; undefined
140008d7c: ffffffff .inst 0xffffffff ; undefined`
Issue
When the following C/C++ code:
is compiled with
aarch64-w64-mingw32-g++
the control flow does not reachmain
and return code 127 or 123 is returned.aarch64-w64-mingw32-gcc
, it works fine.fprintf
line is removed, it works fine.printf
work fine.aarch64-w64-mingw32-gcc
andaarch64-w64-mingw32-g++
they are identical and when then they are linked withaarch64-w64-mingw32-g++
it fails while withaarch64-w64-mingw32-gcc
it works.-static
the binary works fine.libgcc_s_seh-1.dll
correctly while C linked ones does.aarch64-w64-mingw32-g++
bad-exe.txt and byaarch64-w64-mingw32-gcc
good-exe.txt linkers are showing some differences.