3 ms·
That's helpful! Then why is it that libc is the one setting up the stack if this is a convention basically required by the processor?
by eatonphil 6y ago
That's helpful! Then why is it that libc is the one setting up the stack if this is a convention basically required by the processor?
- ajross 6y agoBecause the runtime linker (e.g. ld-linux.so) is implemented in the C library, as is the user-callable implementation of pthread_create() or whatever[1]. It's definitely the application's job to decide on its own memory layout in any case. The kernel doesn't tell you where your stack should be, it's your address space. [1] vs. the clone() Linux syscall, which isn't really useful to regular code because of the complexity.