Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yup, they can. That way your code and data share the same address range, so you need to make sure that the offsets within the address range don't overlap.

It's also possible to configure the system so that your code lives in one segment, and your data and stack live in another. That way, you get 64kB for code and another 64kB for data.

We have to put the stack in the same segment as the data because C requires the stack to be addressable; if you're not working in C, you can put the stack in a third segment and get a bit more space.

Of course, if you're willing to use pointers which contain the segment as well as the offset, so 32 bits wide, you can use multiple segments, but that raises all sort of complexity that's not really worth thinking about these days.



Ah OK the segments have the same address just different offsets from that address is that correct?

You mention:

"We have to put the stack in the same segment as the data because C requires the stack to be addressable"

Are symbols only "reachable" if they are within the base and limit of same memory segment then? If this was the case I would think that the code and stack must be in the same segment? Why is the data segment?

Cheers.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: