Start / exec a process with initial stack at a custom address

Viewed 78

I would like to change the starting stack address of a program on linux.

I've checked a bit the kernel source, found out about

extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
                           unsigned long new_sp);

from https://github.com/torvalds/linux/blob/29c395c77a9a514c5857c45ceae2665e9bd99ac7/arch/x86/include/asm/processor.h

But I didn't find a way to inluence it from outside (of the kernel).

Ideally some configuration of my OS (debian) for a defined program would be perfect. But I don't know how to do that ...

I know about some stack related function like setrlimit() and ulimit() but that doesn't do the job.

May be gdb has some features like that? (It's not a problem if the program runs inside gdb.)

Since it's a program that I wrote, I also thought about doing a big malloc at program startup and change esp/ebp to point to it. But that's not ideal.

If anybody know some dark features of Linux process creation that would be nice!

0 Answers
Related