This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to get name,type,address of global variable from AXF?

I want to get name,type,address of global variable from AXF(.AXF is the executable file of keil MDK),I have gotten variable name、address and  rough  type(eg:object represent variable),The question is how to get specific variable type(eg: int,char..), My development environment is keil MDK 5.36 (compiler version 5).

C:\Users\10004265\Desktop\RTC_no_debug_str\Project\MDK-ARM\obj>readelf -S YD_DEMO.axf
There are 16 section headers, starting at offset 0x4ebac:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] ER_IROM1          PROGBITS        08000000 000034 0013c8 00  AX  0   0  4
  [ 2] RW_IRAM1          PROGBITS        20000000 0013fc 00004c 00  WA  0   0  4
  [ 3] RW_IRAM1          NOBITS          2000004c 001448 00042c 00  WA  0   0  8
  [ 4] .debug_abbrev     PROGBITS        00000000 001448 000584 00      0   0  1
  [ 5] .debug_frame      PROGBITS        00000000 0019cc 000978 00      0   0  1
  [ 6] .debug_info       PROGBITS        00000000 002344 008890 00      0   0  1
  [ 7] .debug_line       PROGBITS        00000000 00abd4 0028cc 00      0   0  1
  [ 8] .debug_loc        PROGBITS        00000000 00d4a0 000c24 00      0   0  1
  [ 9] .debug_macinfo    PROGBITS        00000000 00e0c4 03695c 00      0   0  1
  [10] .debug_pubnames   PROGBITS        00000000 044a20 0009aa 00      0   0  1
  [11] .symtab           SYMTAB          00000000 0453cc 001e00 10     12 285  4
  [12] .strtab           STRTAB          00000000 0471cc 001bf8 00      0   0  1
  [13] .note             NOTE            00000000 048dc4 00001c 00      0   0  4
  [14] .comment          PROGBITS        00000000 048de0 005d10 00      0   0  1
  [15] .shstrtab         STRTAB          00000000 04eaf0 00009c 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

  • you may use fromelf.exe combined with the right command line options, instead of readelf:

    www.keil.com/.../armutil_pge1362128925577.htm

  • That is great,the problem is solved .thank you ,Chen Tang.

  • The problem is almost solved,but the variable type is not perfect to me,I want to get type encode value (a number) instead of a type string.The below is my print using fromelf -a xxx.axf

    address     size       variable name                            type
    0x08001ab0  0x10       AHBPrescTable                            array[16] of const volatile uint8_t

    address     size       variable name                            type
    0x20000004  0x4        SystemCoreClock                          uint32_t

    address     size       variable name                            type
    0x08001aac  0x4        ADCPrescTable                            array[4] of const volatile uint8_t

    address     size       variable name                            type
    0x08001ac0  0x10       APBAHBPrescTable                         array[16] of const volatile uint8_t

    address     size       variable name                            type
    0x20000060  0x2        nTime                                    u16

  • hello,Chen Tang,I consult a question,struct nested struct array ,the software readelf can not parse deeperly,for example,in the lash two line,  stCfgInfo.stTxComIdCfg : array[4] of STRUCT_TX_COMID_CFG can not parse deeperly.Thank you !

    -------------------------

    address     size       variable name                            type
    0x20036d1c  0x90       stCfgInfo                                ETH_GW_CFG_DATA
    0x20036d1c  0x4        stCfgInfo.uiLocalIpAddr                  TRDP_IP_ADDR_T
    0x20036d20  0x4        stCfgInfo.uiSubNetMask                   TRDP_IP_ADDR_T
    0x20036d24  0x2        stCfgInfo.nRxComIdNum                    U16
    0x20036d26  0x2        stCfgInfo.nTxComIdNum                    U16
    0x20036d28  0x2        stCfgInfo.bCtrl                          T_CTRL_BIT
    0x20036d28  0x2        stCfgInfo.bCtrl.bits                     ST_CTRL_BIT
    0x20036d28  0x2(15:1)  stCfgInfo.bCtrl.bits.bComReset           U16
    0x20036d28  0x2(0:15)  stCfgInfo.bCtrl.bits.                    U16
    0x20036d28  0x2        stCfgInfo.bCtrl.all                      U16
    0x20036d2a  0x2        stCfgInfo.spare                          U16
    0x20036d2c  0x50       stCfgInfo.stRxComIdCfg                   array[4] of STRUCT_RX_COMID_CFG
    0x20036d7c  0x30       stCfgInfo.stTxComIdCfg                   array[4] of STRUCT_TX_COMID_CFG

    ------------------------