免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 696 | 回复: 0
打印 上一主题 下一主题

Gnu c routines' entry point [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-06-24 21:47 |只看该作者 |倒序浏览

Gnu c routines' entry point

I have validated that “_start” is the entry point of Gnu c routines.
The following are the verified materials:

/* test.c */
int main(void)
{
}

root@ubuntu:/work/learning/c/before_main# gcc -g -o test test.c
root@ubuntu:/work/learning/c/before_main# readelf -h test
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:   0x80482c0     
  Start of program headers:          52 (bytes into file)
  Start of section headers:          3716 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         7
  Size of section headers:           40 (bytes)
  Number of section headers:         38
  Section header string table index: 35


root@ubuntu:/work/learning/c/before_main# gdb -q  test
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
(gdb) disassemble 0x80482c0                    //disassemble the entry point
Dump of assembler code for function _start:
0x080482c0 :  xor    %ebp,%ebp
0x080482c2 :  pop    %esi
0x080482c3 :  mov    %esp,%ecx
0x080482c5 :  and    $0xfffffff0,%esp
……
End of assembler dump.
(gdb)

root@ubuntu:/work/learning/c/before_main# objdump -t test | grep __main

root@ubuntu:/work/learning/c/before_main# objdump -t test | grep _start
08049420 l       .ctors 00000000              .hidden __init_array_start
0804951c  w      .data  00000000              data_start
080482c0 g     F .text  00000000              _start
00000000  w      *UND*  00000000              __gmon_start__
00000000       F *UND*  000001b2              __libc_start_main@@GLIBC_2.0
0804951c g       .data  00000000              __data_start
08049528 g       *ABS*  00000000              __bss_start

So the conclusion is that use “__main” as default entry point is arm’s implementation mode , while gnu c uses “_start” as default entry point.

Reference: >
http://school.21tx.com/2005/04/13/49121.html


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/60011/showart_1010500.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP