0

Hi.

Library: optlib.

Malloc is working at the beginning, but when __last_heap_object reach end of RAM it’s trying to reserve memory out of RAM. Meanwhile I free allocated before memory.

After some debugging I found top_of_heap() return stack pointer(SP), but my stack is at the beginning of RAM and when malloc thinks after subtraction(SP – __last_heap_object=e.g.(uint32_t)-1234 = 0xFFFFFB2E) there is always spare memory to allocate.

I was trying to define my top_of_heap() but linker was very angry: ld.exe: Disabling relaxation: it will not work with multiple definitions

Moving stack at the end of RAM is also not best solution as if malloc will try to allocate memory right next to SP it block stack from further grow :(

I suggest to add opportunity to redefine top_of_heap(), but dont know exactly how, maybe add weak to declaration or sth?

Other solution would be global variable like __to_of_heap_address set to zero, but user can redefine it and top_of_heap() will take it first instead of SP.

GNU Tools Support commented
    • Hello,

      Unfortunately, there are no plans for further developing the Optlib library.

      Starting with the latest, 2019q4 GCC for Renesas release, the optlib library is considered deprecated. All reasons for this decision are stated in the release notes for both RX and RL78 compilers.

      We encourage you to start looking for the newlib alternative when taking into consideration new projects.

      We apologize if this causes any inconvenience,
      The GNU Tools Team