提交 b17780d5 编写于 作者: B bellard

endianness fixes


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7 c046a42c-6fe2-441c-8c8c-71466251a162
上级 34313956
...@@ -335,9 +335,8 @@ static unsigned int * create_elf_tables(char *p, int argc, int envc, ...@@ -335,9 +335,8 @@ static unsigned int * create_elf_tables(char *p, int argc, int envc,
unsigned long interp_load_addr, int ibcs, unsigned long interp_load_addr, int ibcs,
struct image_info *info) struct image_info *info)
{ {
unsigned int *argv, *envp, *dlinfo; target_ulong *argv, *envp, *dlinfo;
unsigned int *sp; target_ulong *sp;
char **alpha_envp;
/* /*
* Force 16 byte alignment here for generality. * Force 16 byte alignment here for generality.
...@@ -350,14 +349,13 @@ static unsigned int * create_elf_tables(char *p, int argc, int envc, ...@@ -350,14 +349,13 @@ static unsigned int * create_elf_tables(char *p, int argc, int envc,
sp -= argc+1; sp -= argc+1;
argv = sp; argv = sp;
if (!ibcs) { if (!ibcs) {
put_user(envp,--sp); put_user(tswapl((target_ulong)envp),--sp);
put_user(argv,--sp); put_user(tswapl((target_ulong)argv),--sp);
} }
alpha_envp = (char **)malloc((envc+1) * sizeof(char *));
#define NEW_AUX_ENT(id, val) \ #define NEW_AUX_ENT(id, val) \
put_user ((id), dlinfo++); \ put_user (tswapl(id), dlinfo++); \
put_user ((val), dlinfo++) put_user (tswapl(val), dlinfo++)
if (exec) { /* Put this here for an ELF program interpreter */ if (exec) { /* Put this here for an ELF program interpreter */
struct elf_phdr * eppnt; struct elf_phdr * eppnt;
...@@ -377,22 +375,19 @@ static unsigned int * create_elf_tables(char *p, int argc, int envc, ...@@ -377,22 +375,19 @@ static unsigned int * create_elf_tables(char *p, int argc, int envc,
} }
NEW_AUX_ENT (AT_NULL, 0); NEW_AUX_ENT (AT_NULL, 0);
#undef NEW_AUX_ENT #undef NEW_AUX_ENT
put_user((unsigned int)argc,--sp); put_user(tswapl(argc),--sp);
info->arg_start = (unsigned int)((unsigned long)p & 0xffffffff); info->arg_start = (unsigned int)((unsigned long)p & 0xffffffff);
while (argc-->0) { while (argc-->0) {
put_user(p,argv++); put_user(tswapl((target_ulong)p),argv++);
while (get_user(p++)) /* nothing */ ; while (get_user(p++)) /* nothing */ ;
} }
put_user(0,argv); put_user(0,argv);
info->arg_end = info->env_start = (unsigned int)((unsigned long)p & 0xffffffff); info->arg_end = info->env_start = (unsigned int)((unsigned long)p & 0xffffffff);
__environ = alpha_envp;
while (envc-->0) { while (envc-->0) {
*alpha_envp++ = (char *)p; put_user(tswapl((target_ulong)p),envp++);
put_user(p,envp++);
while (get_user(p++)) /* nothing */ ; while (get_user(p++)) /* nothing */ ;
} }
put_user(0,envp); put_user(0,envp);
*alpha_envp = 0;
info->env_end = (unsigned int)((unsigned long)p & 0xffffffff); info->env_end = (unsigned int)((unsigned long)p & 0xffffffff);
return sp; return sp;
} }
...@@ -544,8 +539,8 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex, ...@@ -544,8 +539,8 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex,
static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs, static int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
struct image_info * info) struct image_info * info)
{ {
struct elfhdr elf_ex; struct elfhdr elf_ex;
struct elfhdr interp_elf_ex; struct elfhdr interp_elf_ex;
...@@ -581,7 +576,6 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs, ...@@ -581,7 +576,6 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs,
return -ENOEXEC; return -ENOEXEC;
} }
/* First of all, some simple consistency checks */ /* First of all, some simple consistency checks */
if ((elf_ex.e_type != ET_EXEC && elf_ex.e_type != ET_DYN) || if ((elf_ex.e_type != ET_EXEC && elf_ex.e_type != ET_DYN) ||
(! elf_check_arch(elf_ex.e_machine))) { (! elf_check_arch(elf_ex.e_machine))) {
...@@ -608,6 +602,12 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs, ...@@ -608,6 +602,12 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs,
return -errno; return -errno;
} }
#ifdef BSWAP_NEEDED
elf_ppnt = elf_phdata;
for (i=0; i<elf_ex.e_phnum; i++, elf_ppnt++) {
bswap_phdr(elf_ppnt);
}
#endif
elf_ppnt = elf_phdata; elf_ppnt = elf_phdata;
elf_bss = 0; elf_bss = 0;
...@@ -909,7 +909,7 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs, ...@@ -909,7 +909,7 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs,
int elf_exec(const char * filename, char ** argv, char ** envp, int elf_exec(const char * filename, char ** argv, char ** envp,
struct pt_regs * regs, struct image_info *infop) struct target_pt_regs * regs, struct image_info *infop)
{ {
struct linux_binprm bprm; struct linux_binprm bprm;
int retval; int retval;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册