GCC - How to stop malloc being linked?

前端 未结 2 601
星月不相逢
星月不相逢 2021-01-16 10:09

I am struggling to get my code down to minimal bare bones size! I am using a STM32F0 with only 32k flash and need a good part of the flash for data storage. My code is alr

2条回答
  •  无人及你
    2021-01-16 10:29

    Solved... Some of my code included and called assert. The moment I removed assert calls my code size more than halved! I instead used the STM32 HALs assert_param macro that is a light weight assert that just redirects to a user defined function.

    It would be helpful if someone could explain to me how gcc decides to include library functions when assert is called? I see that assert.h declares an external function __assert_func. How does the linker know to reference it from a library rather than just say "undefined reference to __asert_func"?

提交回复
热议问题