jseward | 2886b0e | 2004-01-04 03:46:11 +0000 | [diff] [blame] | 1 | |
nethercote | bb1c991 | 2004-01-04 16:43:23 +0000 | [diff] [blame] | 2 | /*--------------------------------------------------------------------*/ |
nethercote | 71980f0 | 2004-01-24 18:18:54 +0000 | [diff] [blame] | 3 | /*--- Startup: preliminaries stage1.c ---*/ |
nethercote | bb1c991 | 2004-01-04 16:43:23 +0000 | [diff] [blame] | 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
jseward | 2886b0e | 2004-01-04 03:46:11 +0000 | [diff] [blame] | 6 | /* |
njn | b9c427c | 2004-12-01 14:14:42 +0000 | [diff] [blame] | 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
jseward | 2886b0e | 2004-01-04 03:46:11 +0000 | [diff] [blame] | 9 | |
njn | 5361242 | 2005-03-12 16:22:54 +0000 | [diff] [blame] | 10 | Copyright (C) 2000-2005 Julian Seward |
jseward | 2886b0e | 2004-01-04 03:46:11 +0000 | [diff] [blame] | 11 | jseward@acm.org |
| 12 | |
| 13 | This program is free software; you can redistribute it and/or |
| 14 | modify it under the terms of the GNU General Public License as |
| 15 | published by the Free Software Foundation; either version 2 of the |
| 16 | License, or (at your option) any later version. |
| 17 | |
| 18 | This program is distributed in the hope that it will be useful, but |
| 19 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | General Public License for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License |
| 24 | along with this program; if not, write to the Free Software |
| 25 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 26 | 02111-1307, USA. |
| 27 | |
| 28 | The GNU General Public License is contained in the file COPYING. |
| 29 | */ |
| 30 | |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 31 | #define _FILE_OFFSET_BITS 64 |
| 32 | |
nethercote | 969ecf1 | 2004-10-13 17:29:01 +0000 | [diff] [blame] | 33 | #include <errno.h> |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 34 | #include <stdio.h> |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 35 | #include <string.h> |
| 36 | #include <stdlib.h> |
| 37 | #include <assert.h> |
| 38 | #include <signal.h> |
| 39 | #include <fcntl.h> |
nethercote | 969ecf1 | 2004-10-13 17:29:01 +0000 | [diff] [blame] | 40 | #include <sys/mman.h> |
fitzhardinge | 716c2c1 | 2004-03-09 00:57:45 +0000 | [diff] [blame] | 41 | #include <sys/resource.h> |
nethercote | 969ecf1 | 2004-10-13 17:29:01 +0000 | [diff] [blame] | 42 | #include <unistd.h> |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 43 | |
nethercote | f1e5e15 | 2004-09-01 23:58:16 +0000 | [diff] [blame] | 44 | #include "core.h" |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 45 | #include "ume.h" |
sewardj | b5f6f51 | 2005-03-10 23:59:00 +0000 | [diff] [blame] | 46 | #include "memcheck/memcheck.h" |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 47 | |
| 48 | static int stack[SIGSTKSZ*4]; |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 49 | |
nethercote | c25c449 | 2004-10-18 11:52:17 +0000 | [diff] [blame] | 50 | // Initial stack pointer, which points to argc. |
| 51 | static void* init_sp; |
| 52 | |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 53 | /* Where we expect to find all our aux files (namely, stage2) */ |
| 54 | static const char *valgrind_lib = VG_LIBDIR; |
| 55 | |
| 56 | /* stage2's name */ |
| 57 | static const char stage2[] = "stage2"; |
| 58 | |
nethercote | 969ecf1 | 2004-10-13 17:29:01 +0000 | [diff] [blame] | 59 | /*------------------------------------------------------------*/ |
| 60 | /*--- Auxv modification ---*/ |
| 61 | /*------------------------------------------------------------*/ |
| 62 | |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 63 | /* Modify the auxv the kernel gave us to make it look like we were |
| 64 | execed as the shared object. |
| 65 | |
| 66 | This also inserts a new entry into the auxv table so we can |
| 67 | communicate some extra information to stage2 (namely, the fd of the |
| 68 | padding file, so it can identiry and remove the padding later). |
| 69 | */ |
nethercote | 31779c7 | 2004-07-30 21:50:15 +0000 | [diff] [blame] | 70 | static void *fix_auxv(void *v_init_esp, const struct exeinfo *info, |
| 71 | int padfile) |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 72 | { |
| 73 | struct ume_auxv *auxv; |
| 74 | int *newesp; |
| 75 | int seen; |
| 76 | int delta; |
| 77 | int i; |
| 78 | static const int new_entries = 2; |
| 79 | |
| 80 | /* make sure we're running on the private stack */ |
| 81 | assert(&delta >= stack && &delta < &stack[sizeof(stack)/sizeof(*stack)]); |
| 82 | |
| 83 | /* find the beginning of the AUXV table */ |
| 84 | auxv = find_auxv(v_init_esp); |
| 85 | |
| 86 | /* Work out how we should move things to make space for the new |
| 87 | auxv entry. It seems that ld.so wants a 16-byte aligned stack on |
| 88 | entry, so make sure that's the case. */ |
| 89 | newesp = (int *)(((unsigned long)v_init_esp - new_entries * sizeof(*auxv)) & ~0xf); |
| 90 | delta = (char *)v_init_esp - (char *)newesp; |
| 91 | |
| 92 | memmove(newesp, v_init_esp, (char *)auxv - (char *)v_init_esp); |
| 93 | |
| 94 | v_init_esp = (void *)newesp; |
| 95 | auxv -= delta/sizeof(*auxv); |
| 96 | |
| 97 | /* stage2 needs this so it can clean up the padding we leave in |
| 98 | place when we start it */ |
| 99 | auxv[0].a_type = AT_UME_PADFD; |
nethercote | 31779c7 | 2004-07-30 21:50:15 +0000 | [diff] [blame] | 100 | auxv[0].u.a_val = padfile; |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 101 | |
| 102 | /* This will be needed by valgrind itself so that it can |
| 103 | subsequently execve() children. This needs to be done here |
| 104 | because /proc/self/exe will go away once we unmap stage1. */ |
| 105 | auxv[1].a_type = AT_UME_EXECFD; |
mueller | 5ed88f2 | 2004-01-06 16:02:29 +0000 | [diff] [blame] | 106 | auxv[1].u.a_val = open("/proc/self/exe", O_RDONLY); |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 107 | |
| 108 | /* make sure the rest are sane */ |
| 109 | for(i = new_entries; i < delta/sizeof(*auxv); i++) { |
| 110 | auxv[i].a_type = AT_IGNORE; |
mueller | 5ed88f2 | 2004-01-06 16:02:29 +0000 | [diff] [blame] | 111 | auxv[i].u.a_val = 0; |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | /* OK, go through and patch up the auxv entries to match the new |
| 115 | executable */ |
| 116 | seen = 0; |
| 117 | for(; auxv->a_type != AT_NULL; auxv++) { |
| 118 | if (0) |
sewardj | b5f6f51 | 2005-03-10 23:59:00 +0000 | [diff] [blame] | 119 | printf("doing auxv %p %5lld: %lld %p\n", |
| 120 | auxv, (Long)auxv->a_type, (Long)auxv->u.a_val, auxv->u.a_ptr); |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 121 | |
| 122 | switch(auxv->a_type) { |
| 123 | case AT_PHDR: |
| 124 | seen |= 1; |
mueller | 5ed88f2 | 2004-01-06 16:02:29 +0000 | [diff] [blame] | 125 | auxv->u.a_val = info->phdr; |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 126 | break; |
| 127 | |
| 128 | case AT_PHNUM: |
| 129 | seen |= 2; |
mueller | 5ed88f2 | 2004-01-06 16:02:29 +0000 | [diff] [blame] | 130 | auxv->u.a_val = info->phnum; |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 131 | break; |
| 132 | |
| 133 | case AT_BASE: |
| 134 | seen |= 4; |
mueller | 5ed88f2 | 2004-01-06 16:02:29 +0000 | [diff] [blame] | 135 | auxv->u.a_val = info->interp_base; |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 136 | break; |
| 137 | |
| 138 | case AT_ENTRY: |
| 139 | seen |= 8; |
mueller | 5ed88f2 | 2004-01-06 16:02:29 +0000 | [diff] [blame] | 140 | auxv->u.a_val = info->entry; |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 141 | break; |
fitzhardinge | a1d37c0 | 2004-06-14 02:36:09 +0000 | [diff] [blame] | 142 | |
nethercote | eda6b28 | 2004-06-15 08:34:10 +0000 | [diff] [blame] | 143 | #if (defined(AT_SYSINFO) || defined(AT_SYSINFO_EHDR)) |
| 144 | #ifdef AT_SYSINFO |
fitzhardinge | a1d37c0 | 2004-06-14 02:36:09 +0000 | [diff] [blame] | 145 | case AT_SYSINFO: |
nethercote | eda6b28 | 2004-06-15 08:34:10 +0000 | [diff] [blame] | 146 | #endif |
nethercote | 079acf6 | 2004-06-14 11:56:59 +0000 | [diff] [blame] | 147 | #ifdef AT_SYSINFO_EHDR |
fitzhardinge | a1d37c0 | 2004-06-14 02:36:09 +0000 | [diff] [blame] | 148 | case AT_SYSINFO_EHDR: |
nethercote | 079acf6 | 2004-06-14 11:56:59 +0000 | [diff] [blame] | 149 | #endif |
fitzhardinge | a1d37c0 | 2004-06-14 02:36:09 +0000 | [diff] [blame] | 150 | auxv->a_type = AT_IGNORE; |
| 151 | break; |
nethercote | eda6b28 | 2004-06-15 08:34:10 +0000 | [diff] [blame] | 152 | #endif |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 153 | } |
| 154 | } |
| 155 | |
| 156 | /* If we didn't see all the entries we need to fix up, then we |
| 157 | can't make the new executable viable. */ |
| 158 | if (seen != 0xf) { |
nethercote | 2e1cb4c | 2004-08-05 12:16:13 +0000 | [diff] [blame] | 159 | fprintf(stderr, "valgrind: we didn't see enough auxv entries (seen=%x)\n", seen); |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 160 | exit(1); |
| 161 | } |
| 162 | |
| 163 | return v_init_esp; |
| 164 | } |
| 165 | |
nethercote | 969ecf1 | 2004-10-13 17:29:01 +0000 | [diff] [blame] | 166 | |
| 167 | /*------------------------------------------------------------*/ |
| 168 | /*--- Address space padding ---*/ |
| 169 | /*------------------------------------------------------------*/ |
| 170 | |
| 171 | static void check_mmap(void* res, void* base, int len) |
| 172 | { |
| 173 | if ((void*)-1 == res) { |
| 174 | fprintf(stderr, "valgrind: padding mmap(%p, %d) failed during startup.\n" |
| 175 | "valgrind: is there a hard virtual memory limit set?\n", |
| 176 | base, len); |
| 177 | exit(1); |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | typedef struct { |
| 182 | char* fillgap_start; |
| 183 | char* fillgap_end; |
| 184 | int fillgap_padfile; |
| 185 | } fillgap_extra; |
| 186 | |
| 187 | static int fillgap(char *segstart, char *segend, const char *perm, off_t off, |
| 188 | int maj, int min, int ino, void* e) |
| 189 | { |
| 190 | fillgap_extra* extra = e; |
| 191 | |
| 192 | if (segstart >= extra->fillgap_end) |
| 193 | return 0; |
| 194 | |
| 195 | if (segstart > extra->fillgap_start) { |
| 196 | void* res = mmap(extra->fillgap_start, segstart - extra->fillgap_start, |
| 197 | PROT_NONE, MAP_FIXED|MAP_PRIVATE, |
| 198 | extra->fillgap_padfile, 0); |
| 199 | check_mmap(res, extra->fillgap_start, segstart - extra->fillgap_start); |
| 200 | } |
| 201 | extra->fillgap_start = segend; |
| 202 | |
| 203 | return 1; |
| 204 | } |
| 205 | |
| 206 | // Choose a name for the padfile, open it. |
sewardj | 2c5ffbe | 2005-03-12 13:32:06 +0000 | [diff] [blame] | 207 | static |
nethercote | 969ecf1 | 2004-10-13 17:29:01 +0000 | [diff] [blame] | 208 | int as_openpadfile(void) |
| 209 | { |
| 210 | char buf[256]; |
| 211 | int padfile; |
| 212 | int seq = 1; |
| 213 | do { |
| 214 | snprintf(buf, 256, "/tmp/.pad.%d.%d", getpid(), seq++); |
| 215 | padfile = open(buf, O_RDWR|O_CREAT|O_EXCL, 0); |
| 216 | unlink(buf); |
| 217 | if (padfile == -1 && errno != EEXIST) { |
| 218 | fprintf(stderr, "valgrind: couldn't open padfile\n"); |
| 219 | exit(44); |
| 220 | } |
| 221 | } while(padfile == -1); |
| 222 | |
| 223 | return padfile; |
| 224 | } |
| 225 | |
| 226 | // Pad all the empty spaces in a range of address space to stop interlopers. |
sewardj | 2c5ffbe | 2005-03-12 13:32:06 +0000 | [diff] [blame] | 227 | static |
nethercote | 969ecf1 | 2004-10-13 17:29:01 +0000 | [diff] [blame] | 228 | void as_pad(void *start, void *end, int padfile) |
| 229 | { |
| 230 | fillgap_extra extra; |
| 231 | extra.fillgap_start = start; |
| 232 | extra.fillgap_end = end; |
| 233 | extra.fillgap_padfile = padfile; |
| 234 | |
| 235 | foreach_map(fillgap, &extra); |
| 236 | |
| 237 | if (extra.fillgap_start < extra.fillgap_end) { |
| 238 | void* res = mmap(extra.fillgap_start, |
| 239 | extra.fillgap_end - extra.fillgap_start, |
| 240 | PROT_NONE, MAP_FIXED|MAP_PRIVATE, padfile, 0); |
| 241 | check_mmap(res, extra.fillgap_start, |
| 242 | extra.fillgap_end - extra.fillgap_start); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | |
| 247 | /*------------------------------------------------------------*/ |
| 248 | /*--- main() and related pieces ---*/ |
| 249 | /*------------------------------------------------------------*/ |
| 250 | |
nethercote | 31779c7 | 2004-07-30 21:50:15 +0000 | [diff] [blame] | 251 | static int prmap(char *start, char *end, const char *perm, off_t off, int maj, |
| 252 | int min, int ino, void* dummy) { |
thughes | 4ad52d0 | 2004-06-27 17:37:21 +0000 | [diff] [blame] | 253 | printf("mapping %10p-%10p %s %02x:%02x %d\n", |
| 254 | start, end, perm, maj, min, ino); |
| 255 | return 1; |
| 256 | } |
| 257 | |
sewardj | 7f082a6 | 2005-03-22 01:55:35 +0000 | [diff] [blame^] | 258 | |
nethercote | 9d07242 | 2004-10-13 17:58:36 +0000 | [diff] [blame] | 259 | static void main2(void) |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 260 | { |
nethercote | 31779c7 | 2004-07-30 21:50:15 +0000 | [diff] [blame] | 261 | int err, padfile; |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 262 | struct exeinfo info; |
| 263 | extern char _end; |
| 264 | int *esp; |
| 265 | char buf[strlen(valgrind_lib) + sizeof(stage2) + 16]; |
sewardj | 7f082a6 | 2005-03-22 01:55:35 +0000 | [diff] [blame^] | 266 | printf("& local = %p\n", &esp); |
nethercote | 5462ef7 | 2004-10-26 17:03:54 +0000 | [diff] [blame] | 267 | info.exe_end = PGROUNDDN(init_sp); |
nethercote | 7f39002 | 2004-10-25 17:18:24 +0000 | [diff] [blame] | 268 | #ifdef HAVE_PIE |
| 269 | info.exe_base = ROUNDDN(info.exe_end - 0x02000000, 0x10000000); |
| 270 | assert(info.exe_base >= PGROUNDUP(&_end)); |
| 271 | info.map_base = info.exe_base + 0x01000000; |
| 272 | #else |
nethercote | 7f39002 | 2004-10-25 17:18:24 +0000 | [diff] [blame] | 273 | // If this system doesn't have PIE (position-independent executables), |
| 274 | // we have to choose a hardwired location for stage2. |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 275 | info.exe_base = PGROUNDUP(&_end); |
nethercote | 7f39002 | 2004-10-25 17:18:24 +0000 | [diff] [blame] | 276 | info.map_base = KICKSTART_BASE + 0x01000000; |
| 277 | #endif |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 278 | |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 279 | info.argv = NULL; |
| 280 | |
fitzhardinge | a49f9b5 | 2003-12-16 22:26:45 +0000 | [diff] [blame] | 281 | snprintf(buf, sizeof(buf), "%s/%s", valgrind_lib, stage2); |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 282 | |
| 283 | err = do_exec(buf, &info); |
| 284 | |
| 285 | if (err != 0) { |
nethercote | 2e1cb4c | 2004-08-05 12:16:13 +0000 | [diff] [blame] | 286 | fprintf(stderr, "valgrind: failed to load %s: %s\n", |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 287 | buf, strerror(err)); |
| 288 | exit(1); |
| 289 | } |
| 290 | |
| 291 | /* Make sure stage2's dynamic linker can't tromp on the lower part |
| 292 | of the address space. */ |
nethercote | 31779c7 | 2004-07-30 21:50:15 +0000 | [diff] [blame] | 293 | padfile = as_openpadfile(); |
| 294 | as_pad(0, (void *)info.map_base, padfile); |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 295 | |
nethercote | c25c449 | 2004-10-18 11:52:17 +0000 | [diff] [blame] | 296 | esp = fix_auxv(init_sp, &info, padfile); |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 297 | |
| 298 | if (0) { |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 299 | printf("---------- launch stage 2 ----------\n"); |
| 300 | printf("eip=%p esp=%p\n", (void *)info.init_eip, esp); |
nethercote | 31779c7 | 2004-07-30 21:50:15 +0000 | [diff] [blame] | 301 | foreach_map(prmap, /*dummy*/NULL); |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 302 | } |
| 303 | |
sewardj | 7f082a6 | 2005-03-22 01:55:35 +0000 | [diff] [blame^] | 304 | jump_and_switch_stacks( |
| 305 | (Addr) esp, /* stack */ |
| 306 | (Addr) info.init_eip /* where to */ |
| 307 | ); |
| 308 | |
| 309 | /*NOTREACHED*/ |
| 310 | assert(0); |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 311 | } |
| 312 | |
sewardj | 7f082a6 | 2005-03-22 01:55:35 +0000 | [diff] [blame^] | 313 | |
nethercote | c25c449 | 2004-10-18 11:52:17 +0000 | [diff] [blame] | 314 | int main(int argc, char** argv) |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 315 | { |
fitzhardinge | 716c2c1 | 2004-03-09 00:57:45 +0000 | [diff] [blame] | 316 | struct rlimit rlim; |
sewardj | b5f6f51 | 2005-03-10 23:59:00 +0000 | [diff] [blame] | 317 | const char *cp; |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 318 | |
nethercote | c25c449 | 2004-10-18 11:52:17 +0000 | [diff] [blame] | 319 | // Initial stack pointer is to argc, which is immediately before argv[0] |
nethercote | 41c75da | 2004-10-18 15:34:14 +0000 | [diff] [blame] | 320 | // on the stack. Nb: Assumes argc is word-aligned. |
nethercote | c25c449 | 2004-10-18 11:52:17 +0000 | [diff] [blame] | 321 | init_sp = argv - 1; |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 322 | |
sewardj | b5f6f51 | 2005-03-10 23:59:00 +0000 | [diff] [blame] | 323 | /* The Linux libc startup sequence leaves this in an apparently |
| 324 | undefined state, but it really is defined, so mark it so. */ |
| 325 | VALGRIND_MAKE_READABLE(init_sp, sizeof(int)); |
| 326 | |
| 327 | cp = getenv(VALGRINDLIB); |
| 328 | |
| 329 | if (cp != NULL) |
| 330 | valgrind_lib = cp; |
| 331 | |
fitzhardinge | 716c2c1 | 2004-03-09 00:57:45 +0000 | [diff] [blame] | 332 | /* Set the address space limit as high as it will go, since we make |
| 333 | a lot of very large mappings. */ |
| 334 | getrlimit(RLIMIT_AS, &rlim); |
| 335 | rlim.rlim_cur = rlim.rlim_max; |
| 336 | setrlimit(RLIMIT_AS, &rlim); |
| 337 | |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 338 | /* move onto another stack so we can play with the main one */ |
sewardj | 7f082a6 | 2005-03-22 01:55:35 +0000 | [diff] [blame^] | 339 | jump_and_switch_stacks( |
| 340 | (Addr)stack + sizeof(stack), /* stack */ |
| 341 | main2 /* where to */ |
| 342 | ); |
| 343 | |
| 344 | /*NOTREACHED*/ |
| 345 | assert(0); |
fitzhardinge | 7e343cd | 2003-12-16 02:14:00 +0000 | [diff] [blame] | 346 | } |
nethercote | bb1c991 | 2004-01-04 16:43:23 +0000 | [diff] [blame] | 347 | |
| 348 | /*--------------------------------------------------------------------*/ |
| 349 | /*--- end stage1.c ---*/ |
| 350 | /*--------------------------------------------------------------------*/ |