aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Comstedt <marcus@mc.pp.se>2020-10-18 11:42:15 +0200
committerMarcus Comstedt <marcus@mc.pp.se>2020-11-11 19:30:09 +0100
commit5752f0a173b84a76b772ee0abc8b4a1ad99d301d (patch)
tree8dac4e1174298eaf6dcf1865e2bc6aeefa2f705d
parent8ac2e518fea93dfda9e617a09d13252a0f67831f (diff)
downloadriscv-pk-5752f0a173b84a76b772ee0abc8b4a1ad99d301d.zip
riscv-pk-5752f0a173b84a76b772ee0abc8b4a1ad99d301d.tar.gz
riscv-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).)
-rw-r--r--pk/pk.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/pk/pk.c b/pk/pk.c
index bce11a5..87dfc78 100644
--- a/pk/pk.c
+++ b/pk/pk.c
@@ -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 */ \