地址的含义0x8048080 [英] significance of address 0x8048080
问题描述
为什么当我在gdb中调试asm源时是0x8048080为代码的起始入口点选择的地址?这只是相对偏移量,而不是指令存储器中的实际偏移量,对吗?
地址0x8048080
没有特殊意义,但地址0x08048000
有一个特殊含义.
后一个地址是默认地址,在Linux/x86上,ld
在该默认地址上开始第一个PT_LOAD
段.在Linux/x86_64上,默认值为0x400000
,您可以使用自定义"链接描述文件来更改默认值.您还可以更改.text
部分以-Wl,-Ttext,0xNNNNNNNN
标志开头的位置.
ld
从0x08048000
开始后,它将为程序头添加空间,并根据其内置链接程序脚本继续链接可执行文件的其余部分,您可以查看是否将-Wl,--verbose
传递给您的链接行.
对于您的程序,程序头的大小似乎始终为0x80
,因此您的.text
部分始终以0x8048080
开头,但这绝不是通用的.>
当我链接一个琐碎的int main() { return 0; }
程序时,我会在0x8048300
,0x8048178
或0x8048360
上得到&_start == &.text
,这取决于我使用的是哪个编译器.
why when i debug asm source in gdb is 0x8048080 the address chosen for the starting entry point into code? this is just a relative offset, not an actual offset of into memory of an instruction, correct?
There is no special significance to address 0x8048080
, but there is one for address 0x08048000
.
The latter address is the default address, on which ld
starts the first PT_LOAD
segment on Linux/x86. On Linux/x86_64, the default is 0x400000
, and you can change the default by using a "custom" linker script. You can also change where .text
section starts with -Wl,-Ttext,0xNNNNNNNN
flag.
After ld
starts at 0x08048000
, it adds space for program headers, and proceeds to link the rest of the executable according to its built-in linker script, which you can see if you pass in -Wl,--verbose
to your link line.
For your program, the size of program headers appears to always be 0x80
, so your .text
section always starts at 0x8048080
, but that is by no means universal.
When I link a trivial int main() { return 0; }
program, I get &_start == &.text
at 0x8048300
, 0x8048178
or 0x8048360
, depending on which compiler I use.
这篇关于地址的含义0x8048080的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!