2 * check_initial_reg_state.c - check that execve sets the correct state
3 * Copyright (c) 2014-2016 Andrew Lutomirski
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
19 unsigned long ax, bx, cx, dx, si, di, bp, sp, flags;
20 unsigned long r8, r9, r10, r11, r12, r13, r14, r15;
23 ".pushsection .text\n\t"
24 ".type real_start, @function\n\t"
25 ".global real_start\n\t"
59 ".size real_start, . - real_start\n\t"
67 printf("[FAIL]\tTest was built incorrectly\n");
71 if (ax || bx || cx || dx || si || di || bp
73 || r8 || r9 || r10 || r11 || r12 || r13 || r14 || r15
76 printf("[FAIL]\tAll GPRs except SP should be 0\n");
77 #define SHOW(x) printf("\t" #x " = 0x%lx\n", x);
98 printf("[OK]\tAll GPRs except SP are 0\n");
101 if (flags != 0x202) {
102 printf("[FAIL]\tFLAGS is 0x%lx, but it should be 0x202\n", flags);
105 printf("[OK]\tFLAGS is 0x202\n");
108 return nerrs ? 1 : 0;