$ nasm -felf64 sample.asm
$ ld -o sample sample.o -lc -ecrt0
$ readelf -a sample
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x401020
Start of program headers: 64 (bytes into file)
Start of section headers: 12760 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 8
Size of section headers: 64 (bytes)
Number of section headers: 17
Section header string table index: 16
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .interp PROGBITS 0000000000400200 00000200
000000000000000f 0000000000000000 A 0 0 1
[ 2] .hash HASH 0000000000400210 00000210
0000000000000014 0000000000000004 A 4 0 8
[ 3] .gnu.hash GNU_HASH 0000000000400228 00000228
000000000000001c 0000000000000000 A 4 0 8
[ 4] .dynsym DYNSYM 0000000000400248 00000248
0000000000000030 0000000000000018 A 5 1 8
[ 5] .dynstr STRTAB 0000000000400278 00000278
000000000000001e 0000000000000000 A 0 0 1
[ 6] .gnu.version VERSYM 0000000000400296 00000296
0000000000000004 0000000000000002 A 4 0 2
[ 7] .gnu.version_r VERNEED 00000000004002a0 000002a0
0000000000000020 0000000000000000 A 5 1 8
[ 8] .rela.plt RELA 00000000004002c0 000002c0
0000000000000018 0000000000000018 AI 4 13 8
[ 9] .plt PROGBITS 0000000000401000 00001000
0000000000000020 0000000000000010 AX 0 0 16
[10] .text PROGBITS 0000000000401020 00001020
000000000000000b 0000000000000000 AX 0 0 16
[11] .eh_frame PROGBITS 0000000000402000 00002000
0000000000000000 0000000000000000 A 0 0 8
[12] .dynamic DYNAMIC 0000000000402e98 00002e98
0000000000000150 0000000000000010 WA 5 0 8
[13] .got.plt PROGBITS 0000000000402fe8 00002fe8
0000000000000020 0000000000000008 WA 0 0 8
[14] .symtab SYMTAB 0000000000000000 00003008
00000000000000f0 0000000000000018 15 5 8
[15] .strtab STRTAB 0000000000000000 000030f8
000000000000005b 0000000000000000 0 0 1
[16] .shstrtab STRTAB 0000000000000000 00003153
0000000000000085 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),
D (mbind), l (large), p (processor specific)
There are no section groups in this file.
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x0000000000400040 0x0000000000400040
0x00000000000001c0 0x00000000000001c0 R 0x8
INTERP 0x0000000000000200 0x0000000000400200 0x0000000000400200
0x000000000000000f 0x000000000000000f R 0x1
[Requesting program interpreter: /lib/ld64.so.1]
LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000
0x00000000000002d8 0x00000000000002d8 R 0x1000
LOAD 0x0000000000001000 0x0000000000401000 0x0000000000401000
0x000000000000002b 0x000000000000002b R E 0x1000
LOAD 0x0000000000002000 0x0000000000402000 0x0000000000402000
0x0000000000000000 0x0000000000000000 R 0x1000
LOAD 0x0000000000002e98 0x0000000000402e98 0x0000000000402e98
0x0000000000000170 0x0000000000000170 RW 0x1000
DYNAMIC 0x0000000000002e98 0x0000000000402e98 0x0000000000402e98
0x0000000000000150 0x0000000000000150 RW 0x8
GNU_RELRO 0x0000000000002e98 0x0000000000402e98 0x0000000000402e98
0x0000000000000168 0x0000000000000168 R 0x1
Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .hash .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.plt
03 .plt .text
04 .eh_frame
05 .dynamic .got.plt
06 .dynamic
07 .dynamic
Dynamic section at offset 0x2e98 contains 16 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x0000000000000004 (HASH) 0x400210
0x000000006ffffef5 (GNU_HASH) 0x400228
0x0000000000000005 (STRTAB) 0x400278
0x0000000000000006 (SYMTAB) 0x400248
0x000000000000000a (STRSZ) 30 (bytes)
0x000000000000000b (SYMENT) 24 (bytes)
0x0000000000000015 (DEBUG) 0x0
0x0000000000000003 (PLTGOT) 0x402fe8
0x0000000000000002 (PLTRELSZ) 24 (bytes)
0x0000000000000014 (PLTREL) RELA
0x0000000000000017 (JMPREL) 0x4002c0
0x000000006ffffffe (VERNEED) 0x4002a0
0x000000006fffffff (VERNEEDNUM) 1
0x000000006ffffff0 (VERSYM) 0x400296
0x0000000000000000 (NULL) 0x0
Relocation section '.rela.plt' at offset 0x2c0 contains 1 entry:
Offset Info Type Sym. Value Sym. Name + Addend
000000403000 000100000007 R_X86_64_JUMP_SLO 0000000000000000 printf@GLIBC_2.2.5 + 0
No processor specific unwind information to decode
Symbol table '.dynsym' contains 2 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FUNC GLOBAL DEFAULT UND [...]@GLIBC_2.2.5 (2)
Symbol table '.symtab' contains 10 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS sample.asm
2: 0000000000000000 0 FILE LOCAL DEFAULT ABS
3: 0000000000402e98 0 OBJECT LOCAL DEFAULT 12 _DYNAMIC
4: 0000000000402fe8 0 OBJECT LOCAL DEFAULT 13 _GLOBAL_OFFSET_TABLE_
5: 0000000000403008 0 NOTYPE GLOBAL DEFAULT 13 _edata
6: 0000000000000000 0 FUNC GLOBAL DEFAULT UND printf@GLIBC_2.2.5
7: 0000000000401020 0 NOTYPE GLOBAL DEFAULT 10 crt0
8: 0000000000403008 0 NOTYPE GLOBAL DEFAULT 13 _end
9: 0000000000403008 0 NOTYPE GLOBAL DEFAULT 13 __bss_start
Histogram for bucket list length (total of 1 bucket):
Length Number % of total Coverage
0 0 ( 0.0%)
1 1 (100.0%) 100.0%
Version symbols section '.gnu.version' contains 2 entries:
Addr: 0x0000000000400296 Offset: 0x000296 Link: 4 (.dynsym)
000: 0 (*local*) 2 (GLIBC_2.2.5)
Version needs section '.gnu.version_r' contains 1 entry:
Addr: 0x00000000004002a0 Offset: 0x0002a0 Link: 5 (.dynstr)
000000: Version: 1 File: libc.so.6 Cnt: 1
0x0010: Name: GLIBC_2.2.5 Flags: none Version: 2