有了您的二进制文件,我正在从GDB不同的输出:
(gdb) r
Starting program: /tmp/sample.elf.bad
During startup program terminated with signal SIGKILL, Killed.
在二进制展望:
readelf -l sample.elf
Elf file type is EXEC (Executable file)
Entry point 0x8048080
There are 1 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000054 0x08048080 0x00000000 0x0000c 0x0000c R E 0x1000
这里你问内核mmap
与文件段偏移0x54
在虚拟地址0x08048080
。
由于这两个数字不等于彼此模页面大小,内核拒绝:
strace ./sample.elf
execve("./sample.elf", ["./sample.elf"], [/* 42 vars */] <unfinished ...>
+++ killed by SIGKILL +++
Killed
以上strace的意味着内核试图创建的过程中,并没有像它所认为,和终止它与偏见。没有执行二进制文件的单个指令。
杀青LOAD
虚拟地址和入口点是0x08048054
生产所需的工作可执行:
strace ./sample.elf
execve("./sample.elf", ["./sample.elf"], [/* 42 vars */]) = 0
[ Process PID=23172 runs in 32 bit mode. ]
_exit(0) = ?
+++ exited with 0 +++
这里是它的hexdump都:
hd ./sample.elf
00000000 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 10 |.ELF............|
00000010 02 00 03 00 01 00 00 00 54 80 04 08 34 00 00 00 |........T...4...|
00000020 00 00 00 00 00 00 00 00 34 00 20 00 01 00 28 00 |........4. ...(.|
00000030 00 00 00 00 01 00 00 00 54 00 00 00 54 80 04 08 |........T...T...|
00000040 00 00 00 00 0c 00 00 00 0c 00 00 00 05 00 00 00 |................|
00000050 00 10 00 00 b8 01 00 00 00 bb 00 00 00 00 cd 80 |................|
00000060
的可能的复制[如何制作一个可执行在Linux中使用十六进制编辑器的ELF文件?](http://stackoverflow.com/questions/26294034/how-to-make-an-executable-elf-file-in-linux-using-a-hex-editor)或否则它是调试这个“代码”问题。 –