What's the memory before 0x08048000 used for in 32 bit machine?

前端 未结 4 2017
时光说笑
时光说笑 2020-12-05 00:38

In Linux, I learned that every process stores data starting at 0x08048000 in 32 bit machine (and 0x00400000 in 64 bit machine).

But I don\'t know the reason why star

4条回答
  •  渐次进展
    2020-12-05 01:26

    The start address for loading executable code is determined by the ELF headers for the executable. For example:

    /bin/ls
    architecture: i386, flags 0x00000112:
    EXEC_P, HAS_SYMS, D_PAGED
    start address 0x08049bb0
    

    There's nothing stopping an executable from specifying a different load address; for whatever reason the default linker settings put it there. You could override with a custom linker script.

    By default, on linux/x86, you won't see low addresses below 0x08000000 used for much; although the kernel may use it if requested in a mmap call, or if it runs out of room for mmaps. Additionally, there have been proposals to use addresses in the 0x00000000 - 0x01000000 range for library mappings, to make buffer overflows more difficult (by embedding a NUL byte to terminate strings).

提交回复
热议问题