This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

position independant code

I am trying to write the PIC. I wrote 2 programs in keil. 1 program is residing in the ROM (non PIC). And the second prgram (with-PI) I want to send over UART. I am trying to wrote the program and I also enabled /ropi and /rwpi options, and also tried oputputting the symbol definition file with --symdefs. Somehow I am not able to compile the PIC project. from my inderstanding "main()" is not required and from the startup file I am directly jumping to my_function(). The errors I am getting are pasted below:

toloadAPP.axf: Error: L6241E: toloadapp_startup.o(.text) cannot use the address of 'RWPI (R9 used as SB)' function add2num as the image contains 'USESV6 (R9 used as V6)' functions.
toloadAPP.axf: Error: L6248E: toloadapp_startup.o(.text) in PI region 'ER_RO' cannot have address type relocation to add2num in PI region 'ER_RO'.
toloadAPP.axf: Error: L6285E: Non-relocatable Load region LR_1 contains R-Type dynamic relocations. First R-Type dynamic relocation found in toloadapp_startup.o(.text) at offset 0xc.

The assembly file is as shown below:

                AREA    RESET, DATA, READONLY
               DCD     Reset_Handler             ; Reset Handler

                AREA    |.text|, CODE, READONLY

Reset_Handler   PROC
                EXPORT  Reset_Handler             [WEAK]
                IMPORT  add2num
                LDR     R0, =add2num
                BX      R0
                ENDP
               END

The C file is as below:

int add2num(int a, int b)
{
        return (a + b);
}

Anybody can point to the documentation with which I can proceed further?

Thanks