u-boot-2014.10移植第6天----深入分析代码(一)
来源:互联网 发布:rsync ssh 端口 编辑:程序博客网 时间:2024/04/25 12:15
硬件平台:tq2440
开发环境:Ubuntu-3.11
u-boot版本:2014.10
本文允许转载,请注明出处:http://blog.csdn.net/fulinus
前面我们看到了一个lds文件,我们这里深入的了解一下:
section.c:
/* * Copyright: (C) 2014 EAST fulinux <fulinux@sina.com> */#include <stdio.h>#include <stdlib.h>int localmemory0 __attribute__((section("LOCALmem"))) = 0;int localmemory1 __attribute__((section("LOCALmem"))) = 0;int globalmemory __attribute__((section("GLOBALmem"))) = 0;int main (int argc, char *argv[]){ localmemory0 = 0x456; localmemory1 = 0x123; globalmemory = localmemory0 + localmemory1; return 0;}
$ gcc -c -o section.o section.c
$ objdump -d section.o
section.o: 文件格式 elf64-x86-64Disassembly of section .text:0000000000000000 <main>: 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp 4: 89 7d fc mov %edi,-0x4(%rbp) 7: 48 89 75 f0 mov %rsi,-0x10(%rbp) b: c7 05 00 00 00 00 56 movl $0x456,0x0(%rip) # 15 <main+0x15> 12: 04 00 00 15: c7 05 00 00 00 00 23 movl $0x123,0x0(%rip) # 1f <main+0x1f> 1c: 01 00 00 1f: 8b 15 00 00 00 00 mov 0x0(%rip),%edx # 25 <main+0x25> 25: 8b 05 00 00 00 00 mov 0x0(%rip),%eax # 2b <main+0x2b> 2b: 01 d0 add %edx,%eax 2d: 89 05 00 00 00 00 mov %eax,0x0(%rip) # 33 <main+0x33> 33: b8 00 00 00 00 mov $0x0,%eax 38: 5d pop %rbp 39: c3 retq
section.lds:
SECTIONS{ .text : { *(.text) } LOCALmem 0x1f0000 : { *(LOCALmem) } GLOBALmem 0xff0000 : { *(GLOBALmem) }}
$ ld -o section.elf -T section.lds section.o
$ objdump -S section.elf
section.elf: 文件格式 elf64-x86-64Disassembly of section .text:0000000000000000 <main>: 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp 4: 89 7d fc mov %edi,-0x4(%rbp) 7: 48 89 75 f0 mov %rsi,-0x10(%rbp) b: c7 05 eb ff 1e 00 56 movl $0x456,0x1effeb(%rip) # 1f0000 <localmemory0> 12: 04 00 00 15: c7 05 e5 ff 1e 00 23 movl $0x123,0x1effe5(%rip) # 1f0004 <localmemory1> 1c: 01 00 00 1f: 8b 15 db ff 1e 00 mov 0x1effdb(%rip),%edx # 1f0000 <localmemory0> 25: 8b 05 d9 ff 1e 00 mov 0x1effd9(%rip),%eax # 1f0004 <localmemory1> 2b: 01 d0 add %edx,%eax 2d: 89 05 cd ff fe 00 mov %eax,0xfeffcd(%rip) # ff0000 <globalmemory> 33: b8 00 00 00 00 mov $0x0,%eax 38: 5d pop %rbp 39: c3 retq [fulinux@ubuntu jupiter]$
1 0
- u-boot-2014.10移植第6天----深入分析代码(一)
- u-boot-2014.10移植第7天----深入分析代码(二)
- u-boot-2014.10移植第8天----深入分析代码(三)
- u-boot-2014.10移植第9天----深入分析代码(四)
- u-boot-2014.10移植第10天----深入分析代码(五)
- u-boot-2014.10移植第11天----深入分析代码(六)
- u-boot-2014.10移植第12天----深入分析代码(七)
- u-boot-2014.10移植第1天----熟悉u-boot(一)
- u-boot移植(一)---u-boot启动流程分析
- u-boot-2014.10移植第17天----添加DM9000网卡支持(一)
- u-boot-2014.10移植第19天----添加nand flash命令支持(一)
- u-boot-2014.10移植第23天----nand flash启动(一)
- u-boot-2014.10移植第29天----nand flash的SPL启动(一)
- u-boot-2014.10移植第31天----内核启动(一)
- U-boot分析与移植(6)----U-boot--Makefile
- U-boot分析与移植(6)----U-boot--Makefile
- u-boot-2014.10移植第2天----熟悉u-boot(二)
- U-boot移植(一)
- JavaScript 进阶(一)JS的"多线程"
- 【和我一起学习Unity3D】初识物理系统
- 进程与线程的区别
- codeforces Round #275(div2) B解题报告
- Record
- u-boot-2014.10移植第6天----深入分析代码(一)
- QR二维码生成器源码(中间可插入小图片)
- java多线程
- javascript基础——鼠标事件,系统对话框等
- Spark基础概况
- 在SQL 2005中用T-SQL插入中文数据时出现的问号或乱码的解决方案
- javascript-获取parentNode-firstChild-lastChild的方法及案例
- IOS UIView
- Linux下文本行乱码问题