这几天正要解决一个固定内存地址问题,有如下程序:
test.c:
----------------------------------------------------------------------------------------------------
#include <stdio.h>
extern unsigned char __bootarea_start[];
extern unsigned char __bootarea_end[];
void get_bootarea_addr(unsigned char **addr_start, unsigned int *size)
{
*addr_start = __bootarea_start;
*size = (__bootarea_end - __bootarea_start);
}
/* 即每次开机或重新编译连接,该函数返回的地址和大小都是固定不变的 */
int main(int argc, char **argv)
{
unsigned char *bootarea_addr = NULL; //, *ptr;
unsigned int size = 0;
unsigned int i;
get_bootarea_addr(&bootarea_addr, &size);
printf("bootarea_addr = %p, size = %x/n", bootarea_addr, size);
for(i = 0; i < size; i++) { bootarea_addr[i] = i; }
return 0;
}
----------------------------------------------------------------------------------------------------
i386-linux平台链接脚本如下:i386_linux.lds
----------------------------------------------------------------------------------------------------
/*
==================================================
GNU ld version 2.17.50.0.6-6.el5 20061020
Supported emulations:
elf_i386
i386linux
using internal linker script:
==================================================
*/
/* Script for -z combreloc: combine and sort reloc sections */
OUTPUT_FORMAT("elf32-i386", "elf32-i386",
"elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(_start)
SEARCH_DIR("/usr/i386-redhat-linux/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
SECTIONS
{
/* Read-only sections, merged into text segment: */
/* PROVIDE (__executable_start = 0x08048000); . = 0x08048000 + SIZEOF_HEADERS; */
PROVIDE (__executable_start = 0x000008000); . = 0x00008000 + 1024;
.interp : { *(.interp) }
.hash : { *(.hash) }
.gnu.hash : { *(.gnu.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.dyn :
{
*(.rel.init)
*(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
*(.rel.fini)
*(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
*(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
*(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
*(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
*(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
*(.rel.ctors)
*(.rel.dtors)
*(.rel.got)
*(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
}
.rela.dyn :
{
*(.rela.init)
*(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
*(.rela.fini)
*(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
*(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
*(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
*(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
*(.rela.ctors)
*(.rela.dtors)
*(.rela.got)
*(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
}
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.init :
{
KEEP (*(.init))
} =0x90909090
.plt : { *(.plt) }
.text :
{
*(.text .stub .text.* .gnu.linkonce.t.*)
KEEP (*(.text.*personality*))
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
} =0x90909090
.fini :
{
KEEP (*(.fini))
} =0x90909090
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
.eh_frame_hdr : { *(.eh_frame_hdr) }
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
.gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
/*
. = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1));
. = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
*/
. = ALIGN (0x8000) - ((0x8000 - .) & (0x8000 - 1));
. = DATA_SEGMENT_ALIGN (0x8000, 0x1000);
/* Exception handling */
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
.gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
/* Thread Local Storage sections */
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
}
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
}
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
}
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
.data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
.dynamic : { *(.dynamic) }
.got : { *(.got) }
. = DATA_SEGMENT_RELRO_END (12, .);
.got.plt : { *(.got.plt) }
.data :
{
*(.data .data.* .gnu.linkonce.d.*)
KEEP (*(.gnu.linkonce.d.*personality*))
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
_edata = .; PROVIDE (edata = .);
__bss_start = .;
.bss :
{
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections.
FIXME: Why do we need it? When there is no .bss section, we don't
pad the .data section. */
. = ALIGN(. != 0 ? 32 / 8 : 1);
}
. = ALIGN(32 / 8);
. = ALIGN(32 / 8);
_end = .; PROVIDE (end = .);
. = DATA_SEGMENT_END (.);
/* Stabs debugging sections. */
. = 0x80000000;
.bootarea :
{
__bootarea_start = .;
. = . + 0x500000;
__bootarea_end = .;
}
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
/* DWARF 3 */
.debug_pubtypes 0 : { *(.debug_pubtypes) }
.debug_ranges 0 : { *(.debug_ranges) }
/DISCARD/ : { *(.note.GNU-stack) }
}
----------------------------------------------------------------------------------------------------
arm-linux平台链接脚本如下: arm_linux.lds
----------------------------------------------------------------------------------------------------
/*
==================================================
GNU ld version 2.16.91 20050627
Supported emulations:
armelf_linux
armelf
using internal linker script:
==================================================
*/
/* Script for -z combreloc: combine and sort reloc sections */
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
"elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
/* Do we need any of these for elf?
__DYNAMIC = 0; */
SECTIONS
{
/* Read-only sections, merged into text segment: */
PROVIDE (__executable_start = 0x00008000); . = 0x00008000 + 1024;
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.dyn :
{
*(.rel.init)
*(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
*(.rel.fini)
*(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
*(.rel.data.rel.ro*)
*(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
*(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
*(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
*(.rel.ctors)
*(.rel.dtors)
*(.rel.got)
*(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
}
.rela.dyn :
{
*(.rela.init)
*(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
*(.rela.fini)
*(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
*(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
*(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
*(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
*(.rela.ctors)
*(.rela.dtors)
*(.rela.got)
*(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
}
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.init :
{
KEEP (*(.init))
} =0
.plt : { *(.plt) }
.text :
{
*(.text .stub .text.* .gnu.linkonce.t.*)
KEEP (*(.text.*personality*))
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.glue_7t) *(.glue_7)
} =0
.fini :
{
KEEP (*(.fini))
} =0
PROVIDE (__etext = .);
PROVIDE (_etext = .);
PROVIDE (etext = .);
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
.rodata1 : { *(.rodata1) }
.eh_frame_hdr : { *(.eh_frame_hdr) }
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
.gcc_except_table : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = ALIGN (0x8000) - ((0x8000 - .) & (0x8000 - 1)); . = DATA_SEGMENT_ALIGN (0x8000, 0x1000);
/* Exception handling */
.eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) }
.gcc_except_table : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
/* Thread Local Storage sections */
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
.preinit_array : { KEEP (*(.preinit_array)) }
.init_array : { KEEP (*(.init_array)) }
.fini_array : { KEEP (*(.fini_array)) }
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin*.o(.ctors))
/* We don't want to include the .ctor section from
from the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin*.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
.data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro*) }
.dynamic : { *(.dynamic) }
. = DATA_SEGMENT_RELRO_END (0, .);
.got : { *(.got.plt) *(.got) }
.data :
{
__data_start = . ;
*(.data .data.* .gnu.linkonce.d.*)
KEEP (*(.gnu.linkonce.d.*personality*))
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
_edata = .; PROVIDE (edata = .);
/* __bss_start is used by _bfd_elf_provide_section_bound_symbols in
elflink.c. */
__bss_start = .;
__bss_start__ = .;
.bss :
{
*(.dynbss)
*(.bss .bss.* .gnu.linkonce.b.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections. */
. = ALIGN(. != 0 ? 32 / 8 : 1);
}
. = ALIGN(32 / 8);
_end = .;
_bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
PROVIDE (end = .);
. = DATA_SEGMENT_END (.);
. = 0x80000000;
.bootarea :
{
__bootarea_start = .;
. = . + 0x500000;
__bootarea_end = .;
}
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
/DISCARD/ : { *(.note.GNU-stack) }
}
----------------------------------------------------------------------------------------------------
然后使用如下命令编译连接:
----------------------------------------------------------------------------------------------------
ld -Wall -O2 -Wl,-Ti386_linux.lds -o i386_test test.c
arm-uclibc-linux-ld -Wall -O2 -Wl,-Tarm_linux.lds -o arm_test test.c
----------------------------------------------------------------------------------------------------
运行结果如下:
----------------------------------------------------------------------------------------------------
i386_linux平台: bootarea_addr = 0x80000000, size = 500000
arm_linux平台: 直接killed
----------------------------------------------------------------------------------------------------
i386_linux readelf -a结果如下:
----------------------------------------------------------------------------------------------------
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x85a0
Start of program headers: 52 (bytes into file)
Start of section headers: 2812 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 8
Size of section headers: 40 (bytes)
Number of section headers: 29
Section header string table index: 26
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .interp PROGBITS 00008400 000400 000013 00 A 0 0 1
[ 2] .note.ABI-tag NOTE 00008414 000414 000020 00 A 0 0 4
[ 3] .gnu.hash GNU_HASH 00008434 000434 000020 04 A 4 0 4
[ 4] .dynsym DYNSYM 00008454 000454 000050 10 A 5 1 4
[ 5] .dynstr STRTAB 000084a4 0004a4 00004c 00 A 0 0 1
[ 6] .gnu.version VERSYM 000084f0 0004f0 00000a 02 A 4 0 2
[ 7] .gnu.version_r VERNEED 000084fc 0004fc 000020 00 A 5 1 4
[ 8] .rel.dyn REL 0000851c 00051c 000008 08 A 4 0 4
[ 9] .rel.plt REL 00008524 000524 000018 08 A 4 11 4
[10] .init PROGBITS 0000853c 00053c 000017 00 AX 0 0 4
[11] .plt PROGBITS 00008554 000554 000040 04 AX 0 0 4
[12] .text PROGBITS 000085a0 0005a0 000218 00 AX 0 0 16
[13] .fini PROGBITS 000087b8 0007b8 00001c 00 AX 0 0 4
[14] .rodata PROGBITS 000087d4 0007d4 00002c 00 A 0 0 4
[15] .eh_frame PROGBITS 00008800 000800 000004 00 A 0 0 4
[16] .ctors PROGBITS 00010804 000804 000008 00 WA 0 0 4
[17] .dtors PROGBITS 0001080c 00080c 000008 00 WA 0 0 4
[18] .jcr PROGBITS 00010814 000814 000004 00 WA 0 0 4
[19] .dynamic DYNAMIC 00010818 000818 0000c8 08 WA 5 0 4
[20] .got PROGBITS 000108e0 0008e0 000004 04 WA 0 0 4
[21] .got.plt PROGBITS 000108e4 0008e4 000018 04 WA 0 0 4
[22] .data PROGBITS 000108fc 0008fc 000004 00 WA 0 0 4
[23] .bss NOBITS 00010900 000900 000008 00 WA 0 0 4
[24] .bootarea NOBITS 80000000 000000 500000 00 WA 0 0 1
[25] .comment PROGBITS 00000000 000900 000114 00 0 0 1
[26] .shstrtab STRTAB 00000000 000a14 0000e5 00 0 0 1
[27] .symtab SYMTAB 00000000 000f84 000480 10 28 49 4
[28] .strtab STRTAB 00000000 001404 00028c 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
There are no section groups in this file.
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000034 0x00008034 0x00008034 0x00100 0x00100 R E 0x4
INTERP 0x000400 0x00008400 0x00008400 0x00013 0x00013 R 0x1
[Requesting program interpreter: /lib/ld-linux.so.2]
LOAD 0x000000 0x00008000 0x00008000 0x00804 0x00804 R E 0x1000
LOAD 0x000804 0x00010804 0x00010804 0x000fc 0x00104 RW 0x1000
LOAD 0x000000 0x80000000 0x80000000 0x00000 0x500000 RW 0x1000
DYNAMIC 0x000818 0x00010818 0x00010818 0x000c8 0x000c8 RW 0x4
NOTE 0x000414 0x00008414 0x00008414 0x00020 0x00020 R 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x4
Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .note.ABI-tag .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .eh_frame
03 .ctors .dtors .jcr .dynamic .got .got.plt .data .bss
04 .bootarea
05 .dynamic
06 .note.ABI-tag
07
Dynamic section at offset 0x818 contains 20 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libc.so.6]
0x0000000c (INIT) 0x853c
0x0000000d (FINI) 0x87b8
0x6ffffef5 (GNU_HASH) 0x8434
0x00000005 (STRTAB) 0x84a4
0x00000006 (SYMTAB) 0x8454
0x0000000a (STRSZ) 76 (bytes)
0x0000000b (SYMENT) 16 (bytes)
0x00000015 (DEBUG) 0x0
0x00000003 (PLTGOT) 0x108e4
0x00000002 (PLTRELSZ) 24 (bytes)
0x00000014 (PLTREL) REL
0x00000017 (JMPREL) 0x8524
0x00000011 (REL) 0x851c
0x00000012 (RELSZ) 8 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x6ffffffe (VERNEED) 0x84fc
0x6fffffff (VERNEEDNUM) 1
0x6ffffff0 (VERSYM) 0x84f0
0x00000000 (NULL) 0x0
Relocation section '.rel.dyn' at offset 0x51c contains 1 entries:
Offset Info Type Sym.Value Sym. Name
000108e0 00000106 R_386_GLOB_DAT 00000000 __gmon_start__
Relocation section '.rel.plt' at offset 0x524 contains 3 entries:
Offset Info Type Sym.Value Sym. Name
000108f0 00000107 R_386_JUMP_SLOT 00000000 __gmon_start__
000108f4 00000207 R_386_JUMP_SLOT 00000000 __libc_start_main
000108f8 00000307 R_386_JUMP_SLOT 00000000 printf
There are no unwind sections in this file.
Symbol table '.dynsym' contains 5 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
2: 00000000 415 FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.0 (2)
3: 00000000 57 FUNC GLOBAL DEFAULT UND printf@GLIBC_2.0 (2)
4: 000087d8 4 OBJECT GLOBAL DEFAULT 14 _IO_stdin_used
Symbol table '.symtab' contains 72 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00008400 0 SECTION LOCAL DEFAULT 1
2: 00008414 0 SECTION LOCAL DEFAULT 2
3: 00008434 0 SECTION LOCAL DEFAULT 3
4: 00008454 0 SECTION LOCAL DEFAULT 4
5: 000084a4 0 SECTION LOCAL DEFAULT 5
6: 000084f0 0 SECTION LOCAL DEFAULT 6
7: 000084fc 0 SECTION LOCAL DEFAULT 7
8: 0000851c 0 SECTION LOCAL DEFAULT 8
9: 00008524 0 SECTION LOCAL DEFAULT 9
10: 0000853c 0 SECTION LOCAL DEFAULT 10
11: 00008554 0 SECTION LOCAL DEFAULT 11
12: 000085a0 0 SECTION LOCAL DEFAULT 12
13: 000087b8 0 SECTION LOCAL DEFAULT 13
14: 000087d4 0 SECTION LOCAL DEFAULT 14
15: 00008800 0 SECTION LOCAL DEFAULT 15
16: 00010804 0 SECTION LOCAL DEFAULT 16
17: 0001080c 0 SECTION LOCAL DEFAULT 17
18: 00010814 0 SECTION LOCAL DEFAULT 18
19: 00010818 0 SECTION LOCAL DEFAULT 19
20: 000108e0 0 SECTION LOCAL DEFAULT 20
21: 000108e4 0 SECTION LOCAL DEFAULT 21
22: 000108fc 0 SECTION LOCAL DEFAULT 22
23: 00010900 0 SECTION LOCAL DEFAULT 23
24: 80000000 0 SECTION LOCAL DEFAULT 24
25: 00000000 0 SECTION LOCAL DEFAULT 25
26: 000085c4 0 FUNC LOCAL DEFAULT 12 call_gmon_start
27: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
28: 00010804 0 OBJECT LOCAL DEFAULT 16 __CTOR_LIST__
29: 0001080c 0 OBJECT LOCAL DEFAULT 17 __DTOR_LIST__
30: 00010814 0 OBJECT LOCAL DEFAULT 18 __JCR_LIST__
31: 00010900 4 OBJECT LOCAL DEFAULT 23 dtor_idx.5790
32: 00010904 1 OBJECT LOCAL DEFAULT 23 completed.5788
33: 000085f0 0 FUNC LOCAL DEFAULT 12 __do_global_dtors_aux
34: 00008650 0 FUNC LOCAL DEFAULT 12 frame_dummy
35: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
36: 00010808 0 OBJECT LOCAL DEFAULT 16 __CTOR_END__
37: 00008800 0 OBJECT LOCAL DEFAULT 15 __FRAME_END__
38: 00010814 0 OBJECT LOCAL DEFAULT 18 __JCR_END__
39: 00008790 0 FUNC LOCAL DEFAULT 12 __do_global_ctors_aux
40: 00000000 0 FILE LOCAL DEFAULT ABS addr.c
41: 00010804 0 NOTYPE LOCAL HIDDEN 16 __preinit_array_start
42: 00010804 0 NOTYPE LOCAL HIDDEN 16 __fini_array_end
43: 000108e4 0 OBJECT LOCAL HIDDEN 21 _GLOBAL_OFFSET_TABLE_
44: 00010804 0 NOTYPE LOCAL HIDDEN 16 __preinit_array_end
45: 00010804 0 NOTYPE LOCAL HIDDEN 16 __fini_array_start
46: 00010804 0 NOTYPE LOCAL HIDDEN 16 __init_array_end
47: 00010804 0 NOTYPE LOCAL HIDDEN 16 __init_array_start
48: 00010818 0 OBJECT LOCAL HIDDEN 19 _DYNAMIC
49: 000108fc 0 NOTYPE WEAK DEFAULT 22 data_start
50: 00008710 5 FUNC GLOBAL DEFAULT 12 __libc_csu_fini
51: 000085a0 0 FUNC GLOBAL DEFAULT 12 _start
52: 00000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__
53: 00000000 0 NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses
54: 000087d4 4 OBJECT GLOBAL DEFAULT 14 _fp_hw
55: 000087b8 0 FUNC GLOBAL DEFAULT 13 _fini
56: 00000000 415 FUNC GLOBAL DEFAULT UND __libc_start_main@@GLIBC_
57: 80500000 0 NOTYPE GLOBAL DEFAULT 24 __bootarea_end
58: 000087d8 4 OBJECT GLOBAL DEFAULT 14 _IO_stdin_used
59: 000108fc 0 NOTYPE GLOBAL DEFAULT 22 __data_start
60: 000087dc 0 OBJECT GLOBAL HIDDEN 14 __dso_handle
61: 00010810 0 OBJECT GLOBAL HIDDEN 17 __DTOR_END__
62: 00008720 105 FUNC GLOBAL DEFAULT 12 __libc_csu_init
63: 00000000 57 FUNC GLOBAL DEFAULT UND printf@@GLIBC_2.0
64: 00008680 29 FUNC GLOBAL DEFAULT 12 get_bootarea_addr
65: 00010900 0 NOTYPE GLOBAL DEFAULT ABS __bss_start
66: 80000000 0 NOTYPE GLOBAL DEFAULT 24 __bootarea_start
67: 00010908 0 NOTYPE GLOBAL DEFAULT ABS _end
68: 00010900 0 NOTYPE GLOBAL DEFAULT ABS _edata
69: 00008789 0 FUNC GLOBAL HIDDEN 12 __i686.get_pc_thunk.bx
70: 000086a0 109 FUNC GLOBAL DEFAULT 12 main
71: 0000853c 0 FUNC GLOBAL DEFAULT 10 _init
Histogram for `.gnu.hash' bucket list length (total of 2 buckets):
Length Number % of total Coverage
0 1 ( 50.0%)
1 1 ( 50.0%) 100.0%
Version symbols section '.gnu.version' contains 5 entries:
Addr: 00000000000084f0 Offset: 0x0004f0 Link: 4 (.dynsym)
000: 0 (*local*) 0 (*local*) 2 (GLIBC_2.0) 2 (GLIBC_2.0)
004: 1 (*global*)
Version needs section '.gnu.version_r' contains 1 entries:
Addr: 0x00000000000084fc Offset: 0x0004fc Link to section: 5 (.dynstr)
000000: Version: 1 File: libc.so.6 Cnt: 1
0x0010: Name: GLIBC_2.0 Flags: none Version: 2
Notes at offset 0x00000414 with length 0x00000020:
Owner Data size Description
GNU 0x00000010 NT_VERSION (version)
----------------------------------------------------------------------------------------------------
arm-uclibc-linux-readelf -a结果如下:
----------------------------------------------------------------------------------------------------
ELF 头:
Magic: 7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: ARM
ABI Version: 0
Type: EXEC (可执行文件)
Machine: ARM
Version: 0x1
入口点地址: 0x86bc
程序头起点: 52 (bytes into file)
Start of section headers: 2876 (bytes into file)
标志: 0x202, has entry point, GNU EABI, software FP
本头的大小: 52 (字节)
程序头大小: 32 (字节)
程序头数量: 7
节头大小: 40 (字节)
节头数量: 25
字符串表索引节头: 22
节头:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .interp PROGBITS 00008400 000400 000014 00 A 0 0 1
[ 2] .hash HASH 00008414 000414 000090 04 A 3 0 4
[ 3] .dynsym DYNSYM 000084a4 0004a4 000110 10 A 4 1 4
[ 4] .dynstr STRTAB 000085b4 0005b4 000090 00 A 0 0 1
[ 5] .rel.dyn REL 00008644 000644 000018 08 A 3 0 4
[ 6] .rel.plt REL 0000865c 00065c 000018 08 A 3 8 4
[ 7] .init PROGBITS 00008674 000674 000010 00 AX 0 0 4
[ 8] .plt PROGBITS 00008684 000684 000038 04 AX 0 0 4
[ 9] .text PROGBITS 000086bc 0006bc 000198 00 AX 0 0 4
[10] .fini PROGBITS 00008854 000854 00000c 00 AX 0 0 4
[11] .rodata PROGBITS 00008860 000860 000020 01 AMS 0 0 4
[12] .eh_frame PROGBITS 00008880 000880 000004 00 A 0 0 4
[13] .ctors PROGBITS 00010884 000884 000008 00 WA 0 0 4
[14] .dtors PROGBITS 0001088c 00088c 000008 00 WA 0 0 4
[15] .jcr PROGBITS 00010894 000894 000004 00 WA 0 0 4
[16] .dynamic DYNAMIC 00010898 000898 0000b0 08 WA 4 0 4
[17] .got PROGBITS 00010948 000948 000024 04 WA 0 0 4
[18] .data PROGBITS 0001096c 00096c 000014 00 WA 0 0 4
[19] .bss NOBITS 00010980 000980 000004 00 WA 0 0 1
[20] .bootarea NOBITS 80000000 000980 500000 00 WA 0 0 1 --> [b][color=#FF0000]why the offset of segment bootarea is 0x980?[/color][/b]
[21] .comment PROGBITS 00000000 000980 00010c 00 0 0 1
[22] .shstrtab STRTAB 00000000 000a8c 0000ae 00 0 0 1
[23] .symtab SYMTAB 00000000 000f24 0005a0 10 24 68 4
[24] .strtab STRTAB 00000000 0014c4 0001fd 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
There are no section groups in this file.
程序头:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000034 0x00008034 0x00008034 0x000e0 0x000e0 R E 0x4
INTERP 0x000400 0x00008400 0x00008400 0x00014 0x00014 R 0x1
[正在请求程序解释器:/lib/ld-uClibc.so.0]
LOAD 0x000000 0x00008000 0x00008000 0x00884 0x00884 R E 0x8000
LOAD 0x000884 0x00010884 0x00010884 0x000fc 0x00100 RW 0x8000
LOAD 0x000000 0x80000000 0x80000000 0x00000 0x500000 RW 0x8000
DYNAMIC 0x000898 0x00010898 0x00010898 0x000b0 0x000b0 RW 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RWE 0x4
Section to Segment mapping:
段节...
00
01 .interp
02 .interp .hash .dynsym .dynstr .rel.dyn .rel.plt .init .plt .text .fini .rodata .eh_frame
03 .ctors .dtors .jcr .dynamic .got .data .bss
04 .bootarea
05 .dynamic
06
Dynamic section at offset 0x898 contains 17 entries:
标记 类型 名称/值
0x00000001 (NEEDED) 共享库:[libc.so.0]
0x0000000c (INIT) 0x8674
0x0000000d (FINI) 0x8854
0x00000004 (HASH) 0x8414
0x00000005 (STRTAB) 0x85b4
0x00000006 (SYMTAB) 0x84a4
0x0000000a (STRSZ) 144 (bytes)
0x0000000b (SYMENT) 16 (bytes)
0x00000015 (DEBUG) 0x0
0x00000003 (PLTGOT) 0x10948
0x00000002 (PLTRELSZ) 24 (bytes)
0x00000014 (PLTREL) REL
0x00000017 (JMPREL) 0x865c
0x00000011 (REL) 0x8644
0x00000012 (RELSZ) 24 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x00000000 (NULL) 0x0
重定位节 “.rel.dyn” 位于偏移量 0x644 含有 3 个条目:
Offset Info Type Sym.Value Sym. Name
00010960 00000515 R_ARM_GLOB_DAT 00008674 _init
00010964 00000a15 R_ARM_GLOB_DAT 000087b8 main
00010968 00000c15 R_ARM_GLOB_DAT 00008854 _fini
重定位节 “.rel.plt” 位于偏移量 0x65c 含有 3 个条目:
Offset Info Type Sym.Value Sym. Name
00010954 00000116 R_ARM_JUMP_SLOT 00008698 printf
00010958 00000816 R_ARM_JUMP_SLOT 000086a4 __uClibc_main
0001095c 00001016 R_ARM_JUMP_SLOT 00000000 _Jv_RegisterClasses
There are no unwind sections in this file.
Symbol table '.dynsym' contains 17 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00008698 60 FUNC GLOBAL DEFAULT UND printf
2: 00010898 0 OBJECT GLOBAL DEFAULT ABS _DYNAMIC
3: 00010984 0 NOTYPE GLOBAL DEFAULT ABS _bss_end__
4: 00010980 0 NOTYPE GLOBAL DEFAULT ABS __bss_start__
5: 00008674 4 FUNC GLOBAL DEFAULT 7 _init
6: 00010984 0 NOTYPE GLOBAL DEFAULT ABS __bss_end__
7: 000086bc 80 FUNC GLOBAL DEFAULT 9 _start
8: 000086a4 516 FUNC GLOBAL DEFAULT UND __uClibc_main
9: 00010980 0 NOTYPE GLOBAL DEFAULT ABS __bss_start
10: 000087b8 92 FUNC GLOBAL DEFAULT 9 main
11: 00010984 0 NOTYPE GLOBAL DEFAULT ABS __end__
12: 00008854 4 FUNC GLOBAL DEFAULT 10 _fini
13: 00010980 0 NOTYPE GLOBAL DEFAULT ABS _edata
14: 00010984 0 NOTYPE GLOBAL DEFAULT ABS _end
15: 0001096c 0 NOTYPE GLOBAL DEFAULT 18 __data_start
16: 00000000 0 NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses
Symbol table '.symtab' contains 90 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00008400 0 SECTION LOCAL DEFAULT 1
2: 00008414 0 SECTION LOCAL DEFAULT 2
3: 000084a4 0 SECTION LOCAL DEFAULT 3
4: 000085b4 0 SECTION LOCAL DEFAULT 4
5: 00008644 0 SECTION LOCAL DEFAULT 5
6: 0000865c 0 SECTION LOCAL DEFAULT 6
7: 00008674 0 SECTION LOCAL DEFAULT 7
8: 00008684 0 SECTION LOCAL DEFAULT 8
9: 000086bc 0 SECTION LOCAL DEFAULT 9
10: 00008854 0 SECTION LOCAL DEFAULT 10
11: 00008860 0 SECTION LOCAL DEFAULT 11
12: 00008880 0 SECTION LOCAL DEFAULT 12
13: 00010884 0 SECTION LOCAL DEFAULT 13
14: 0001088c 0 SECTION LOCAL DEFAULT 14
15: 00010894 0 SECTION LOCAL DEFAULT 15
16: 00010898 0 SECTION LOCAL DEFAULT 16
17: 00010948 0 SECTION LOCAL DEFAULT 17
18: 0001096c 0 SECTION LOCAL DEFAULT 18
19: 00010980 0 SECTION LOCAL DEFAULT 19
20: 80000000 0 SECTION LOCAL DEFAULT 20
21: 00000000 0 SECTION LOCAL DEFAULT 21
22: 00000000 0 SECTION LOCAL DEFAULT 22
23: 00000000 0 SECTION LOCAL DEFAULT 23
24: 00000000 0 SECTION LOCAL DEFAULT 24
25: 00008674 0 NOTYPE LOCAL DEFAULT 7 $a
26: 00008854 0 NOTYPE LOCAL DEFAULT 10 $a
27: 00010970 0 OBJECT LOCAL DEFAULT 18 force_to_data
28: 00010884 0 OBJECT LOCAL DEFAULT 13 __CTOR_LIST__
29: 00010884 0 NOTYPE LOCAL DEFAULT 13 $d
30: 0001088c 0 OBJECT LOCAL DEFAULT 14 __DTOR_LIST__
31: 0001088c 0 NOTYPE LOCAL DEFAULT 14 $d
32: 00010894 0 OBJECT LOCAL DEFAULT 15 __JCR_LIST__
33: 00010974 0 NOTYPE LOCAL DEFAULT 18 $d
34: 00010978 0 OBJECT LOCAL DEFAULT 18 p.0
35: 00010980 1 OBJECT LOCAL DEFAULT 19 completed.1
36: 0000870c 0 FUNC LOCAL DEFAULT 9 __do_global_dtors_aux
37: 0000870c 0 NOTYPE LOCAL DEFAULT 9 $a
38: 00008758 0 NOTYPE LOCAL DEFAULT 9 $d
39: 00008760 0 FUNC LOCAL DEFAULT 9 call___do_global_dtors_au
40: 00008760 0 NOTYPE LOCAL DEFAULT 9 $a
41: 00008858 0 NOTYPE LOCAL DEFAULT 10 $a
42: 00008768 0 FUNC LOCAL DEFAULT 9 frame_dummy
43: 00008788 0 NOTYPE LOCAL DEFAULT 9 $d
44: 00008790 0 FUNC LOCAL DEFAULT 9 call_frame_dummy
45: 00008790 0 NOTYPE LOCAL DEFAULT 9 $a
46: 00008678 0 NOTYPE LOCAL DEFAULT 7 $a
47: 0001097c 0 OBJECT LOCAL DEFAULT 18 force_to_data
48: 00010888 0 OBJECT LOCAL DEFAULT 13 __CTOR_END__
49: 00010888 0 NOTYPE LOCAL DEFAULT 13 $d
50: 00010890 0 OBJECT LOCAL DEFAULT 14 __DTOR_END__
51: 00010890 0 NOTYPE LOCAL DEFAULT 14 $d
52: 00008880 0 OBJECT LOCAL DEFAULT 12 __FRAME_END__
53: 00008880 0 NOTYPE LOCAL DEFAULT 12 $d
54: 00010894 0 OBJECT LOCAL DEFAULT 15 __JCR_END__
55: 00010894 0 NOTYPE LOCAL DEFAULT 15 $d
56: 00008814 0 FUNC LOCAL DEFAULT 9 __do_global_ctors_aux
57: 00008814 0 NOTYPE LOCAL DEFAULT 9 $a
58: 00008848 0 NOTYPE LOCAL DEFAULT 9 $d
59: 0000884c 0 FUNC LOCAL DEFAULT 9 call___do_global_ctors_au
60: 0000884c 0 NOTYPE LOCAL DEFAULT 9 $a
61: 0000867c 0 NOTYPE LOCAL DEFAULT 7 $a
62: 00008680 0 NOTYPE LOCAL DEFAULT 7 $a
63: 0000885c 0 NOTYPE LOCAL DEFAULT 10 $a
64: 00008798 0 NOTYPE LOCAL DEFAULT 9 $a
65: 000087b0 0 NOTYPE LOCAL DEFAULT 9 $d
66: 000087b8 0 NOTYPE LOCAL DEFAULT 9 $a
67: 00008810 0 NOTYPE LOCAL DEFAULT 9 $d
68: 00008698 60 FUNC GLOBAL DEFAULT UND printf
69: 00010898 0 OBJECT GLOBAL DEFAULT ABS _DYNAMIC
70: 00010984 0 NOTYPE GLOBAL DEFAULT ABS _bss_end__
71: 00008798 32 FUNC GLOBAL DEFAULT 9 get_bootarea_addr
72: 00010980 0 NOTYPE GLOBAL DEFAULT ABS __bss_start__
73: 00010974 0 OBJECT GLOBAL HIDDEN 18 __dso_handle
74: 80500000 0 NOTYPE GLOBAL DEFAULT 20 __bootarea_end
75: 00008674 4 FUNC GLOBAL DEFAULT 7 _init
76: 00010984 0 NOTYPE GLOBAL DEFAULT ABS __bss_end__
77: 000086bc 80 FUNC GLOBAL DEFAULT 9 _start
78: 000086a4 516 FUNC GLOBAL DEFAULT UND __uClibc_main
79: 00010980 0 NOTYPE GLOBAL DEFAULT ABS __bss_start
80: 000087b8 92 FUNC GLOBAL DEFAULT 9 main
81: 00010984 0 NOTYPE GLOBAL DEFAULT ABS __end__
82: 0001096c 0 NOTYPE WEAK DEFAULT 18 data_start
83: 00008854 4 FUNC GLOBAL DEFAULT 10 _fini
84: 00010980 0 NOTYPE GLOBAL DEFAULT ABS _edata
85: 00010948 0 OBJECT GLOBAL HIDDEN 17 _GLOBAL_OFFSET_TABLE_
86: 00010984 0 NOTYPE GLOBAL DEFAULT ABS _end
87: 0001096c 0 NOTYPE GLOBAL DEFAULT 18 __data_start
88: 00000000 0 NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses
89: 80000000 0 NOTYPE GLOBAL DEFAULT 20 __bootarea_start
Histogram for bucket list length (total of 17 buckets):
Length Number % of total Coverage
0 5 ( 29.4%)
1 9 ( 52.9%) 56.2%
2 2 ( 11.8%) 81.2%
3 1 ( 5.9%) 100.0%
No version information found in this file.
----------------------------------------------------------------------------------------------------