Debug non-contiguous PIC binary in CodeWarrior

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Debug non-contiguous PIC binary in CodeWarrior

738 Views
yanzhang
Contributor I

Hi,

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.

Yan

0 Kudos
Reply
1 Reply

614 Views
yipingwang
NXP TechSupport
NXP TechSupport

For .data related sections relocation, you could define it in CodeWarrior lcf file. For example, you could define .data section as the following, please define a ram1 memory region starting at 0x8522f800, then relocate .data section to ram1.

MEMORY
{

rom (rx) : ORIGIN = 0x60100000, LENGTH = 1M
ram (rwx) : ORIGIN = 0x10000000, LENGTH = 128K
ram1 (rwx) : ORIGIN = 0x8522f800, LENGTH = 1M
}

SECTIONS
{
... ...
.data :
AT (erom)
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */

. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} > ram1
... ...
}

For detailed information about LCF file, you could refer to the ROM version lcf file in LS1021A sample project provided in CodeWarrior.

After create a bare board project in CodeWarrior IDE, please modify the project to ROM version, and refer to the file LS102xA_rom.ld.


Have a great day,
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply