I am unable to reproduce that internal error you experienced. To do that, I need your entire project. Is that something you can do?
It seems you want special handling for the sections .stack and .free_memory. I have ideas about how you might do that. But first I'd appreciate if you would explain exactly what you want to do. Don't worry about how it might be implemented. Just describe the problem you want to solve.
Thanks and regards,
-George