问题
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?
回答1:
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.
回答2:
0×8048080 is the default entry point in virtual memory used by the Linux ld linker. You can change it to whatever you want.
for more details check out: http://eli.thegreenplace.net/2011/01/27/how-debuggers-work-part-2-breakpoints/
来源:https://stackoverflow.com/questions/5928869/significance-of-address-0x8048080