共1条
1/1 1 跳转至页
[转帖]loadModuleAt

I want to use the loadModuleAt command to get around the 24 bit relocation (32meg) restriction. I don't want to compile with -mlongcall because of performance reasons I cannot afford. However, I also need the system to have more of the 128meg available than just 32meg. My problem is how do I know a safe location for text, data, and Bss? What globals and calls (like sysMemTop()) and others can I use to determine where to place the next module? I am loading several modules.
Hello,
Using loadModuleAt is not the way to get around the 24 bit relocation limit. Since you don't want to use the -mlongcall option, you have a few possibilities:
1) Set USER_RESERVED_MEM to be 96MB (i.e. 128MB - 32MB). That will leave just 32MB for the kernel initially. Load all your modules at the start of execution, then, once they are loaded, you can use memAddToPool() to add the reserved 96MB into the system memory partition.
2) Again, reserve the upper section of the memory, but this time don't add it to the system pool. Instead, use it for your application's dynamic allocation requirements. Create a memory partition in there using memPartCreate(), then allocate and free directly from it using memPartAlloc() and memPartFree().
If you really want to try to use loadModuleAt(), one trick you perhaps get away with would be to move the data/bss segments above the 32MB line, and keep the code below. To do this though will require some ingenuity:
a) You will need to reserve the upper memory again.
b) As soon as the system starts up, allocate a block from the heap that will be used for the text segments - make sure it is large enough for all the text segments you plan to load. Use this allocated block to create a new memory partition - the text partition.
c) Use memAddToPool() to add back the reserved memory.
Now, when you want to load a file, simply allocate enough memory for the text from the text partition, and allocate enough memory for the data+bss from the system heap. Then use loadModuleAt() to load the module.
There is one little thing that you will need to do first though: work out the sizes of the segments so that you know how much memory to allocate. I don't believe that there is an API for that, so you'd probably have to open the file and read the OMF headers yourself to work it out.
HTH,
John...
关键词: 转帖 loadModuleAt
共1条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【EEPW电子工程师创研计划】技术变现通道已开启~ | |
发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
【EEPW在线】E起听工程师的声音! | |
“我踩过的那些坑”主题活动——第001期 | |
高校联络员开始招募啦!有惊喜!! | |
【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
送您一块开发板,2025年“我要开发板活动”又开始了! | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
多组DCTODC电源方案被打赏50分 | |
【我踩过的那些坑】STM32cubeMX软件的使用过程中的“坑”被打赏50分 | |
新手必看!C语言精华知识:表驱动法被打赏50分 | |
【我踩过的那些坑】杜绑线问题被打赏50分 | |
【我踩过的那些坑】STM32的硬件通讯调试过程的“坑”被打赏50分 | |
【我踩过的那些坑】晶振使用的问题被打赏100分 | |
【我踩过的那些坑】电感选型错误导致的处理器连接不上被打赏50分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏10分 | |
【我踩过的那些坑】DRC使用位置错误导致的问题被打赏100分 | |
我踩过的那些坑之混合OTL功放与落地音箱被打赏50分 |