OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 706 to Rev 707
    Reverse comparison

Rev 706 → Rev 707

/trunk/uclinux/uClinux-2.0.x/fs/binfmt_elf.c
37,7 → 37,8
 
#include <linux/elf.h>
 
#define STACK_SIZE (1*PAGE_SIZE)
#define JUMP_TO_MAIN 0
#define STACK_SIZE (2*PAGE_SIZE)
 
static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs);
 
62,6 → 63,7
unsigned short *or32_consth_add = (unsigned short *)NULL;
unsigned long or32_consth_rel;
 
#if JUMP_TO_MAIN
unsigned long *create_elf_tables(char *p, int argc, int envc, struct pt_regs *regs)
{
unsigned long *argv, *envp;
98,7 → 100,43
current->mm->env_end = (unsigned long) p;
return sp;
}
#else
unsigned long *create_elf_tables(char *p, int argc, int envc, struct pt_regs *regs)
{
unsigned long *argv, *envp;
unsigned long *sp;
 
/*
* Force 16 byte alignment here for generality.
*/
sp = (unsigned long *) (~15UL & (unsigned long) p);
sp -= 2;
sp -= envc + 1;
envp = sp;
sp -= argc + 1;
argv = sp;
 
regs->gprs[1] = sp;
put_user((unsigned long) argc, --sp);
current->mm->arg_start = (unsigned long) p;
while (argc-- > 0) {
put_user(p, argv++);
while (get_user(p++)) /* nothing */
;
}
put_user(0, argv);
current->mm->arg_end = current->mm->env_start = (unsigned long) p;
while (envc-- > 0) {
put_user(p, envp++);
while (get_user(p++)) /* nothing */
;
}
put_user(0, envp);
current->mm->env_end = (unsigned long) p;
return sp;
}
#endif
 
static unsigned long putstring(unsigned long p, char * string)
{
unsigned long l = strlen(string)+1;
139,7 → 177,7
int i;
for(i = 0; i < rel_nb; i++, rel_ptr++) {
 
/* Symbol tab */
sym_tab = sym_ptr + (rel_ptr->r_info >> 8);
/* Section index of section that contains symbol */
147,7 → 185,6
/* Location in physical memory to which this relocation
is refering to */
rel_loc = (void *)(rel_ptr->r_offset + sec[dst_indx].pm_add);
 
if((rel_ptr->r_info & 0x000000ff) == R_OR32_32) {
*(unsigned long *)rel_loc = *(unsigned long *)rel_loc
- sec[src_indx].vm_add
169,7 → 206,7
}
else if((rel_ptr->r_info & 0x000000ff) == R_OR32_CONST) {
tmp = or32_consth_rel | *(((unsigned short *)rel_loc) + 1);
tmp = tmp/* + sym_tab->st_value*/ - sec[src_indx].vm_add +
tmp = tmp /*+ sym_tab->st_value */ - sec[src_indx].vm_add +
sec[src_indx].pm_add;
*(((unsigned short *)rel_loc) + 1) = tmp & 0x0000ffff;
if(or32_consth_add != (unsigned short *)NULL) {
196,6 → 233,7
return 0;
}
 
#if JUMP_TO_MAIN
unsigned long do_find_main(int sym_nb, struct elf32_sym *sym_prt, char *str_ptr)
{
int i;
209,6 → 247,21
}
return 0;
}
#else
unsigned long do_find_start(int sym_nb, struct elf32_sym *sym_prt, char *str_ptr)
{
int i;
 
for(i = 0; i < sym_nb; i++, sym_prt++) {
if(sym_prt->st_name == 0)
continue;
 
if(strcmp(&str_ptr[sym_prt->st_name], "_start") == 0)
return (sym_prt->st_value + sec[sym_prt->st_shndx].pm_add);
}
return 0;
}
#endif
/*
* These are the functions used to load ELF style executables and shared
* libraries. There is no binary dependent code anywhere else.
315,6 → 368,12
}
}
 
/* Make room on stack for arguments & environment */
stack_len = STACK_SIZE;
stack_len += strlen(bprm->filename) + 1;
stack_len += stringarraylen(bprm->envc, bprm->envp);
stack_len += stringarraylen(bprm->argc, bprm->argv);
 
/* Allocate space */
retval = (unsigned long)do_mmap(NULL,
0,
334,13 → 393,7
data_end = data_start;
bss_start = data_start + data_len;
bss_end = bss_start;
stack_len = STACK_SIZE;
 
/* Make room on stack for arguments & environment */
stack_len += strlen(bprm->filename) + 1;
stack_len += stringarraylen(bprm->envc, bprm->envp);
stack_len += stringarraylen(bprm->argc, bprm->argv);
current->mm->executable = 0;
 
/* Now copy sections in memory */
349,6 → 402,9
 
if(elf_spnt->sh_type == SHT_PROGBITS && elf_spnt->sh_flags & SHF_EXECINSTR) {
 
if(elf_spnt->sh_size == 0)
continue;
 
retval = read_exec(bprm->inode, elf_spnt->sh_offset,
(char *)code_end, elf_spnt->sh_size, 1);
 
365,6 → 421,9
}
else if (elf_spnt->sh_type == SHT_PROGBITS && elf_spnt->sh_flags & SHF_ALLOC) {
 
if(elf_spnt->sh_size == 0)
continue;
 
retval = read_exec(bprm->inode, elf_spnt->sh_offset,
(char *)data_end, elf_spnt->sh_size, 1);
 
381,6 → 440,9
}
else if (elf_spnt->sh_type == SHT_NOBITS && elf_spnt->sh_flags & SHF_ALLOC) {
 
if(elf_spnt->sh_size == 0)
continue;
 
sec[i].pm_add = bss_end;
sec[i].vm_add = elf_spnt->sh_addr;
 
464,8 → 526,11
}
 
sym_nb = sec[symtab_indx].len / sizeof(struct elf32_sym);
#if JUMP_TO_MAIN
elf_entry = do_find_main(sym_nb, sym_ptr, str_ptr);
 
#else
elf_entry = do_find_start(sym_nb, sym_ptr, str_ptr);
#endif
break;
}
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.