为什么在我的可执行文件的入口点地址为0x8048330(0x330所抵消.text段中) [英] why the Entry point address in my executable is 0x8048330 (0x330 being offset of .text section)

查看:658
本文介绍了为什么在我的可执行文件的入口点地址为0x8048330(0x330所抵消.text段中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个小程序添加到整数,并使用readelf -a executable_name这表明入口点地址ELF头为:

I wrote a small program to add to integers and on using "readelf -a executable_name" it showed the entry point address in elf header as :

Entry point address: 0x8048330

我的可执行文件是如何知道这个地址预先加载器加载到内存中甚至在?
elf_format.pdf说,这成员给出了虚拟地址到系统首先将控制权转移,从而启动进程。任何人都可以请解释什么是这句话的意思,什么是这里的虚拟地址的意义?

How my executable knows this address beforehand even before loader loads it in memory ? elf_format.pdf says this member gives the virtual address to which the system first transfers control, thus starting the process. Can anyone please explain what is the meaning of this statement and what is the meaning of virtual address here ?

也让我知道了,从哪里可执行文件获取为切入点地址0x8048330的值。只是交叉检查我编译另一个程序和也,入口点地址将保持不变值0x8048330(偏移.text段在两种情况下是0x330的)。

Also let me know, from where the executable file gets the value of 0x8048330 as entry point address. just for cross check i compiled another program and for that also, the entry point address remains the same value 0x8048330 (offset of .text section being 0x330 in both the cases).

推荐答案

在它创建的​​入口地址被链接编辑器设置,在当时
可执行文件。加载程序文件映射在指定的地址(ES)
由ELF头之前,控制权转交给入口地址。

The entry address is set by the link editor, at the time when it creates the executable. The loader maps the program file at the address(es) specified by the ELF headers before transferring control to the entry address.

要使用一个具体的例子,考虑以下几点:

To use a concrete example, consider the following:

% file a.out
a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, \
    for GNU/Linux 2.6.15, not stripped
% readelf -e a.out
... snip ...
Elf file type is EXEC (Executable file)
Entry point 0x8048170
There are 6 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000000 0x08048000 0x08048000 0x7cca6 0x7cca6 R E 0x1000
  LOAD           0x07cf98 0x080c5f98 0x080c5f98 0x00788 0x022fc RW  0x1000
... snip ...

第一程序头指定该文件中的内容
文件偏移0应映射到虚拟地址0x08048000。该
文件和内存大小这部分是0x7cca6字节。这个
段是在可读和可执行但不可写要映射
(它包含程序的code)。

The first program header specifies that the contents of the file at file offset 0 should be mapped to virtual address 0x08048000. The file and memory sizes for this segment are 0x7cca6 bytes. This segment is to be mapped in readable and executable but not writable (it contains the program's code).

在ELF头指定的入口地址为0x8048170,这
瀑布含计划code中的区域内。

The entry point address specified in the ELF header is 0x8048170, which falls inside the region containing program code.

这本书链接器和加载的约翰·莱文是一个很好的资源,就链接编辑器和加载器相关事宜进行磋商。

The book "Linkers and Loaders" by John Levine is a good resource to consult on matters related to link editors and loaders.

这篇关于为什么在我的可执行文件的入口点地址为0x8048330(0x330所抵消.text段中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆