ARM Technical Support Knowledge Articles

ABSOLUTE FUNCTION ADDRESS

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

How do I locate a C function at an absolute address? I succeeded in variables using _at_, but it doesn't work for functions.

ANSWER

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:

?PR?function_name?file_name

So, the function named func in main.c would have a symbol name of:

?PR?FUNC?MAIN

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:

?PR?_FUNC?MAIN

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:

    ?pr?func?main(C:0x2000)

MORE INFORMATION

Article last edited on: 2006-10-04 09:31:29

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential