Commit fddc8f81 authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Paul E. McKenney
Browse files

tools/nolibc: use C89 comment syntax



Most of nolibc is already using C89 comments.

Signed-off-by: default avatarThomas Weißschuh <linux@weissschuh.net>
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
parent 0738c2d7
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -176,24 +176,24 @@ const unsigned long *_auxv __attribute__((weak));
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
{
	__asm__ volatile (
		"ldr x0, [sp]\n"     // argc (x0) was in the stack
		"add x1, sp, 8\n"    // argv (x1) = sp
		"lsl x2, x0, 3\n"    // envp (x2) = 8*argc ...
		"add x2, x2, 8\n"    //           + 8 (skip null)
		"add x2, x2, x1\n"   //           + argv
		"adrp x3, environ\n"          // x3 = &environ (high bits)
		"str x2, [x3, #:lo12:environ]\n" // store envp into environ
		"mov x4, x2\n"       // search for auxv (follows NULL after last env)
		"ldr x0, [sp]\n"     /* argc (x0) was in the stack                          */
		"add x1, sp, 8\n"    /* argv (x1) = sp                                      */
		"lsl x2, x0, 3\n"    /* envp (x2) = 8*argc ...                              */
		"add x2, x2, 8\n"    /*           + 8 (skip null)                           */
		"add x2, x2, x1\n"   /*           + argv                                    */
		"adrp x3, environ\n"          /* x3 = &environ (high bits)                  */
		"str x2, [x3, #:lo12:environ]\n" /* store envp into environ                 */
		"mov x4, x2\n"       /* search for auxv (follows NULL after last env)       */
		"0:\n"
		"ldr x5, [x4], 8\n"  // x5 = *x4; x4 += 8
		"cbnz x5, 0b\n"      // and stop at NULL after last env
		"adrp x3, _auxv\n"   // x3 = &_auxv (high bits)
		"str x4, [x3, #:lo12:_auxv]\n" // store x4 into _auxv
		"and sp, x1, -16\n"  // sp must be 16-byte aligned in the callee
		"bl main\n"          // main() returns the status code, we'll exit with it.
		"mov x8, 93\n"       // NR_exit == 93
		"ldr x5, [x4], 8\n"  /* x5 = *x4; x4 += 8                                   */
		"cbnz x5, 0b\n"      /* and stop at NULL after last env                     */
		"adrp x3, _auxv\n"   /* x3 = &_auxv (high bits)                             */
		"str x4, [x3, #:lo12:_auxv]\n" /* store x4 into _auxv                       */
		"and sp, x1, -16\n"  /* sp must be 16-byte aligned in the callee            */
		"bl main\n"          /* main() returns the status code, we'll exit with it. */
		"mov x8, 93\n"       /* NR_exit == 93                                       */
		"svc #0\n"
	);
	__builtin_unreachable();
}
#endif // _NOLIBC_ARCH_AARCH64_H
#endif /* _NOLIBC_ARCH_AARCH64_H */
+22 −22
Original line number Diff line number Diff line
@@ -203,34 +203,34 @@ const unsigned long *_auxv __attribute__((weak));
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
{
	__asm__ volatile (
		"pop {%r0}\n"                 // argc was in the stack
		"mov %r1, %sp\n"              // argv = sp
		"pop {%r0}\n"                 /* argc was in the stack                               */
		"mov %r1, %sp\n"              /* argv = sp                                           */

		"add %r2, %r0, $1\n"          // envp = (argc + 1) ...
		"lsl %r2, %r2, $2\n"          //        * 4        ...
		"add %r2, %r2, %r1\n"         //        + argv
		"ldr %r3, 1f\n"               // r3 = &environ (see below)
		"str %r2, [r3]\n"             // store envp into environ
		"add %r2, %r0, $1\n"          /* envp = (argc + 1) ...                               */
		"lsl %r2, %r2, $2\n"          /*        * 4        ...                               */
		"add %r2, %r2, %r1\n"         /*        + argv                                       */
		"ldr %r3, 1f\n"               /* r3 = &environ (see below)                           */
		"str %r2, [r3]\n"             /* store envp into environ                             */

		"mov r4, r2\n"                // search for auxv (follows NULL after last env)
		"mov r4, r2\n"                /* search for auxv (follows NULL after last env)       */
		"0:\n"
		"mov r5, r4\n"                // r5 = r4
		"add r4, r4, #4\n"            // r4 += 4
		"ldr r5,[r5]\n"               // r5 = *r5 = *(r4-4)
		"cmp r5, #0\n"                // and stop at NULL after last env
		"mov r5, r4\n"                /* r5 = r4                                             */
		"add r4, r4, #4\n"            /* r4 += 4                                             */
		"ldr r5,[r5]\n"               /* r5 = *r5 = *(r4-4)                                  */
		"cmp r5, #0\n"                /* and stop at NULL after last env                     */
		"bne 0b\n"
		"ldr %r3, 2f\n"               // r3 = &_auxv (low bits)
		"str r4, [r3]\n"              // store r4 into _auxv
		"ldr %r3, 2f\n"               /* r3 = &_auxv (low bits)                              */
		"str r4, [r3]\n"              /* store r4 into _auxv                                 */

		"mov %r3, $8\n"               // AAPCS : sp must be 8-byte aligned in the
		"neg %r3, %r3\n"              //         callee, and bl doesn't push (lr=pc)
		"and %r3, %r3, %r1\n"         // so we do sp = r1(=sp) & r3(=-8);
		"mov %sp, %r3\n"              //
		"mov %r3, $8\n"               /* AAPCS : sp must be 8-byte aligned in the            */
		"neg %r3, %r3\n"              /*         callee, and bl doesn't push (lr=pc)         */
		"and %r3, %r3, %r1\n"         /* so we do sp = r1(=sp) & r3(=-8);                    */
		"mov %sp, %r3\n"

		"bl main\n"                   // main() returns the status code, we'll exit with it.
		"movs r7, $1\n"               // NR_exit == 1
		"bl main\n"                   /* main() returns the status code, we'll exit with it. */
		"movs r7, $1\n"               /* NR_exit == 1                                        */
		"svc $0x00\n"
		".align 2\n"                  // below are the pointers to a few variables
		".align 2\n"                  /* below are the pointers to a few variables           */
		"1:\n"
		".word environ\n"
		"2:\n"
@@ -239,4 +239,4 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
	__builtin_unreachable();
}

#endif // _NOLIBC_ARCH_ARM_H
#endif /* _NOLIBC_ARCH_ARM_H */
+20 −20
Original line number Diff line number Diff line
@@ -194,31 +194,31 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"),no_stack_protec
{
	__asm__ volatile (
#ifdef NOLIBC_STACKPROTECTOR
		"call __stack_chk_init\n"   // initialize stack protector
		"call __stack_chk_init\n"   /* initialize stack protector                    */
#endif
		"pop %eax\n"                // argc   (first arg, %eax)
		"mov %esp, %ebx\n"          // argv[] (second arg, %ebx)
		"lea 4(%ebx,%eax,4),%ecx\n" // then a NULL then envp (third arg, %ecx)
		"mov %ecx, environ\n"       // save environ
		"xor %ebp, %ebp\n"          // zero the stack frame
		"mov %ecx, %edx\n"          // search for auxv (follows NULL after last env)
		"pop %eax\n"                /* argc   (first arg, %eax)                      */
		"mov %esp, %ebx\n"          /* argv[] (second arg, %ebx)                     */
		"lea 4(%ebx,%eax,4),%ecx\n" /* then a NULL then envp (third arg, %ecx)       */
		"mov %ecx, environ\n"       /* save environ                                  */
		"xor %ebp, %ebp\n"          /* zero the stack frame                          */
		"mov %ecx, %edx\n"          /* search for auxv (follows NULL after last env) */
		"0:\n"
		"add $4, %edx\n"            // search for auxv using edx, it follows the
		"cmp -4(%edx), %ebp\n"      // ... NULL after last env (ebp is zero here)
		"add $4, %edx\n"            /* search for auxv using edx, it follows the     */
		"cmp -4(%edx), %ebp\n"      /* ... NULL after last env (ebp is zero here)    */
		"jnz 0b\n"
		"mov %edx, _auxv\n"         // save it into _auxv
		"and $-16, %esp\n"          // x86 ABI : esp must be 16-byte aligned before
		"sub $4, %esp\n"            // the call instruction (args are aligned)
		"push %ecx\n"               // push all registers on the stack so that we
		"push %ebx\n"               // support both regparm and plain stack modes
		"mov %edx, _auxv\n"         /* save it into _auxv                            */
		"and $-16, %esp\n"          /* x86 ABI : esp must be 16-byte aligned before  */
		"sub $4, %esp\n"            /* the call instruction (args are aligned)       */
		"push %ecx\n"               /* push all registers on the stack so that we    */
		"push %ebx\n"               /* support both regparm and plain stack modes    */
		"push %eax\n"
		"call main\n"               // main() returns the status code in %eax
		"mov %eax, %ebx\n"          // retrieve exit code (32-bit int)
		"movl $1, %eax\n"           // NR_exit == 1
		"int $0x80\n"               // exit now
		"hlt\n"                     // ensure it does not
		"call main\n"               /* main() returns the status code in %eax        */
		"mov %eax, %ebx\n"          /* retrieve exit code (32-bit int)               */
		"movl $1, %eax\n"           /* NR_exit == 1                                  */
		"int $0x80\n"               /* exit now                                      */
		"hlt\n"                     /* ensure it does not                            */
	);
	__builtin_unreachable();
}

#endif // _NOLIBC_ARCH_I386_H
#endif /* _NOLIBC_ARCH_I386_H */
+19 −19
Original line number Diff line number Diff line
@@ -158,7 +158,7 @@ const unsigned long *_auxv __attribute__((weak));
#define LONG_ADDI    "addi.w"
#define LONG_SLL     "slli.w"
#define LONG_BSTRINS "bstrins.w"
#else // __loongarch_grlen == 64
#else /* __loongarch_grlen == 64 */
#define LONGLOG      "3"
#define SZREG        "8"
#define REG_L        "ld.d"
@@ -173,28 +173,28 @@ const unsigned long *_auxv __attribute__((weak));
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
{
	__asm__ volatile (
		REG_L        " $a0, $sp, 0\n"         // argc (a0) was in the stack
		LONG_ADDI    " $a1, $sp, "SZREG"\n"   // argv (a1) = sp + SZREG
		LONG_SLL     " $a2, $a0, "LONGLOG"\n" // envp (a2) = SZREG*argc ...
		LONG_ADDI    " $a2, $a2, "SZREG"\n"   //             + SZREG (skip null)
		LONG_ADD     " $a2, $a2, $a1\n"       //             + argv
		REG_L        " $a0, $sp, 0\n"         /* argc (a0) was in the stack                          */
		LONG_ADDI    " $a1, $sp, "SZREG"\n"   /* argv (a1) = sp + SZREG                              */
		LONG_SLL     " $a2, $a0, "LONGLOG"\n" /* envp (a2) = SZREG*argc ...                          */
		LONG_ADDI    " $a2, $a2, "SZREG"\n"   /*             + SZREG (skip null)                     */
		LONG_ADD     " $a2, $a2, $a1\n"       /*             + argv                                  */

		"move          $a3, $a2\n"            // iterate a3 over envp to find auxv (after NULL)
		"0:\n"                                // do {
		REG_L        " $a4, $a3, 0\n"         //   a4 = *a3;
		LONG_ADDI    " $a3, $a3, "SZREG"\n"   //   a3 += sizeof(void*);
		"bne           $a4, $zero, 0b\n"      // } while (a4);
		"la.pcrel      $a4, _auxv\n"          // a4 = &_auxv
		LONG_S       " $a3, $a4, 0\n"         // store a3 into _auxv
		"move          $a3, $a2\n"            /* iterate a3 over envp to find auxv (after NULL)      */
		"0:\n"                                /* do {                                                */
		REG_L        " $a4, $a3, 0\n"         /*   a4 = *a3;                                         */
		LONG_ADDI    " $a3, $a3, "SZREG"\n"   /*   a3 += sizeof(void*);                              */
		"bne           $a4, $zero, 0b\n"      /* } while (a4);                                       */
		"la.pcrel      $a4, _auxv\n"          /* a4 = &_auxv                                         */
		LONG_S       " $a3, $a4, 0\n"         /* store a3 into _auxv                                 */

		"la.pcrel      $a3, environ\n"        // a3 = &environ
		LONG_S       " $a2, $a3, 0\n"         // store envp(a2) into environ
		LONG_BSTRINS " $sp, $zero, 3, 0\n"    // sp must be 16-byte aligned
		"bl            main\n"                // main() returns the status code, we'll exit with it.
		"li.w          $a7, 93\n"             // NR_exit == 93
		"la.pcrel      $a3, environ\n"        /* a3 = &environ                                       */
		LONG_S       " $a2, $a3, 0\n"         /* store envp(a2) into environ                         */
		LONG_BSTRINS " $sp, $zero, 3, 0\n"    /* sp must be 16-byte aligned                          */
		"bl            main\n"                /* main() returns the status code, we'll exit with it. */
		"li.w          $a7, 93\n"             /* NR_exit == 93                                       */
		"syscall       0\n"
	);
	__builtin_unreachable();
}

#endif // _NOLIBC_ARCH_LOONGARCH_H
#endif /* _NOLIBC_ARCH_LOONGARCH_H */
+28 −28
Original line number Diff line number Diff line
@@ -183,42 +183,42 @@ const unsigned long *_auxv __attribute__((weak));
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) __start(void)
{
	__asm__ volatile (
		//".set nomips16\n"
		/*".set nomips16\n"*/
		".set push\n"
		".set    noreorder\n"
		".option pic0\n"
		//".ent __start\n"
		//"__start:\n"
		"lw $a0,($sp)\n"        // argc was in the stack
		"addiu  $a1, $sp, 4\n"  // argv = sp + 4
		"sll $a2, $a0, 2\n"     // a2 = argc * 4
		"add   $a2, $a2, $a1\n" // envp = argv + 4*argc ...
		"addiu $a2, $a2, 4\n"   //        ... + 4
		"lui $a3, %hi(environ)\n"     // load environ into a3 (hi)
		"addiu $a3, %lo(environ)\n"   // load environ into a3 (lo)
		"sw $a2,($a3)\n"              // store envp(a2) into environ

		"move $t0, $a2\n"             // iterate t0 over envp, look for NULL
		"0:"                          // do {
		"lw $a3, ($t0)\n"             //   a3=*(t0);
		"bne $a3, $0, 0b\n"           // } while (a3);
		"addiu $t0, $t0, 4\n"         // delayed slot: t0+=4;
		"lui $a3, %hi(_auxv)\n"       // load _auxv into a3 (hi)
		"addiu $a3, %lo(_auxv)\n"     // load _auxv into a3 (lo)
		"sw $t0, ($a3)\n"             // store t0 into _auxv
		/*".ent __start\n"*/
		/*"__start:\n"*/
		"lw $a0,($sp)\n"        /* argc was in the stack                               */
		"addiu  $a1, $sp, 4\n"  /* argv = sp + 4                                       */
		"sll $a2, $a0, 2\n"     /* a2 = argc * 4                                       */
		"add   $a2, $a2, $a1\n" /* envp = argv + 4*argc ...                            */
		"addiu $a2, $a2, 4\n"   /*        ... + 4                                      */
		"lui $a3, %hi(environ)\n"     /* load environ into a3 (hi)                     */
		"addiu $a3, %lo(environ)\n"   /* load environ into a3 (lo)                     */
		"sw $a2,($a3)\n"              /* store envp(a2) into environ                   */

		"move $t0, $a2\n"             /* iterate t0 over envp, look for NULL           */
		"0:"                          /* do {                                          */
		"lw $a3, ($t0)\n"             /*   a3=*(t0);                                   */
		"bne $a3, $0, 0b\n"           /* } while (a3);                                 */
		"addiu $t0, $t0, 4\n"         /* delayed slot: t0+=4;                          */
		"lui $a3, %hi(_auxv)\n"       /* load _auxv into a3 (hi)                       */
		"addiu $a3, %lo(_auxv)\n"     /* load _auxv into a3 (lo)                       */
		"sw $t0, ($a3)\n"             /* store t0 into _auxv                           */

		"li $t0, -8\n"
		"and $sp, $sp, $t0\n"   // sp must be 8-byte aligned
		"addiu $sp,$sp,-16\n"   // the callee expects to save a0..a3 there!
		"jal main\n"            // main() returns the status code, we'll exit with it.
		"nop\n"                 // delayed slot
		"move $a0, $v0\n"       // retrieve 32-bit exit code from v0
		"li $v0, 4001\n"        // NR_exit == 4001
		"and $sp, $sp, $t0\n"   /* sp must be 8-byte aligned                           */
		"addiu $sp,$sp,-16\n"   /* the callee expects to save a0..a3 there!            */
		"jal main\n"            /* main() returns the status code, we'll exit with it. */
		"nop\n"                 /* delayed slot                                        */
		"move $a0, $v0\n"       /* retrieve 32-bit exit code from v0                   */
		"li $v0, 4001\n"        /* NR_exit == 4001                                     */
		"syscall\n"
		//".end __start\n"
		/*".end __start\n"*/
		".set pop\n"
	);
	__builtin_unreachable();
}

#endif // _NOLIBC_ARCH_MIPS_H
#endif /* _NOLIBC_ARCH_MIPS_H */
Loading