AnsweredAssumed Answered

Debug non-contiguous PIC binary in CodeWarrior

Question asked by Yan Zhang on Mar 26, 2018
Latest reply on Mar 30, 2018 by Yiping Wang



I have CodeWarrior 10.0.9, which connects to a NXP ls1021a-twr board. There is no OS running on the board except a test app. And we wrote a simple loader to load PIC images. Previously I had a Position Independent Executable(PIE) image, which is loaded into RAM contiguously. The loaded address will be printed on console. So in CodeWarrior, I can just use loadsym and setpicloadaddr commands to debug the binary.


However, currently, I have to modify the loader to load sections into non-contiguous memory. For example, load .text section into memory start from 0x87200000, and load .rodata, .data, and .bss sections into memory start from 0x85200000. Those numbers are just an example here. I was able to get this mechanism working with the help of compiler(compile with option -mno-pic-data-is-text-relative), and some tweaks in relocation logic. Now the problem I have is I couldn't debug the binary in CodeWarrior anymore. I can still setpicloadaddr to 0x87200000. The code execution is good, but the data addresses are all messed up. I think setpicloadaddr command assumes that the PIC image is loaded into one contiguous memory, which is not the case. 


Is there any way to make CodeWarrior display correct data addresses while text and data are loaded into non-contiguous memory?


Please let me know if you need more information.


Thank you for your help.