syscall_exec: handle R2L and L2R stacking compilers
authorAlan Cox <alan@linux.intel.com>
Fri, 16 Jan 2015 13:36:58 +0000 (13:36 +0000)
committerAlan Cox <alan@linux.intel.com>
Fri, 16 Jan 2015 13:36:58 +0000 (13:36 +0000)
Kernel/platform-tgl6502/config.h
Kernel/syscall_exec.c

index cabfc8c..bac8e9d 100644 (file)
@@ -12,6 +12,8 @@
 #undef CONFIG_SINGLETASK
 #define CONFIG_BANKS   2
 
+#define CONFIG_CALL_R2L                /* Runtime stacks arguments backwards */
+
 /* For now used BANK_FIXED as we don't yet have sane swap with 16K maps */
 #define CONFIG_BANK_FIXED
 #define MAX_MAPS 2
index d0b5f59..7968386 100644 (file)
@@ -54,7 +54,6 @@ int16_t _execve(void)
 {
        staticfast inoptr ino, emu_ino;
        staticfast unsigned char *buf;
-       staticfast blkno_t blk;
        char **nargv;           /* In user space */
        char **nenvp;           /* In user space */
        staticfast struct s_argblk *abuf, *ebuf;
@@ -256,8 +255,13 @@ int16_t _execve(void)
        brelse(ebuf);
 
        // Shove argc and the address of argv just below envp
+#ifdef CONFIG_CALL_R2L /* Arguments are stacked the 'wrong' way around */
        uputw((uint16_t) nargv, nenvp - 1);
        uputw((uint16_t) argc, nenvp - 2);
+#else
+       uputw((uint16_t) nargv, nenvp - 1);
+       uputw((uint16_t) argc, nenvp - 2);
+#endif
 
        // Set stack pointer for the program
        udata.u_isp = nenvp - 2;