[root@localhost c]# readelf -a hello.oELF Header:
Magic: 7f 45 4c 46020101000000000000000000 Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: REL (Relocatable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x0
Start of program headers: 0 (bytes into file)
Start of section headers: 672 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 0 (bytes)
Number of program headers: 0
Size of section headers: 64 (bytes)
Number of section headers: 13
Section header string table index: 12
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .text PROGBITS 0000000000000000 00000040
000000000000001a 0000000000000000 AX 0 0 1
[ 2] .rela.text RELA 0000000000000000 000001f0
0000000000000030 0000000000000018 I 10 1 8
[ 3] .data PROGBITS 0000000000000000 0000005a
0000000000000000 0000000000000000 WA 0 0 1
[ 4] .bss NOBITS 0000000000000000 0000005a
0000000000000000 0000000000000000 WA 0 0 1
[ 5] .rodata PROGBITS 0000000000000000 0000005a
000000000000000d 0000000000000000 A 0 0 1
[ 6] .comment PROGBITS 0000000000000000 00000067
000000000000002e 0000000000000001 MS 0 0 1
[ 7] .note.GNU-stack PROGBITS 0000000000000000 00000095
0000000000000000 0000000000000000 0 0 1
[ 8] .eh_frame PROGBITS 0000000000000000 00000098
0000000000000038 0000000000000000 A 0 0 8
[ 9] .rela.eh_frame RELA 0000000000000000 00000220
0000000000000018 0000000000000018 I 10 8 8
[10] .symtab SYMTAB 0000000000000000 000000d0
0000000000000108 0000000000000018 11 9 8
[11] .strtab STRTAB 0000000000000000 000001d8
0000000000000015 0000000000000000 0 0 1
[12] .shstrtab STRTAB 0000000000000000 00000238
0000000000000061 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
l (large), p (processor specific)
There are no section groups in this file.
There are no program headers in this file.
Relocation section '.rela.text' at offset 0x1f0 contains 2 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000005 00050000000a R_X86_64_32 0000000000000000 .rodata + 0
00000000000f 000a00000002 R_X86_64_PC32 0000000000000000 printf - 4
Relocation section '.rela.eh_frame' at offset 0x220 contains 1 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000020 000200000002 R_X86_64_PC32 0000000000000000 .text + 0
The decoding of unwind sections for machine type Advanced Micro Devices X86-64 is not currently supported.
Symbol table '.symtab' contains 11 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000000000000 NOTYPE LOCAL DEFAULT UND
1: 00000000000000000 FILE LOCAL DEFAULT ABS hello.c
2: 00000000000000000 SECTION LOCAL DEFAULT 1 3: 00000000000000000 SECTION LOCAL DEFAULT 3 4: 00000000000000000 SECTION LOCAL DEFAULT 4 5: 00000000000000000 SECTION LOCAL DEFAULT 5 6: 00000000000000000 SECTION LOCAL DEFAULT 7 7: 00000000000000000 SECTION LOCAL DEFAULT 8 8: 00000000000000000 SECTION LOCAL DEFAULT 6 9: 000000000000000026 FUNC GLOBAL DEFAULT 1 main
10: 00000000000000000 NOTYPE GLOBAL DEFAULT UND printf
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 00000000000000000000000000000000000000000000000000000000000[ 1] .text PROGBITS 000000000000000000000040 000000000000001a 0000000000000000 AX 001[ 2] .rela.text RELA 0000000000000000 000001f0
00000000000000300000000000000018 I 1018[ 3] .data PROGBITS 0000000000000000 0000005a
00000000000000000000000000000000 WA 001[ 4] .bss NOBITS 0000000000000000 0000005a
00000000000000000000000000000000 WA 001[ 5] .rodata PROGBITS 0000000000000000 0000005a
000000000000000d 0000000000000000 A 001[ 6] .comment PROGBITS 000000000000000000000067 000000000000002e 0000000000000001 MS 001[ 7] .note.GNU-stack PROGBITS 00000000000000000000009500000000000000000000000000000000001[ 8] .eh_frame PROGBITS 00000000000000000000009800000000000000380000000000000000 A 008[ 9] .rela.eh_frame RELA 00000000000000000000022000000000000000180000000000000018 I 1088[10] .symtab SYMTAB 0000000000000000 000000d0
000000000000010800000000000000181198[11] .strtab STRTAB 0000000000000000 000001d8
00000000000000150000000000000000001[12] .shstrtab STRTAB 00000000000000000000023800000000000000610000000000000000001Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
l (large), p (processor specific)
且程序头表提示没有信息
1
2
3
There are no section groups in this file.
There are no program headers in this file.
符号表段
表格形式
1
2
3
4
5
6
7
8
9
10
11
12
13
Symbol table '.symtab' contains 11 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000000000000 NOTYPE LOCAL DEFAULT UND
1: 00000000000000000 FILE LOCAL DEFAULT ABS hello.c
2: 00000000000000000 SECTION LOCAL DEFAULT 1 3: 00000000000000000 SECTION LOCAL DEFAULT 3 4: 00000000000000000 SECTION LOCAL DEFAULT 4 5: 00000000000000000 SECTION LOCAL DEFAULT 5 6: 00000000000000000 SECTION LOCAL DEFAULT 7 7: 00000000000000000 SECTION LOCAL DEFAULT 8 8: 00000000000000000 SECTION LOCAL DEFAULT 6 9: 000000000000000026 FUNC GLOBAL DEFAULT 1 main
10: 00000000000000000 NOTYPE GLOBAL DEFAULT UND printf
符号表段记录了汇编代码中定义的符号信息,重定位表段记录可重定位目标文件中需要重定位的符号信息。
可以看到main、print
重定位表段
表格形式
1
2
3
4
5
6
7
8
Relocation section '.rela.text' at offset 0x1f0 contains 2 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000005 00050000000a R_X86_64_32 0000000000000000 .rodata + 000000000000f 000a00000002 R_X86_64_PC32 0000000000000000printf - 4Relocation section '.rela.eh_frame' at offset 0x220 contains 1 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000020000200000002 R_X86_64_PC32 0000000000000000 .text + 0