On Wed, 2021-10-20 at 22:53 +0800, 桂永林 wrote: > Hellow Tom and Liu Hao, > We encounter another GCC link problem. Our hardware is cotex-M33 > platform, our software project development on windows environment and > use GCC compiler and the gcc-linker as bellow: > > > gcc version 7.3.1 20180622 (release) [ARM/embedded-7-branch > revision 261907] (GNU Tools for Arm Embedded Processors 7-2018-q2- > update) > > GCC: GNU ISO C11 7 2018-q2-update > > GCC parameter: -std=gnu11 > > gcc-linker parameter: --specs=nano.specs --specs=nosys.specs > > Our project need link a C++ static lib into our project. The C++ > lib build enviroment as bellow: > G++:GNU ISO 2011 C++ > G++ parameter:-std=gnu++11 -fabi-version=0 -fno-exceptions -fno- > rtti -fno-use-cxa-atexit -fno-non-call-exceptions > > > > But we found that if we linked the C++ static lib to our program, > then the program have runtime logic problem sometimes. If we do not > link the C++ lib, it can run well. We can not understand why the > reason. We guess, if maybe some gcc linker parameter need used when we > need link the C++ lib? > Can you give us some suggest about how to fix this problem! I think it will be very difficult to tell. Maybe there is some undefined behavior (for example, out-of-bound access) in your program and linking in libstdc++ just changes the memory layout or something and exploits the issue. The undefined behavior may be even triggered by some hardware problem for a embedded system... (I once debugged my program for one day and then found out one capacitor was simply too small!) -- Xi Ruoyao <xry111@xxxxxxxxxxxxxxxx> School of Aerospace Science and Technology, Xidian University