ARM Technical Support Knowledge Articles

LOCATING VARIABLES TO FIXED ADDRESSES

Applies to: C166 C Compiler

Answer


Information in this article applies to:


QUESTION

How do I locate a global variable at a specific address?

ANSWER

To locate a C166 C global variable to a specific address...

  1. Create a C file that contains only that global variable.
  2. Compile the C file as normal.
  3. Link as normal. Review the linker map file (*.M66) and find the variable name in the "PUBLIC SYMBOLS OF MODULE" section of the map file. For example, the global variable junk_var appears as follows in the Public Symbols section:
    VALUE     PUBLIC SYMBOL NAME      REP   TGR  CLASS   SECTION NAME
    =================================================================
    000000H   RESET                   INTNO ---  ---     ---
    00AAAAH   junk_var                VAR   ---  NDATA0  ?ND0?MAIN
    000004H   main                    LABEL ---  NCODE   ?PR?MAIN
    
  4. Add a section to the linker command line that specifies the location for your global variable. For example, the section name to use for junk_var is ?ND0?MAIN%NDATA0. The linker command line to locate this sections is:
    L166 ???.OBJ  TO  OUTFILE.ABS  SECTIONS(?ND0?MAIN%NDATA0(0x006000))
    

In uVision, you may specify the section information in the Sections Tab of the Linker Options:

?ND0?MAIN%NDATA0(0x006000)

MORE INFORMATION

Article last edited on: 2005-07-15 10:38:52

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