This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
the question about PT_DYNAMIC's p_offset value in elf file for mipsplatform
- From: eagle_zhou at ali dot com dot tw
- To: binutils at sources dot redhat dot com
- Date: Tue, 26 Oct 2004 15:20:58 +0800
- Subject: the question about PT_DYNAMIC's p_offset value in elf file for mipsplatform
I am researching shared library on mips platform.
and i have built one cross compile tools based on mips-elf target.
(the software package i used are : binutils-2.15/newlib-1.12.0/gcc-3.4.0)
I created a demo.so file by sequences listed below:
$mips-elf-gcc -EL -g -fPIC -mabicalls -c demo.c
$mips-elf-ld -EL -shared -o demo.so demo.o
$readelf -a demo.so >demo.elf
the content of demo.elf is :
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: DYN (Shared object file)
Machine: MIPS R3000
Version: 0x1
Entry point address: 0x5ffe05a8
Start of program headers: 52 (bytes into file)
Start of section headers: 5908 (bytes into file)
Flags: 0x7, noreorder, pic, cpic, mips1
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 3
Size of section headers: 40 (bytes)
Number of section headers: 26
Section header string table index: 23
Section Headers:
[Nr] Name Type Addr Off Size ES Flg
Lk Inf Al
[ 0] NULL 00000000 000000 000000 00
0 0 0
[ 1] .reginfo MIPS_REGINFO 5ffe0094 001104 000018 18
0 0 4
[ 2] .hash HASH 5ffe00ac 0000ac 00014c 00 A
3 0 4
[ 3] .dynsym DYNSYM 5ffe01f8 0001f8 0002c0 10 A
4 23 4
[ 4] .dynstr STRTAB 5ffe04b8 0004b8 0000dd 00 A
0 0 4
[ 5] .text PROGBITS 5ffe05a8 0005a8 000130 00 AX
0 0 4
[ 6] .MIPS.stubs PROGBITS 5ffe06d8 0006d8 000040 00 AX
0 0 4
[ 7] .data PROGBITS 60021000 001000 000008 00 WA
0 0 4
[ 8] .dynamic DYNAMIC 60021008 001008 0000c0 00 A
4 0 4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 9] .got PROGBITS 600210d0 0010d0 000034 04 WAp
0 0 16
[10] .sbss NOBITS 60021104 00111c 000000 00 WAp
0 0 1
[11] .bss NOBITS 60021104 001104 000800 00 WA
0 0 4
[12] .debug_aranges MIPS_DWARF 00000000 00111c 000020 00
0 0 1
[13] .debug_pubnames MIPS_DWARF 00000000 00113c 00004b 00
0 0 1
[14] .debug_info MIPS_DWARF 00000000 001187 0001b4 00
0 0 1
[15] .debug_abbrev MIPS_DWARF 00000000 00133b 0000a8 00
0 0 1
[16] .debug_line MIPS_DWARF 00000000 0013e3 00004b 00
0 0 1
[17] .debug_frame MIPS_DWARF 00000000 001430 000050 00
0 0 4
[18] .debug_str MIPS_DWARF 00000000 001480 00000d 00
0 0 1
[19] .pdr PROGBITS 00000000 001490 000040 00
0 0 4
[20] .mdebug.abi32 PROGBITS 00000000 0014d0 000000 00
0 0 1
[21] .rel.dyn REL 5ffe0598 000598 000010 08 A
3 0 4
[22] .compact_rel PROGBITS 00000000 0014d0 000150 00
0 0 4
[23] .shstrtab STRTAB 00000000 001620 0000f1 00
0 0 1
[24] .symtab SYMTAB 00000000 001b24 000300 10
25 27 4
[25] .strtab STRTAB 00000000 001e24 0000e4 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)
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg
Align
LOAD 0x000000 0x5ffe0000 0x5ffe0000 0x00718 0x00718 R E
0x1000
LOAD 0x001000 0x60021000 0x60021000 0x00104 0x00904 RW
0x1000
DYNAMIC 0x0000ac 0x5ffe00ac 0x5ffe00ac 0x4101c 0x4101c RWE
0x4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Section to Segment mapping:
Segment Sections...
00 .hash .dynsym .dynstr .text .MIPS.stubs .rel.dyn
01 .data .dynamic .got .bss
02 .reginfo .hash .dynsym .dynstr .text .MIPS.stubs .data
.dynamic .debug_aranges .debug_pubnames .debug_info .debug_abbrev
.debug_line .debug_frame .debug_str .pdr .rel.dyn .compact_rel .shstrtab
.symtab
Dynamic section at offset 0x1008 contains 19 entries:
Tag Type Name/Value
0x00000004 (HASH) 0x5ffe00ac
0x00000005 (STRTAB) 0x5ffe04b8
0x00000006 (SYMTAB) 0x5ffe01f8
0x0000000a (STRSZ) 221 (bytes)
0x0000000b (SYMENT) 16 (bytes)
0x00000016 (TEXTREL) 0x0
0x00000003 (PLTGOT) 0x600210d0
0x00000011 (REL) 0x5ffe0598
0x00000012 (RELSZ) 16 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x70000001 (MIPS_RLD_VERSION) 1
0x70000005 (MIPS_FLAGS) NOTPOT
0x70000006 (MIPS_BASE_ADDRESS) 0x5ffe0000
0x7000000a (MIPS_LOCAL_GOTNO) 7
0x70000011 (MIPS_SYMTABNO) 44
0x70000012 (MIPS_UNREFEXTNO) 23
0x70000013 (MIPS_GOTSYM) 0x26
0x70000014 (MIPS_HIPAGENO) 5
0x00000000 (NULL) 0x0
......
......
Is this elf file is right?
I do not know why PT_DYNAMIC's p_offset is 0x0000ac. I think the correct
value should be 0x1008.
I do not know the reason.
Does anyone have an idea of what goes wrong?