标签:
#include<stdio.h>
int main(void)
{
printf("hello world\n");
return 0;
}
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: 0x4003c0
Start of program headers: 64 (bytes into file)
Start of section headers: 2560 (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: 29
Section header string table index: 26
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
000000000000001c 0000000000000000 A 0 0 1
[ 2] .note.ABI-tag NOTE 000000000040021c 0000021c
0000000000000020 0000000000000000 A 0 0 4
[ 3] .hash HASH 0000000000400240 00000240
0000000000000024 0000000000000004 A 4 0 8
[ 4] .dynsym DYNSYM 0000000000400268 00000268
0000000000000060 0000000000000018 A 5 1 8
[ 5] .dynstr STRTAB 00000000004002c8 000002c8
000000000000003d 0000000000000000 A 0 0 1
[ 6] .gnu.version VERSYM 0000000000400306 00000306
0000000000000008 0000000000000002 A 4 0 2
[ 7] .gnu.version_r VERNEED 0000000000400310 00000310
0000000000000020 0000000000000000 A 5 1 8
[ 8] .rela.dyn RELA 0000000000400330 00000330
0000000000000018 0000000000000018 A 4 0 8
[ 9] .rela.plt RELA 0000000000400348 00000348
0000000000000030 0000000000000018 A 4 11 8
[10] .init PROGBITS 0000000000400378 00000378
0000000000000018 0000000000000000 AX 0 0 4
[11] .plt PROGBITS 0000000000400390 00000390
0000000000000030 0000000000000010 AX 0 0 4
[12] .text PROGBITS 00000000004003c0 000003c0
0000000000000258 0000000000000000 AX 0 0 16
[13] .fini PROGBITS 0000000000400618 00000618
000000000000000e 0000000000000000 AX 0 0 4
[14] .rodata PROGBITS 0000000000400628 00000628
0000000000000010 0000000000000000 A 0 0 4
[15] .eh_frame_hdr PROGBITS 0000000000400638 00000638
0000000000000024 0000000000000000 A 0 0 4
[16] .eh_frame PROGBITS 0000000000400660 00000660
000000000000007c 0000000000000000 A 0 0 8
[17] .ctors PROGBITS 00000000006006e0 000006e0
0000000000000010 0000000000000000 WA 0 0 8
[18] .dtors PROGBITS 00000000006006f0 000006f0
0000000000000010 0000000000000000 WA 0 0 8
[19] .jcr PROGBITS 0000000000600700 00000700
0000000000000008 0000000000000000 WA 0 0 8
[20] .dynamic DYNAMIC 0000000000600708 00000708
0000000000000190 0000000000000010 WA 5 0 8
[21] .got PROGBITS 0000000000600898 00000898
0000000000000008 0000000000000008 WA 0 0 8
[22] .got.plt PROGBITS 00000000006008a0 000008a0
0000000000000028 0000000000000008 WA 0 0 8
[23] .data PROGBITS 00000000006008c8 000008c8
0000000000000010 0000000000000000 WA 0 0 8
[24] .bss NOBITS 00000000006008d8 000008d8
0000000000000010 0000000000000000 WA 0 0 8
[25] .comment PROGBITS 0000000000000000 000008d8
000000000000003e 0000000000000001 MS 0 0 1
[26] .shstrtab STRTAB 0000000000000000 00000916
00000000000000e7 0000000000000000 0 0 1
[27] .symtab SYMTAB 0000000000000000 00001140
0000000000000660 0000000000000018 28 47 8
[28] .strtab STRTAB 0000000000000000 000017a0
000000000000025b 0000000000000000 0 0 1
execve("./hello", ["./hello"], [/* 41 vars */]) = 0
brk(0) = 0x151b000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f30733ef000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=62458, ...}) = 0
mmap(NULL, 62458, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f30733df000
close(3)= 0
open("/lib64/libc.so.6", O_RDONLY) = 3 //加载c语言库
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000\356!\2478\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1928936, ...}) = 0
mmap(0x38a7200000, 3750184, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x38a7200000
mprotect(0x38a738a000, 2097152, PROT_NONE) = 0
mmap(0x38a758a000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x18a000) = 0x38a758a000
mmap(0x38a7590000, 14632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x38a7590000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f30733de000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f30733dd000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f30733dc000
arch_prctl(ARCH_SET_FS, 0x7f30733dd700) = 0
mprotect(0x38a758a000, 16384, PROT_READ) = 0
mprotect(0x38a701f000, 4096, PROT_READ) = 0
munmap(0x7f30733df000, 62458) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f30733ee000
write(1, "hello world\n", 12hello world
) = 12
exit_group(0) = ?
+++ exited with 0 +++
int __open_nocancel(const char *file,int oflag,...)
{
int mode=0;if(oflagO_CREAT)
{va_list arg;
va_start(arg,oflag);
mode=va_arg(arg,int);
va_end(arg);
}
//系统调用编号
return INLINE_SYSCALL(openat,4,AT_FDCWD,file,oflag,mode);
}
# define INTERNAL_SYSCALL(name, err, nr, args...) \
({ \
register unsigned int resultvar; \
EXTRAVAR_##nr \
asm volatile ( \
LOADARGS_##nr \
"movl %1, %%eax\n\t" \
"int $0x80\n\t" \
RESTOREARGS_##nr \
: "=a" (resultvar) \
: "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc"); \
(int) resultvar; })
标签:
原文地址:http://www.cnblogs.com/zengyiwen/p/5755185.html