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

write Functions at specific locations

Hi All,

I am trying to write functions at specific locations.
I am using KEIL 4 IDE ... and LPC2478
Though I could find a keyword "FIXED" which says one can write function at specific locations, but don't know how to use it .

This is what I want to achieve ....

for eg :

void main(void){
function_1();
function_2();

}

void function_1(){

}

void function_2(){

}

I need "function_1()" to be placed at specific location ...say...address 0x2000.

and

I need "function_2()" to be placed at specific location ...say...address 0x4000.

Can this be achieved ....and if yes How can I do this ?

All suggestions are welcome....
(I could not understand how the keyword "FIXED" works )....

Thanks ...
K.Ganesh

Parents
  • Per,

    I'm using a system that has 3 or even 4 "independent" components (multiple binaries, in effect), and I find it rather handy to have some functions placed at predefined locations (in order to allow hardware drivers to post RTX signals, for example - because the drivers themselves are not linked with RTX). But maybe what you mentioned is a better arrangement so I'm curious: Were you referring to a situation where there are multiple binaries, or a situation where there is only one program from which a partial update can "steal" a symbol to link with?

Reply
  • Per,

    I'm using a system that has 3 or even 4 "independent" components (multiple binaries, in effect), and I find it rather handy to have some functions placed at predefined locations (in order to allow hardware drivers to post RTX signals, for example - because the drivers themselves are not linked with RTX). But maybe what you mentioned is a better arrangement so I'm curious: Were you referring to a situation where there are multiple binaries, or a situation where there is only one program from which a partial update can "steal" a symbol to link with?

Children
  • Using a link table has been used for many years.

    An example is when you have multiple binaries. For example a BIOS and a main application. You don't want the main application to known internal information about the BIOS so instead it gets a table with pointers to use.

    Quite similar (even if OS loader hides much of it) when using dynamic link libraries. The loaded DLL has a table of exported symbols. The main application may either directly use the pointers or the loader may patch the main application to make calls to the target address stored in the lookup table.

    You are way better off with a pointer table than to store functions at absolute addresses. Store the table first or last in the updateable memory region to make it easy to locate. Then let the linker decide where to place the individual functions within the memory block.

  • Looks like fundamental techniques are no longer taught. Doesn't bode well for future products and their safety.

  • For the sake of completeness, implementing such a table also greatly simplifies scatter loading.
    But, doing it the "wrong" way did teach me something else: how to run the preprocessor on a scatter file...!