How does works the allocation of a writable/readable segment in ELF?

A segment of *PT_LOAD* type, flags *PF_write | PF_read*, *p_filesiz = x* and
*p_memsiz = x+y* it's up to the kernel allocate *p_memsiz*, correct? How
does this allocation actually works? the kernel allocate *p_memsiz* and put
the begging of this block memory on *p_vaddr* so that the write/read memory
region of this segment is from *p_vaddr* up to *p_vaddr + p_memsiz*? if so,
what values(address) is the kernel expecting at *p_vaddr* at time before it
does the allocation?

This question isn’t on-topic for this list (we’re compiler devs, not kernel devs). If you want to look at exactly how this works you can check out the linux source code <> or the source code of various other kernels (*BSD, illumos, Haiku, Xv6 (might be easiest)). IIRC that is where I learned about it.

– Sean Silva

What I'm trying to understand here is segment in the ELF file format that's
the binary file format used in most modern UNIX as output of compilers for
this platform. And It's still (very highly) compiler's back-end related.

bcc cfe-dev

Your question is compiler backend related, which makes it more appropriate for The Clang mailing list is more frontend-oriented.

Then you may have better luck posting your question to the llvmdev mailing list.
The "fe" in cfe-dev stands for front-end :slight_smile:


Csaba Raduly wrote