@@ -937,6 +937,21 @@ int main(int argc, char **argv, char **envp) {
937
937
sp = (long * )(argv - 1 );
938
938
auxv = (long * )(envp + i + 1 );
939
939
940
+ /* create new bottom of stack for spawned program
941
+ system v abi aligns this on a 16-byte boundary
942
+ grows down the alloc by poking the guard pages */
943
+ n = (auxv - sp + AUXV_WORDS + 1 ) * sizeof (long );
944
+ sp2 = (long * )__builtin_alloca (n );
945
+ if ((long )sp2 & 15 ) ++ sp2 ;
946
+ for (; n > 0 ; n -= pagesz ) {
947
+ ((char * )sp2 )[n - 1 ] = 0 ;
948
+ }
949
+ memmove (sp2 , sp , (auxv - sp ) * sizeof (long ));
950
+ argv = (char * * )(sp2 + 1 );
951
+ envp = (char * * )(sp2 + 1 + argc + 1 );
952
+ auxv = sp2 + (auxv - sp );
953
+ sp = sp2 ;
954
+
940
955
/* interpret command line arguments */
941
956
if ((M -> ps .literally = argc >= 3 && !StrCmp (argv [1 ], "-" ))) {
942
957
/* if the first argument is a hyphen then we give the user the
@@ -959,21 +974,6 @@ int main(int argc, char **argv, char **envp) {
959
974
argv = (char * * )((sp += 1 ) + 1 );
960
975
}
961
976
962
- /* create new bottom of stack for spawned program
963
- system v abi aligns this on a 16-byte boundary
964
- grows down the alloc by poking the guard pages */
965
- n = (auxv - sp + AUXV_WORDS + 1 ) * sizeof (long );
966
- sp2 = (long * )__builtin_alloca (n );
967
- if ((long )sp2 & 15 ) ++ sp2 ;
968
- for (; n > 0 ; n -= pagesz ) {
969
- ((char * )sp2 )[n - 1 ] = 0 ;
970
- }
971
- memmove (sp2 , sp , (auxv - sp ) * sizeof (long ));
972
- argv = (char * * )(sp2 + 1 );
973
- envp = (char * * )(sp2 + 1 + argc + 1 );
974
- auxv = sp2 + (auxv - sp );
975
- sp = sp2 ;
976
-
977
977
/* allocate ephemeral memory for reading file */
978
978
n = sizeof (union ElfEhdrBuf );
979
979
ebuf = (union ElfEhdrBuf * )__builtin_alloca (n );
0 commit comments