特定のプロセスのメモリ レイアウトを調べています。各プロセスの開始メモリ位置が 0 ではないことに気付きました。このWeb サイトでは、TEXT は 0x08048000 から始まります。1 つの理由は、アドレスを NULL ポインターで区別することです。他に正当な理由があるかどうか疑問に思っていますか?ありがとう。
3 に答える
A loader loads a binary in segments into memory: text (constants), data, code. There is no need to start from 0, and as C is has the problem from bugs accessing around null, like in a[i]
that is even dangerous. This allows (on some processors) to intercept segmentation faults.
It would be the C runtime introducing a linear address space from 0. That might be imaginable where C is the operating system's implementation language. But serves no purpose; to have the heap start from 0. The memory model is one of segments. A code segment might be protected against modification by some processors.
And in segments allocation happens in C runtime managed memory blocks.
I might add, that physical 0 and upwards is often used by the operating system itself.