Revision cb33da57 linux-user/elfload.c
b/linux-user/elfload.c | ||
---|---|---|
12 | 12 |
#include "qemu.h" |
13 | 13 |
#include "disas.h" |
14 | 14 |
|
15 |
/* from personality.h */ |
|
16 |
|
|
17 |
/* |
|
18 |
* Flags for bug emulation. |
|
19 |
* |
|
20 |
* These occupy the top three bytes. |
|
21 |
*/ |
|
22 |
enum { |
|
23 |
ADDR_NO_RANDOMIZE = 0x0040000, /* disable randomization of VA space */ |
|
24 |
FDPIC_FUNCPTRS = 0x0080000, /* userspace function ptrs point to descriptors |
|
25 |
* (signal handling) |
|
26 |
*/ |
|
27 |
MMAP_PAGE_ZERO = 0x0100000, |
|
28 |
ADDR_COMPAT_LAYOUT = 0x0200000, |
|
29 |
READ_IMPLIES_EXEC = 0x0400000, |
|
30 |
ADDR_LIMIT_32BIT = 0x0800000, |
|
31 |
SHORT_INODE = 0x1000000, |
|
32 |
WHOLE_SECONDS = 0x2000000, |
|
33 |
STICKY_TIMEOUTS = 0x4000000, |
|
34 |
ADDR_LIMIT_3GB = 0x8000000, |
|
35 |
}; |
|
36 |
|
|
37 |
/* |
|
38 |
* Personality types. |
|
39 |
* |
|
40 |
* These go in the low byte. Avoid using the top bit, it will |
|
41 |
* conflict with error returns. |
|
42 |
*/ |
|
43 |
enum { |
|
44 |
PER_LINUX = 0x0000, |
|
45 |
PER_LINUX_32BIT = 0x0000 | ADDR_LIMIT_32BIT, |
|
46 |
PER_LINUX_FDPIC = 0x0000 | FDPIC_FUNCPTRS, |
|
47 |
PER_SVR4 = 0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO, |
|
48 |
PER_SVR3 = 0x0002 | STICKY_TIMEOUTS | SHORT_INODE, |
|
49 |
PER_SCOSVR3 = 0x0003 | STICKY_TIMEOUTS | |
|
50 |
WHOLE_SECONDS | SHORT_INODE, |
|
51 |
PER_OSR5 = 0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS, |
|
52 |
PER_WYSEV386 = 0x0004 | STICKY_TIMEOUTS | SHORT_INODE, |
|
53 |
PER_ISCR4 = 0x0005 | STICKY_TIMEOUTS, |
|
54 |
PER_BSD = 0x0006, |
|
55 |
PER_SUNOS = 0x0006 | STICKY_TIMEOUTS, |
|
56 |
PER_XENIX = 0x0007 | STICKY_TIMEOUTS | SHORT_INODE, |
|
57 |
PER_LINUX32 = 0x0008, |
|
58 |
PER_LINUX32_3GB = 0x0008 | ADDR_LIMIT_3GB, |
|
59 |
PER_IRIX32 = 0x0009 | STICKY_TIMEOUTS,/* IRIX5 32-bit */ |
|
60 |
PER_IRIXN32 = 0x000a | STICKY_TIMEOUTS,/* IRIX6 new 32-bit */ |
|
61 |
PER_IRIX64 = 0x000b | STICKY_TIMEOUTS,/* IRIX6 64-bit */ |
|
62 |
PER_RISCOS = 0x000c, |
|
63 |
PER_SOLARIS = 0x000d | STICKY_TIMEOUTS, |
|
64 |
PER_UW7 = 0x000e | STICKY_TIMEOUTS | MMAP_PAGE_ZERO, |
|
65 |
PER_OSF4 = 0x000f, /* OSF/1 v4 */ |
|
66 |
PER_HPUX = 0x0010, |
|
67 |
PER_MASK = 0x00ff, |
|
68 |
}; |
|
69 |
|
|
70 |
/* |
|
71 |
* Return the base personality without flags. |
|
72 |
*/ |
|
73 |
#define personality(pers) (pers & PER_MASK) |
|
74 |
|
|
15 | 75 |
/* this flag is uneffective under linux too, should be deleted */ |
16 | 76 |
#ifndef MAP_DENYWRITE |
17 | 77 |
#define MAP_DENYWRITE 0 |
... | ... | |
154 | 214 |
|
155 | 215 |
#define ELF_START_MMAP 0x80000000 |
156 | 216 |
|
157 |
#define elf_check_arch(x) ( (x) == EM_SPARCV9 ) |
|
217 |
#define elf_check_arch(x) ( (x) == EM_SPARCV9 || (x) == EM_SPARC32PLUS )
|
|
158 | 218 |
|
159 | 219 |
#define ELF_CLASS ELFCLASS64 |
160 | 220 |
#define ELF_DATA ELFDATA2MSB |
... | ... | |
168 | 228 |
regs->pc = infop->entry; |
169 | 229 |
regs->npc = regs->pc + 4; |
170 | 230 |
regs->y = 0; |
171 |
regs->u_regs[14] = infop->start_stack - 16 * 8 - STACK_BIAS; |
|
231 |
if (personality(infop->personality) == PER_LINUX32) |
|
232 |
regs->u_regs[14] = infop->start_stack - 16 * 4; |
|
233 |
else |
|
234 |
regs->u_regs[14] = infop->start_stack - 16 * 8 - STACK_BIAS; |
|
172 | 235 |
} |
173 | 236 |
|
174 | 237 |
#else |
... | ... | |
412 | 475 |
#define ELF_HWCAP 0 |
413 | 476 |
#endif |
414 | 477 |
|
478 |
#ifdef OVERRIDE_ELF_CLASS |
|
479 |
#undef ELF_CLASS |
|
480 |
#define ELF_CLASS OVERRIDE_ELF_CLASS |
|
481 |
#undef bswaptls |
|
482 |
#define bswaptls(ptr) bswap32s(ptr) |
|
483 |
#endif |
|
484 |
|
|
415 | 485 |
#include "elf.h" |
416 | 486 |
|
417 | 487 |
struct exec |
... | ... | |
439 | 509 |
/* max code+data+bss+brk space allocated to ET_DYN executables */ |
440 | 510 |
#define ET_DYN_MAP_SIZE (128 * 1024 * 1024) |
441 | 511 |
|
442 |
/* from personality.h */ |
|
443 |
|
|
444 |
/* Flags for bug emulation. These occupy the top three bytes. */ |
|
445 |
#define STICKY_TIMEOUTS 0x4000000 |
|
446 |
#define WHOLE_SECONDS 0x2000000 |
|
447 |
|
|
448 |
/* Personality types. These go in the low byte. Avoid using the top bit, |
|
449 |
* it will conflict with error returns. |
|
450 |
*/ |
|
451 |
#define PER_MASK (0x00ff) |
|
452 |
#define PER_LINUX (0x0000) |
|
453 |
#define PER_SVR4 (0x0001 | STICKY_TIMEOUTS) |
|
454 |
#define PER_SVR3 (0x0002 | STICKY_TIMEOUTS) |
|
455 |
#define PER_SCOSVR3 (0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS) |
|
456 |
#define PER_WYSEV386 (0x0004 | STICKY_TIMEOUTS) |
|
457 |
#define PER_ISCR4 (0x0005 | STICKY_TIMEOUTS) |
|
458 |
#define PER_BSD (0x0006) |
|
459 |
#define PER_XENIX (0x0007 | STICKY_TIMEOUTS) |
|
460 |
|
|
461 | 512 |
/* Necessary parameters */ |
462 | 513 |
#define TARGET_ELF_EXEC_PAGESIZE TARGET_PAGE_SIZE |
463 | 514 |
#define TARGET_ELF_PAGESTART(_v) ((_v) & ~(unsigned long)(TARGET_ELF_EXEC_PAGESIZE-1)) |
... | ... | |
587 | 638 |
return p; |
588 | 639 |
} |
589 | 640 |
|
590 |
target_ulong setup_arg_pages(target_ulong p, struct linux_binprm * bprm,
|
|
591 |
struct image_info * info)
|
|
641 |
static target_ulong setup_arg_pages(target_ulong p, struct linux_binprm *bprm,
|
|
642 |
struct image_info *info)
|
|
592 | 643 |
{ |
593 | 644 |
target_ulong stack_base, size, error; |
594 | 645 |
int i; |
Also available in: Unified diff