GCC link problem help!
桂永林
guiyonglin@huaqin.com
Thu Oct 21 03:36:35 GMT 2021
Hello Xi Ruoyao,
Thanks for your reply! I can confirm that our hardware can work well, since if I link another C lib to replace the C++ lib with same function, the program can work well. So, I guess this problem maybe related with my c++ lib, and the only difference is that the c++ lib is build by G++ and g++linker.
If there is some special parameter we need check, when we link the c++ lib to C program with C linker?
Thanks!
Best regards,
Operagui
发件人:Xi Ruoyao <xry111@mengyan1223.wang>
发送时间:2021-10-21 00:17
主题:Re: GCC link problem help!
收件人:"桂永林/图灵研究院软件三部/图灵研究院"<guiyonglin@huaqin.com>,"LIU Hao"<lh_mouse@126.com>,"Tom Kacvinsky"<tkacvins@gmail.com>
抄送:"gcc-help"<gcc-help@gcc.gnu.org>,"柳茂昕/图灵研究院软件三部/图灵研究院"<liumaoxin@huaqin.com>,"李闯闯/图灵研究院软件三部/图灵研究院"<lichuangchuang@huaqin.com>,"汤汝/图灵研究院软件三部/图灵研究院"<tangru@huaqin.com>
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@mengyan1223.wang>
School of Aerospace Science and Technology, Xidian University
More information about the Gcc-help
mailing list