Memory Layout of a Program in C
web.eecs.utk.edu
Memory Layout of a Program in C
1–10 of 38 posts
Re: Memory Layout of a Program in C
#2Re: Memory Layout of a Program in C
#3So this is a whole lot more complicated these days. There's not one stack but many for the different threads, regions have guard pages typically, and all these regions are setup with mmap (so there's no sbrk syscall anymore) just for starters.
Re: Memory Layout of a Program in C
#4So this is a whole lot more complicated these days. There's not one stack but many for the different threads, regions have guard pages typically, and all these regions are setup with mmap (so there's no sbrk syscall anymore) just for starters.
strace ls
execve("/usr/bin/ls", ["ls"], 0x7ffd86646d90 /* 61 vars */) = 0
brk(NULL) = 0x5581b6542000
I see brk(), that's glibc.Re: Memory Layout of a Program in C
#5I'm not sure how true this is outside of a particular platform/compiler. As far as I'm aware, C doesn't actually define how pointers are represented, only that they are a reference to memory (although null is a special case). Pointers in C are very abstract which allows for much more aggressive optimisations.
And all this is before we get into how memory actually works in practice, such as CPU cache lines.
Re: Memory Layout of a Program in C
#6So this is a whole lot more complicated these days. There's not one stack but many for the different threads, regions have guard pages typically, and all these regions are setup with mmap (so there's no sbrk syscall anymore) just for starters.
strace ls execve("/usr/bin/ls", ["ls"], 0x7ffd86646d90 /* 61 vars */) = 0 brk(NULL) = 0x5581b6542000 I see brk(), that's glibc.
Re: Memory Layout of a Program in C
#7> As I have said previously, memory is like a huge array with (say) 0xffffffff elements. A pointer in C is an index to this array. Thus when a C pointer is 0xefffe034, it points to the 0xefffe035th element in the memory array (memory being indexed starting with zero). I'm not sure how true this is outside of a particular platform/compiler. As far as I'm aware, C doesn't actually define how pointers are represented, o…
[1]: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2263.htm#q3...
Re: Memory Layout of a Program in C
#8> As I have said previously, memory is like a huge array with (say) 0xffffffff elements. A pointer in C is an index to this array. Thus when a C pointer is 0xefffe034, it points to the 0xefffe035th element in the memory array (memory being indexed starting with zero). I'm not sure how true this is outside of a particular platform/compiler. As far as I'm aware, C doesn't actually define how pointers are represented, o…
Re: Memory Layout of a Program in C
#9Re: Memory Layout of a Program in C
#10> As I have said previously, memory is like a huge array with (say) 0xffffffff elements. A pointer in C is an index to this array. Thus when a C pointer is 0xefffe034, it points to the 0xefffe035th element in the memory array (memory being indexed starting with zero). I'm not sure how true this is outside of a particular platform/compiler. As far as I'm aware, C doesn't actually define how pointers are represented, o…
For another example, the LLVM webassembly backend doesn't put the call stack in the same address space as the heap at all.