Keil Logo

ARMLINK: Create and Import a Symdefs File Using Arm Compiler 6


Information in this knowledgebase article applies to:

  • MDK-ARM v4.x and v5.x
  • Arm Compiler 6 toolset

QUESTION

In my target device I have one application image that always resides in ROM and multiple images that are loaded into RAM.

Can the images loaded into RAM can access global functions or variables from the image located in ROM? Can external symbols generated by another project get linked into a µVision project?

ANSWER

The Linker in Arm Compiler tools and the µVision IDE use symbol definitions (symdefs) for this. The steps are:

  • Create a symbdef file for the original ROM image (for exporting)
  • Include (i.e. import) that symdef file in another project
  • Use the symdef file when building the RAM application images

Create a Symdef File

  1. Open the 'ROM' project in µVision.
  2. Go to Project -> Options For Target -> Linker tab and in the Misc controls section, add the armlink option:
    --symdefs=symbols.obj
    
  3. This tells the linker to create a symbdef file called 'symbols.obj', located in the Folder for Objects.
  4. Select Project -> Build.

    The symdefs file has a specific format that consists of all global symbols and their absolute addresses in fixed hexadecimal format. Open this file with a text editor - it will contain an entry similar to:

    #< SYMDEFS ># ARM Linker, 5060750: Last Updated: Tue Feb 06 16:19:22 2018
    ...
    0x08004be0 D foo
    ...
    

    ...This says a global constant foo from the ROM image is located in ROM memory at 0x08004be0.

    Note: See this link on how to output only a subset of the global symbols into a symdefs file.

Import a Symdef File

  1. Open another µVision session. Select Project -> Open and select the 'RAM' project.
  2. (Optional) Using Windows Explorer, copy symbols.obj from the ROM project folder into the RAM project folder. Do this if no further changes are planned for the ROM Project.
  3. In the RAM project, in the Project window add 'symbols.obj' to a project folder. See: Add Source Files to Project.
  4. In the Project window, right click on 'symbols.obj' and select Options for File.... Make sure the File type is Object file, then click the OK button.

Reference Global Symbols in the Symdef File

  1. In a c file, declare this external 'foo' symbol in current project as follows:
    extern uint32_t const foo;
    
  2. Select Project -> Build.
  3. In the Project window, Double-click the target name to open the linker mapping file (*.map).
  4. Search the map file for 'foo' - the application image can access the symbol 'foo' at address '0x08004be0' from another image located in ROM.

    Note: If the original ROM project is still changing, then the symdefs file needs to be updated for the RAM Application project. Use Multi-projects for managing more than one project in a single µVision project environment in the same GUI.

NEXT STEPS

MORE INFORMATION FOR ARM COMPILER 6

MORE INFORMATION FOR ARM COMPILER 5

SEE ALSO

Last Reviewed: Tuesday, February 19, 2019


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.