Why is the entry point address in my executable 0x8048330? (0x330 being the offset of .text section)

后端 未结 3 1829
暖寄归人
暖寄归人 2020-12-15 18:24

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



        
3条回答
  •  既然无缘
    2020-12-15 18:50

    For first question:

    the entry point you saw, 0x8048330, is a virtual memory address (in the opposite, is physical memory). This means your executive doesn't have to know what physical address to map. (after it loads with a loader) It doesn't even have the access to the physical memory. To the process of your program, your .text section always starts from 0x8048330, your system (OS and hardware) will then map it (the virtual address) to the physical memory at run-time.

    mapping and managing physical memory is a lot of things, you can check on Google for more information.

    For the second question

    I'm not sure which part confused you so I'll try to cover them all:

    • Could more than one program have same entry point?

    Yes, there could be another program with the same entry point 0x8048330. because this address is virtual, the programs will be mapped to different physical memory at run-time when you try to run them at the same time.

    • Does the entry always 0x8048330?

    Well, Linux executives are start from 0x8048000, but the offset of .text section is related to other sections length. So no, it could be 0x8048034 or anything else.

    • Why it always start from 0x8048000?

    I think it's kind of history thing, the designer of Linux picked this one for some unknown or even random reason. you can refer this thread to see what under that area.

提交回复
热议问题