zoukankan      html  css  js  c++  java
  • u-boot之ldrpc_start_armboot解析

    u-boot之ldrpc_start_armboot解析

    2008年07月02日02:21 来源:ChinaUnix博客 作者:osama123 编辑:周荣茂 评论:0
    本文Tag: Linux系统管理

        在cpu/arm920t/start.S中,将text relocate 到Ram后,其代码段的最后1行有条语句:

        ldr pc _start_armboot

        _start_armboot: .word start_armboot

         start_armboot是一个函数指针,这个symbol对应了符号表里的函数地址,这个函数是一个C语言的函数,他就是u-boot的stage2的入口点,这个stage2应该是在RAM里面执行的。问题就来了,既然我们只是手动将text relocate到了RAM里面,此时FLASH和RAM里面都有start_armboot的代码,为什么程序就要跳转到RAM里,而不是依然在FLASH里?

         我最初感觉除非是ld在连接的时候,修改了符号表里的内容,指定start_armboot符号的地址是RAM里的地址,这样只要我们执行时取其地址,取到的肯定是RAM中的地址。

         经查阅资料,有如下一段解释:

        转自:http://www.mail-archive.com/u-boot-users@lists.sourceforge.net/msg04018.html

        ----- Original Message ----

        > > > > From: Vishal Oliyil Kunnil

        > > > > To: Tiju

        > > > >

        > > > > Sent: Monday, 31 March, 2008 2:58:12 PM

        > > > > Subject: Re: [U-Boot-Users] s3c2440 -- serial_init

        > > > >

        > > > > TEXT_BASE is the address for which u-boot is linked for.If you take an

        > > > > objdump of u-boot

        > > > > elf, you will see that it links for address beginning with that

        > > > > specified by TEXT_BASE.

        > > > > Meaning, you link for the address thus specified.

        > > > > Typically the binary will be run from the reset vector of the

        > > > > processor, which is not necessarily

        > > > > TEXT_BASE : say 0x0 flash address. U-boot starts executing from the

        > > > > reset vector,

        > > > > relocates to RAM and since it is linked for TEXT_BASE, the ldr pc,

        > > > > _start_armboot

        > > > > will branch to the start_armboot which is in RAM.

        > > > > -------snip - start.S --------------

        > > > > ldr pc, _start_armboot

        > > > > _start_armboot: .word start_armboot

        > > > > -------snip - start.S --------------

        > > > > Regards,

        > > > > Vishal 上面的意思是说,我们在u-boot的C代码的编译环境里制定了TEXT_BASE的值,然后所有生成的C函数的可执行代码都是以TEXT_BASE作为连接基地址,而不是我们的0x00000000(u-boot在FLASH开始执行的起始地址),也就是说这是我们u-boot的代码中在FLASH里,除了最开始的一部分汇编码是在FLASH里执行的,其他由C语言实现的部分都只能在RAM里执行,因为我们给他们定好的基地址就是RAM的地址。

        

        

        

        

        本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/72383/showart_1071034.html

  • 相关阅读:
    Windows SDK编程(Delphi版) 之 应用基础,楔子
    一个小问题引发的论证思考
    Delphi 组件开发教程指南(7)继续模拟动画显示控件
    用PyInstaller将python转成可执行文件exe笔记
    使用 .Net Memory Profiler 诊断 .NET 应用内存泄漏(方法与实践)
    Microsof Office SharePoint 2007 工作流开发环境搭建
    How to monitor Web server performance by using counter logs in System Monitor in IIS
    LINQ之Order By
    window 性能监视器
    内存泄露检测工具
  • 原文地址:https://www.cnblogs.com/liuwen1987/p/3504711.html
Copyright © 2011-2022 走看看