硬件平台: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-64 Disassembly 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
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-64 Disassembly 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]$
u-boot-2014.10移植第6天----深入分析代码(一)
原文地址:http://blog.csdn.net/fulinus/article/details/40515111