I want to locate a C function at a specific location in the memory. How can I do that?
Regards, Gaurav
As Christoph said, your actual requirement is quite different from the question that you originally asked!
"What you are really trying to do it excluding a certain address range from the pool that the linker uses to locate functions"
Absolutely; and the Linker has specific controls to do exactly that - see the appropriate Linker Manual:
http://www.keil.com/support/man/docs/bl51/ http://www.keil.com/support/man/docs/lx51/
If you're using uVision: www.keil.com/.../uv3_ca_ovwconfigdialogs.htm http://www.keil.com/support/man/docs/uv3/uv3_dg_target51.htm http://www.keil.com/support/man/docs/uv3/uv3_dg_l51loc.htm http://www.keil.com/support/man/docs/uv3/uv3_dg_l251loc.htm
I do not want to place the function at a specific location but I want to avoid certain memory range, specifically the 0-4K range.
It's good that you said that, because that is quite different from "locating a function at a certain address" !
Using the answer you got for the latter address, you would have had to locate all of your functions by hand, and that is a true nightmare.
What you are really trying to do it excluding a certain address range from the pool that the linker uses to locate functions - i.e. you want to modify the memory map.
Well the reason I want to do it is specific to my SoC design. I do not want to place the function at a specific location but I want to avoid certain memory range, specifically the 0-4K range. The reason is that I need switch the 0 to 4K mapping back and forth between the RAM and Flash for accesing the flash. My code is executing from RAM. Hence I need to keep the flash access code in a location other than 0K to 4K range.
I know I can do it my placing the file such that it is compiled last , but that is not safe ...in case my complete binary is less than 4K size.
"I want to locate a C function at a specific location in the memory."
Why do you particularly want to do that?
If you explain what you're actually trying to achieve, people may well be able to suggest a better way of doing it...
Use a linker control. Please read the Macro Assembler and Utilities User Guide, chapter 9 for further details.
E.g. if you want to place function foo() in file bar.c at 0x0200, the control is ?PR?foo?bar(0200h).
Thomas
View all questions in Keil forum