U-Boot编译——System.map与u-boot.map

U-Boot编译之后会在其顶级目录中生成System.mapu-boot.map两个文件:


1 System.map

    该文件按链接地址由小到大的顺序列出了所有符号:u-boot-2010.03配置编译smdk2410所生成的System.map文件开头部分如下:

[cpp]  view plain  copy
  1. 33f80000 T _start  
  2. 33f80020 t _undefined_instruction  
  3. 33f80024 t _software_interrupt  
  4. 33f80028 t _prefetch_abort  
  5. 33f8002c t _data_abort  
  6. 33f80030 t _not_used  
  7. 33f80034 t _irq  
  8. 33f80038 t _fiq  
  9. 33f80040 t _TEXT_BASE  
  10. 33f80044 T _armboot_start  
  11. 33f80048 T _bss_start  
  12. 33f8004c T _bss_end  
  13. 34f80050 t start_code  
  14. ...  
    由上面信息可知, _start 符号被链接在最前面的地址 0x33f80000 ,它是U-Boot的入口。SDRAM初始化完成后,需要将U-Boot加载到上述地址(SDRAM初始化前,U-Boot在Nor Flash或者芯片内部RAM中运行)。

2 u-boot.map

    u-boot-2010.03配置编译smdk2410所生成的u-boot.map文件开头部分如下:

[cpp]  view plain  copy
  1. Archive member included because of file (symbol)  
  2.   
  3. lib_arm/libarm.a(board.o)     cpu/arm920t/start.o (start_armboot)  
  4. lib_arm/libarm.a(interrupts.o)  
  5.                               lib_arm/libarm.a(board.o) (enable_interrupts)  
  6. net/libnet.a(eth.o)           lib_arm/libarm.a(board.o) (eth_initialize)  
  7. net/libnet.a(net.o)           lib_arm/libarm.a(board.o) (copy_filename)  
  8. net/libnet.a(nfs.o)           net/libnet.a(net.o) (NfsStart)  
  9. net/libnet.a(rarp.o)          net/libnet.a(net.o) (RarpRequest)  
  10. net/libnet.a(tftp.o)          net/libnet.a(net.o) (TftpStart)  
  11. net/libnet.a(bootp.o)         net/libnet.a(net.o) (BootpRequest)  
  12. drivers/serial/libserial.a(serial_s3c24x0.o)  
  13.                               lib_arm/libarm.a(board.o) (serial_init)  
  14. common/libcommon.a(cmd_bdinfo.o)  
  15.                               (__u_boot_cmd_bdinfo)  
  16. common/libcommon.a(cmd_boot.o)  
  17.                               (__u_boot_cmd_go)  
  18. common/libcommon.a(cmd_bootm.o)  
  19.                               lib_arm/libarm.a(board.o) (load_addr)  
  20. common/libcommon.a(cmd_cache.o)  
  21.                               (__u_boot_cmd_icache)  
  22. common/libcommon.a(cmd_console.o)  
  23.                               (__u_boot_cmd_coninfo)  
  24. common/libcommon.a(cmd_date.o)  
  25.                               (__u_boot_cmd_date)  
  26. common/libcommon.a(cmd_echo.o)  
  27.                               (__u_boot_cmd_echo)  
  28. common/libcommon.a(cmd_elf.o)  
  29.                               common/libcommon.a(cmd_bootm.o) (do_bootvx)  
  30. common/libcommon.a(cmd_flash.o)  
  31.                               (__u_boot_cmd_flinfo)  
  32. common/libcommon.a(cmd_help.o)  
  33.                               (__u_boot_cmd_help)  
  34. common/libcommon.a(cmd_itest.o)  
  35.                               (__u_boot_cmd_itest)  
  36. common/libcommon.a(cmd_load.o)  
  37.                               (__u_boot_cmd_loads)  
  38. common/libcommon.a(cmd_mem.o)  
  39.                               (__u_boot_cmd_md)  
  40. common/libcommon.a(cmd_misc.o)  
  41.                               (__u_boot_cmd_sleep)  
  42. common/libcommon.a(cmd_net.o)  
  43.                               (__u_boot_cmd_bootp)  
  44. common/libcommon.a(cmd_nvedit.o)  
  45.                               net/libnet.a(eth.o) (get_env_id)  
  46. common/libcommon.a(cmd_source.o)  
  47.                               (__u_boot_cmd_source)  
  48. common/libcommon.a(cmd_version.o)  
  49.                               (__u_boot_cmd_version)  
  50. common/libcommon.a(cmd_ximg.o)  
  51.                               (__u_boot_cmd_imxtract)  
  52. common/libcommon.a(command.o)  
  53.                               common/libcommon.a(cmd_itest.o) (cmd_get_data_size)  
  54. common/libcommon.a(console.o)  
  55.                               lib_arm/libarm.a(board.o) (printf)  
  56. common/libcommon.a(dlmalloc.o)  
  57.                               common/libcommon.a(cmd_source.o) (free)  
  58. common/libcommon.a(env_common.o)  
  59.                               common/libcommon.a(cmd_nvedit.o) (env_get_addr)  
  60. common/libcommon.a(env_flash.o)  
  61.                               common/libcommon.a(env_common.o) (env_get_char_spec)  
  62. common/libcommon.a(exports.o)  
  63.                               lib_arm/libarm.a(board.o) (jumptable_init)  
  64. common/libcommon.a(flash.o)   common/libcommon.a(cmd_load.o) (addr2info)  
  65. common/libcommon.a(image.o)   common/libcommon.a(cmd_ximg.o) (image_multi_count)  
  66. common/libcommon.a(main.o)    common/libcommon.a(cmd_bootm.o) (run_command)  
  67. common/libcommon.a(s_record.o)  
  68.                               common/libcommon.a(cmd_load.o) (srec_decode)  
  69. common/libcommon.a(stdio.o)   common/libcommon.a(cmd_console.o) (stdio_get_list)  
  70. common/libcommon.a(xyzModem.o)  
  71.                               common/libcommon.a(cmd_load.o) (xyzModem_error)  
  72. board/samsung/smdk2410/libsmdk2410.a(smdk2410.o)  
  73.                               lib_arm/libarm.a(board.o) (dram_init)  
  74. board/samsung/smdk2410/libsmdk2410.a(flash.o)  
  75.                               common/libcommon.a(flash.o) (write_buff)  
  76. board/samsung/smdk2410/libsmdk2410.a(lowlevel_init.o)  
  77.                               cpu/arm920t/start.o (lowlevel_init)  
  78. lib_generic/libgeneric.a(crc16.o)  
  79.                               common/libcommon.a(xyzModem.o) (cyg_crc16)  
  80. lib_generic/libgeneric.a(crc32.o)  
  81.                               common/libcommon.a(cmd_mem.o) (crc32)  
  82. lib_generic/libgeneric.a(display_options.o)  
  83.                               lib_arm/libarm.a(board.o) (print_size)  
  84. lib_generic/libgeneric.a(gunzip.o)  
  85.                               common/libcommon.a(cmd_bootm.o) (gunzip)  
  86. lib_generic/libgeneric.a(net_utils.o)  
  87.                               lib_arm/libarm.a(board.o) (string_to_ip)  
  88. lib_generic/libgeneric.a(string.o)  
  89.                               net/libnet.a(net.o) (strcpy)  
  90. lib_generic/libgeneric.a(time.o)  
  91.                               common/libcommon.a(cmd_load.o) (udelay)  
  92. lib_generic/libgeneric.a(vsprintf.o)  
  93.                               lib_arm/libarm.a(board.o) (simple_strtoul)  
  94. lib_generic/libgeneric.a(zlib.o)  
  95.                               lib_generic/libgeneric.a(gunzip.o) (inflateInit2_)  
  96. lib_generic/libgeneric.a(ctype.o)  
  97.                               lib_generic/libgeneric.a(display_options.o) (_ctype)  
  98. lib_generic/libgeneric.a(div64.o)  
  99.                               lib_generic/libgeneric.a(vsprintf.o) (__div64_32)  
  100. cpu/arm920t/s3c24x0/libs3c24x0.a(speed.o)  
  101.                               drivers/serial/libserial.a(serial_s3c24x0.o) (get_PCLK)  
  102. cpu/arm920t/s3c24x0/libs3c24x0.a(timer.o)  
  103.                               lib_generic/libgeneric.a(time.o) (__udelay)  
  104. lib_arm/libarm.a(bootm.o)     common/libcommon.a(cmd_bootm.o) (do_bootm_linux)  
  105. lib_arm/libarm.a(cache.o)     common/libcommon.a(cmd_elf.o) (flush_cache)  
  106. lib_arm/libarm.a(cache-cp15.o)  
  107.                               common/libcommon.a(cmd_cache.o) (icache_enable)  
  108. lib_arm/libarm.a(reset.o)     common/libcommon.a(cmd_boot.o) (do_reset)  
  109. drivers/net/libnet.a(cs8900.o)  
  110.                               board/samsung/smdk2410/libsmdk2410.a(smdk2410.o) (cs8900_initialize)  
  111. drivers/rtc/librtc.a(date.o)  common/libcommon.a(cmd_date.o) (GregorianDay)  
  112. drivers/rtc/librtc.a(s3c24x0_rtc.o)  
  113.                               common/libcommon.a(cmd_date.o) (rtc_get)  
  114. cpu/arm920t/libarm920t.a(cpu.o)  
  115.                               lib_arm/libarm.a(bootm.o) (cleanup_before_linux)  
  116. /home/liyihai/Mini2440/Toolschain/4.4.3/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.3/libgcc.a(_udivsi3.o)  
  117.                               net/libnet.a(tftp.o) (__aeabi_uidiv)  
  118. /home/liyihai/Mini2440/Toolschain/4.4.3/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.3/libgcc.a(_divsi3.o)  
  119.                               common/libcommon.a(cmd_date.o) (__aeabi_idiv)  
  120. /home/liyihai/Mini2440/Toolschain/4.4.3/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.3/libgcc.a(_lshrdi3.o)  
  121.                               lib_generic/libgeneric.a(vsprintf.o) (__aeabi_llsr)  
  122. /home/liyihai/Mini2440/Toolschain/4.4.3/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.3/libgcc.a(_dvmd_lnx.o)  
  123.                               /home/liyihai/Mini2440/Toolschain/4.4.3/bin/../lib/gcc/arm-none-linux-gnueabi/4.4.3/libgcc.a(_udivsi3.o) (__div0)  
  124.   
  125. Memory Configuration  
  126.   
  127. Name             Origin             Length             Attributes  
  128. *default*        0x00000000         0xffffffff  
  129.   
  130. Linker script and memory map  
  131.   
  132.                 0x00000000                . = 0x0  
  133.                 0x00000000                . = ALIGN (0x4)  
  134.   
  135. .text           0x33f80000    0x13414  
  136.  cpu/arm920t/start.o(.text)  
  137.  .text          0x33f80000      0x400 cpu/arm920t/start.o  
  138.                 0x33f80000                _start  
  139.                 0x33f80044                _armboot_start  
  140.                 0x33f80048                _bss_start  
  141.                 0x33f8004c                _bss_end  
  142.  *(.text)  
  143.  .text          0x33f80400      0x248 lib_arm/libarm.a(board.o)  
  144.                 0x33f80400                coloured_LED_init  
  145.                 0x33f80400                __coloured_LED_init  
  146.                 0x33f80404                red_LED_on  
  147.                 0x33f80404                __red_LED_on  
  148.                 0x33f80408                __red_LED_off  
  149.                 0x33f80408                red_LED_off  
  150.                 0x33f8040c                green_LED_on  
  151.                 0x33f8040c                __green_LED_on  
  152.                 0x33f80410                __green_LED_off  
  153.                 0x33f80410                green_LED_off  
  154.                 0x33f80414                __yellow_LED_on  
  155.                 0x33f80414                yellow_LED_on  
  156.                 0x33f80418                __yellow_LED_off  
  157.                 0x33f80418                yellow_LED_off  
  158.                 0x33f8041c                blue_LED_on  
  159.                 0x33f8041c                __blue_LED_on  
  160.                 0x33f80420                blue_LED_off  
  161.                 0x33f80420                __blue_LED_off  
  162.                 0x33f80424                hang  
  163.                 0x33f804e0                start_armboot  
  164. ...  

    由上述信息可见,u-boot.map中包含了链接过程中涉及的目标文件将其所依赖的库文件,然后所链接的目标文件的先后顺序列出各目标文件中各符号所链接的地址。



 用make命令编译时自动生成的,里面包含所有的函数逻辑地址.
printf("0x%x\n", function_name); /* 这个逻辑地址,可以在u-boot.map里找到对应的函数名,用于是debug查错,相当好,例如函数指针. */

实际上,kernel开发,也常常用syste.map文件.

LDFLAGS += -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)
LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds

这句话同时生成 u-boot.map 和 u-boot
cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \
  --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
  -Map u-boot.map -o u-boot

测试,使用
gcc -Wl,-Map,a.map foo.c -o foo

可生成..map 文件

在u-boot中,就有一种快速方法“从众多的同名函数中找到与我们相关的那一个”:
编译出来完的uboot会生成一个u-boot.map文件,你只要以这个“函数的名字”为关键字去u-boot.map中查找,就能找到编译出来的uboot映像,使用的是哪个文件中的函数了。
比如:uboot源码中对icache_enable函数的定义会存在于很多文件中,那么到底哪个才是与我们有关的呢?
我们只要去u-boot.map文件查找“icache_enable ”,就会看到:
“ .text          0x33f98f18      0x104 cpu/arm920t/libarm920t.a(cpu.o)
                0x33f98fb8                icache_status
                0x33f98fe4                icache_enable    “




  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值