Hardware platform: tq2440
Development environment: Ubuntu-3.11
U-boot version: 2014.10
This article allows reprint, please specify the source: Http://blog.csdn.net/fulinus
Before we see an LDS file, here's an in-depth look at:
SECTION.C:
/* Copyright: (C) EAST fulinux <[email protected]> */#include <stdio.h> #include <stdlib.h>int Loc Almemory0 __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
SECTION.O: File format elf64-x86-64disassembly of section. text:0000000000000000 <main>: 0:55 Push%rbp 1:48 e5 mov%rsp,%rbp 4:89 7d FC mov%edi,-0x4 (%RBP) 7: F0 mov%rsi,-0x10 (%RBP) b:c7, XX, Movl $0x456,0x0 (%rip) # <mai N+0x15> 12:04 ($0x123,0x0) # 1f <main+0x1f>%rip, 15:c7, XX, Movl 1c:01 XX 1f:8b (%rip),%edx # <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 XX mov%eax,0x0 (%rip) # <main+0x33> 33:b8 xx xx xx $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
Section.elf: File format elf64-x86-64disassembly of section. text:0000000000000000 <main>: 0:55 Push%rbp 1:48 e5 mov%rsp,%rbp 4:89 7d FC mov%edi,-0x4 (%RBP) 7: F0 mov%rsi,-0x10 (%RBP) b:c7 EB ff 1e. Movl $0x456,0x1effeb (%rip) # 1f0 <localmemory0> 12:04 xx 15:c7 e5 ff 1e movl $0x123,0x1effe5 (%rip) # 1f0004 < Localmemory1> 1c:01 (1f:8b) 1e/mov 0x1effdb (%rip),%edx # 1f0000 <localmemor y0> 25:8b D9 ff 1e XX mov 0x1effd9 (%rip),%eax # 1f0004 <localmemory1> 2b:01 D0 Add%edx,%eax 2d:89 CD ff fe XX mov%eax,0xfeffcd (%rip) # ff0000 <globalmemory> 33:b8 xx xx $0x0,%eax 38:5d pop%rbp 39:c3 RETQ [[Email proTected] jupiter]$
u-boot-2014.10 Transplant 6th Day----In-depth analysis code (i)