diff options
author | Marcus Comstedt <marcus@mc.pp.se> | 2020-10-18 11:42:15 +0200 |
---|---|---|
committer | Marcus Comstedt <marcus@mc.pp.se> | 2020-11-11 19:30:09 +0100 |
commit | 5752f0a173b84a76b772ee0abc8b4a1ad99d301d (patch) | |
tree | 8dac4e1174298eaf6dcf1865e2bc6aeefa2f705d /pk | |
parent | 8ac2e518fea93dfda9e617a09d13252a0f67831f (diff) | |
download | pk-5752f0a173b84a76b772ee0abc8b4a1ad99d301d.zip pk-5752f0a173b84a76b772ee0abc8b4a1ad99d301d.tar.gz pk-5752f0a173b84a76b772ee0abc8b4a1ad99d301d.tar.bz2 |
pk: Fix pushing of argc to match linux kernel behaviour
The linux kernel pushes argc as an int, not an uintptr_t.
(The offset to the next element is still sizeof(uintptr_t).)
Diffstat (limited to 'pk')
-rw-r--r-- | pk/pk.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -129,15 +129,15 @@ static void run_loaded_program(size_t argc, char** argv, uintptr_t kstack_top) // place argc, argv, envp, auxp on stack #define PUSH_ARG(type, value) do { \ *((type*)sp) = (type)value; \ - sp += sizeof(type); \ + sp ++; \ } while (0) #define STACK_INIT(type) do { \ unsigned naux = sizeof(aux)/sizeof(aux[0]); \ stack_top -= (1 + argc + 1 + envc + 1 + 2*naux) * sizeof(type); \ stack_top &= -16; \ - long sp = stack_top; \ - PUSH_ARG(type, argc); \ + type *sp = (void*)stack_top; \ + PUSH_ARG(int, argc); \ for (unsigned i = 0; i < argc; i++) \ PUSH_ARG(type, argv[i]); \ PUSH_ARG(type, 0); /* argv[argc] = NULL */ \ |