Keil Logo

How to find where a symbol is placed when linking

5.4 How to find where a symbol is placed when linking

To find where a symbol is placed when linking you must find the section that defines the symbol, and ensure that the linker has not removed the section.

You can do this with the --keep="section_id" and --symbols options. For example, if object(section) is the section containing the symbol, enter:
armlink --keep="object(section)" --symbols s.o --output=s.axf      

Note

You can also run fromelf -s on the resultant image.
As an example, do the following:

Procedure

  1. Create the file s.c containing the following source code:
    long long altstack[10] __attribute__ ((section ("STACK"), zero_init));
    
    int main(void)
    {
        return sizeof(altstack);
    }
  2. Compile the source:
    armcc -c s.c -o s.o
  3. Link the object s.o, keeping the STACK symbol and displaying the symbols:
    armlink --keep="s.o(STACK)" --map --symbols s.o --output=s.axf
  4. Locate the STACK symbol in the output, for example:
    ======================================================================
    
    Image Symbol Table
    
        Local Symbols
    
        Symbol Name                        Value     Ov Type        Size  Object(Section)
    …
        STACK                              0x00008200   Section       80  s.o(STACK)
    
        Global Symbols
    
        Symbol Name                        Value     Ov Type        Size  Object(Section)
    …
        altstack                           0x00008200   Data          80  s.o(STACK)
        Image$$ZI$$Limit                   0x00008250   Number         0  s.o(STACK)
    This shows that the stack is placed in the ZI execution region.
Non-ConfidentialPDF file icon PDF versionARM DUI0377H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  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.