_start

  
[root@localhost mini2440]# cat hello.c
#include <stdio.h>

int func_int(int tmp)
{
printf("func_int start\n");
printf("tmp=%d\n",tmp);
printf("func_int end\n");
return 0;

}

void func_void(int tmp)
{
printf("func_void start\n");
printf("tmp=%d\n",tmp);
printf("func_void end\n");
}

int main()
{
printf("main start\n");

func_int(6);
printf("//\n");
func_void(7);

printf("main end\n");
return 0;
}
[root@localhost mini2440]# gcc -o hello hello.c
[root@localhost mini2440]# ./hello
main start
func_int start
tmp=6
func_int end
//
func_void start
tmp=7
func_void end
main end
[root@localhost mini2440]# readelf -h hello//elf文件头
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:                              EXEC (Executable file)
  Machine:                           Intel 80386
  Version:                           0x1
  Entry point address:               0x8048340>://08048340,入口为libc的_start,不是自己的main
  Start of program headers:          52 (bytes into file)
  Start of section headers:          2432 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         8
  Size of section headers:           40 (bytes)
  Number of section headers:         30
  Section header string table index: 27
[root@localhost mini2440]# readelf -l  hello//可执行程序头
Elf file type is EXEC (Executable file)
Entry point 0x8048340    //08048340,入口为libc的_start
There are 8 program headers, starting at offset 52
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x08048034 0x08048034 0x00100 0x00100 R E 0x4
  INTERP         0x000134 0x08048134 0x08048134 0x00013 0x00013 R   0x1
      [Requesting program interpreter: /lib/ld-linux.so.2]
  LOAD           0x000000 0x08048000 0x08048000 0x00674 0x00674 R E 0x1000//代码segment(multiple sections)--vma
  LOAD           0x000674 0x08049674 0x08049674 0x00100 0x00108 RW  0x1000
  DYNAMIC        0x000688 0x08049688 0x08049688 0x000c8 0x000c8 RW  0x4
  NOTE           0x000148 0x08048148 0x08048148 0x00044 0x00044 R   0x4
  GNU_EH_FRAME   0x000600 0x08048600 0x08048600 0x0001c 0x0001c R   0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x4
Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame 
   03     .ctors .dtors .jcr .dynamic .got .got.plt .data .bss 
   04     .dynamic 
   05     .note.ABI-tag .note.gnu.build-id 
   06     .eh_frame_hdr 
   07    
[root@localhost mini2440]# objdump -S  hello

hello:     file format elf32-i386


Disassembly of section .init:

080482b4 <_init>:
 80482b4:	55                   	push   %ebp
 80482b5:	89 e5                	mov    %esp,%ebp
 80482b7:	53                   	push   %ebx
 80482b8:	83 ec 04             	sub    $0x4,%esp
 80482bb:	e8 00 00 00 00       	call   80482c0 <_init+0xc>
 80482c0:	5b                   	pop    %ebx
 80482c1:	81 c3 94 14 00 00    	add    $0x1494,%ebx
 80482c7:	8b 93 fc ff ff ff    	mov    -0x4(%ebx),%edx
 80482cd:	85 d2                	test   %edx,%edx
 80482cf:	74 05                	je     80482d6 <_init+0x22>
 80482d1:	e8 1e 00 00 00       	call   80482f4 <__gmon_start__@plt>
 80482d6:	e8 f5 00 00 00       	call   80483d0 <frame_dummy>
 80482db:	e8 50 02 00 00       	call   8048530 <__do_global_ctors_aux>
 80482e0:	58                   	pop    %eax
 80482e1:	5b                   	pop    %ebx
 80482e2:	c9                   	leave  
 80482e3:	c3                   	ret    

Disassembly of section .plt:

080482e4 <__gmon_start__@plt-0x10>:
 80482e4:	ff 35 58 97 04 08    	pushl  0x8049758
 80482ea:	ff 25 5c 97 04 08    	jmp    *0x804975c
 80482f0:	00 00                	add    %al,(%eax)
	...

080482f4 <__gmon_start__@plt>:
 80482f4:	ff 25 60 97 04 08    	jmp    *0x8049760
 80482fa:	68 00 00 00 00       	push   $0x0
 80482ff:	e9 e0 ff ff ff       	jmp    80482e4 <_init+0x30>

08048304 <__libc_start_main@plt>:
 8048304:	ff 25 64 97 04 08    	jmp    *0x8049764
 804830a:	68 08 00 00 00       	push   $0x8
 804830f:	e9 d0 ff ff ff       	jmp    80482e4 <_init+0x30>

08048314 <printf@plt>:
 8048314:	ff 25 68 97 04 08    	jmp    *0x8049768
 804831a:	68 10 00 00 00       	push   $0x10
 804831f:	e9 c0 ff ff ff       	jmp    80482e4 <_init+0x30>

08048324 <puts@plt>:
 8048324:	ff 25 6c 97 04 08    	jmp    *0x804976c
 804832a:	68 18 00 00 00       	push   $0x18
 804832f:	e9 b0 ff ff ff       	jmp    80482e4 <_init+0x30>

Disassembly of section .text:

08048340 <_start>://08048340
 8048340:	31 ed                	xor    %ebp,%ebp
 8048342:	5e                   	pop    %esi
 8048343:	89 e1                	mov    %esp,%ecx
 8048345:	83 e4 f0             	and    $0xfffffff0,%esp
 8048348:	50                   	push   %eax
 8048349:	54                   	push   %esp
 804834a:	52                   	push   %edx
 804834b:	68 c0 84 04 08       	push   $0x80484c0
 8048350:	68 d0 84 04 08       	push   $0x80484d0
 8048355:	51                   	push   %ecx
 8048356:	56                   	push   %esi
 8048357:	68 5f 84 04 08       	push   $0x804845f
 804835c:	e8 a3 ff ff ff       	call   8048304 <__libc_start_main@plt>
 8048361:	f4                   	hlt    
 8048362:	90                   	nop    
 8048363:	90                   	nop    
 8048364:	90                   	nop    
 8048365:	90                   	nop    
 8048366:	90                   	nop    
 8048367:	90                   	nop    
 8048368:	90                   	nop    
 8048369:	90                   	nop    
 804836a:	90                   	nop    
 804836b:	90                   	nop    
 804836c:	90                   	nop    
 804836d:	90                   	nop    
 804836e:	90                   	nop    
 804836f:	90                   	nop    
..............................................
080483f4 <func_int>:
 80483f4:	55                   	push   %ebp
 80483f5:	89 e5                	mov    %esp,%ebp
 80483f7:	83 ec 08             	sub    $0x8,%esp
 80483fa:	c7 04 24 84 85 04 08 	movl   $0x8048584,(%esp)
 8048401:	e8 1e ff ff ff       	call   8048324 <puts@plt>
 8048406:	8b 45 08             	mov    0x8(%ebp),%eax
 8048409:	89 44 24 04          	mov    %eax,0x4(%esp)
 804840d:	c7 04 24 93 85 04 08 	movl   $0x8048593,(%esp)
 8048414:	e8 fb fe ff ff       	call   8048314 <printf@plt>
 8048419:	c7 04 24 9b 85 04 08 	movl   $0x804859b,(%esp)
 8048420:	e8 ff fe ff ff       	call   8048324 <puts@plt>
 8048425:	b8 00 00 00 00       	mov    $0x0,%eax
 804842a:	c9                   	leave  
 804842b:	c3                   	ret    

0804842c <func_void>:
 804842c:	55                   	push   %ebp
 804842d:	89 e5                	mov    %esp,%ebp
 804842f:	83 ec 08             	sub    $0x8,%esp
 8048432:	c7 04 24 a8 85 04 08 	movl   $0x80485a8,(%esp)
 8048439:	e8 e6 fe ff ff       	call   8048324 <puts@plt>
 804843e:	8b 45 08             	mov    0x8(%ebp),%eax
 8048441:	89 44 24 04          	mov    %eax,0x4(%esp)
 8048445:	c7 04 24 93 85 04 08 	movl   $0x8048593,(%esp)
 804844c:	e8 c3 fe ff ff       	call   8048314 <printf@plt>
 8048451:	c7 04 24 b8 85 04 08 	movl   $0x80485b8,(%esp)
 8048458:	e8 c7 fe ff ff       	call   8048324 <puts@plt>
 804845d:	c9                   	leave  
 804845e:	c3                   	ret    

0804845f <main>:
 804845f:	8d 4c 24 04          	lea    0x4(%esp),%ecx
 8048463:	83 e4 f0             	and    $0xfffffff0,%esp
 8048466:	ff 71 fc             	pushl  -0x4(%ecx)
 8048469:	55                   	push   %ebp
 804846a:	89 e5                	mov    %esp,%ebp
 804846c:	51                   	push   %ecx
 804846d:	83 ec 04             	sub    $0x4,%esp
 8048470:	c7 04 24 c6 85 04 08 	movl   $0x80485c6,(%esp)
 8048477:	e8 a8 fe ff ff       	call   8048324 <puts@plt>
 804847c:	c7 04 24 06 00 00 00 	movl   $0x6,(%esp)
 8048483:	e8 6c ff ff ff       	call   80483f4 <func_int>
 8048488:	c7 04 24 d4 85 04 08 	movl   $0x80485d4,(%esp)
 804848f:	e8 90 fe ff ff       	call   8048324 <puts@plt>
 8048494:	c7 04 24 07 00 00 00 	movl   $0x7,(%esp)
 804849b:	e8 8c ff ff ff       	call   804842c <func_void>
 80484a0:	c7 04 24 f7 85 04 08 	movl   $0x80485f7,(%esp)
 80484a7:	e8 78 fe ff ff       	call   8048324 <puts@plt>
 80484ac:	b8 00 00 00 00       	mov    $0x0,%eax
 80484b1:	83 c4 04             	add    $0x4,%esp
 80484b4:	59                   	pop    %ecx
 80484b5:	5d                   	pop    %ebp
 80484b6:	8d 61 fc             	lea    -0x4(%ecx),%esp
 80484b9:	c3                   	ret    
 80484ba:	90                   	nop    
 80484bb:	90                   	nop    
 80484bc:	90                   	nop    
 80484bd:	90                   	nop    
 80484be:	90                   	nop    
 80484bf:	90                   	nop    
....................... 
 
 

                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值