|ARM Technical Support Knowledge Articles|
Applies to: C51 C Compiler
Information in this article applies to:
How do I locate a C function at an absolute address? I succeeded in variables using _at_, but it doesn't work for functions.
You must use the BL51 Linker or LX51 Linker to locate functions at fixed addresses. To do so, make a note of the function name and the source file in which it is saved. The compiler creates a symbol name for the function using the following format:
So, the function named func in main.c would have a symbol name of:
Everything is uppercase to comply with the OMF51 standard.
There may be derivatives of this naming convention. For example, if the function accepts arguments that can all be passed in registers, the function name is prefixed with an underscore ('_') and the above would be:
You may look in the linker's map file to figure out the symbolic names for your functions.
Once you know the symbolic name, it is a simple matter of telling the linker where to locate it using the CODE directive. For example:
BL51 main.obj code(?pr?func?main(2000h))
Tells the linker to locate the function func at code address 0x2000.
If you use the uVision IDE you may enter the starting address for segments under Project - Options for Target. For the BL51 Linker/Locater enter the following code segment with the address under BL51 Locate - Code. For the LX51 Linker/Locater enter it under LX51 Locate - User Segments:
Article last edited on: 2006-10-04 09:31:29
Did you find this article helpful? Yes No
How can we improve this article?