[MIPS] IRIX: Linux coding style cleanups.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
parent
3f21cdee41
commit
c917061751
1 changed files with 173 additions and 148 deletions
|
@ -10,6 +10,8 @@
|
|||
* Copyright (C) 1996 - 2004 David S. Miller <dm@engr.sgi.com>
|
||||
* Copyright (C) 2004 - 2005 Steven J. Hill <sjhill@realitydiluted.com>
|
||||
*/
|
||||
#undef DEBUG
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/stat.h>
|
||||
|
@ -40,8 +42,6 @@
|
|||
|
||||
#include <linux/elf.h>
|
||||
|
||||
#undef DEBUG
|
||||
|
||||
static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs);
|
||||
static int load_irix_library(struct file *);
|
||||
static int irix_core_dump(long signr, struct pt_regs * regs,
|
||||
|
@ -52,55 +52,86 @@ static struct linux_binfmt irix_format = {
|
|||
irix_core_dump, PAGE_SIZE
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
/* Debugging routines. */
|
||||
static char *get_elf_p_type(Elf32_Word p_type)
|
||||
{
|
||||
int i = (int) p_type;
|
||||
#ifdef DEBUG
|
||||
switch (p_type) {
|
||||
case PT_NULL:
|
||||
return "PT_NULL";
|
||||
break;
|
||||
|
||||
switch(i) {
|
||||
case PT_NULL: return("PT_NULL"); break;
|
||||
case PT_LOAD: return("PT_LOAD"); break;
|
||||
case PT_DYNAMIC: return("PT_DYNAMIC"); break;
|
||||
case PT_INTERP: return("PT_INTERP"); break;
|
||||
case PT_NOTE: return("PT_NOTE"); break;
|
||||
case PT_SHLIB: return("PT_SHLIB"); break;
|
||||
case PT_PHDR: return("PT_PHDR"); break;
|
||||
case PT_LOPROC: return("PT_LOPROC/REGINFO"); break;
|
||||
case PT_HIPROC: return("PT_HIPROC"); break;
|
||||
default: return("PT_BOGUS"); break;
|
||||
case PT_LOAD:
|
||||
return "PT_LOAD";
|
||||
break;
|
||||
|
||||
case PT_DYNAMIC:
|
||||
return "PT_DYNAMIC";
|
||||
break;
|
||||
|
||||
case PT_INTERP:
|
||||
return "PT_INTERP";
|
||||
break;
|
||||
|
||||
case PT_NOTE:
|
||||
return "PT_NOTE";
|
||||
break;
|
||||
|
||||
case PT_SHLIB:
|
||||
return "PT_SHLIB";
|
||||
break;
|
||||
|
||||
case PT_PHDR:
|
||||
return "PT_PHDR";
|
||||
break;
|
||||
|
||||
case PT_LOPROC:
|
||||
return "PT_LOPROC/REGINFO";
|
||||
break;
|
||||
|
||||
case PT_HIPROC:
|
||||
return "PT_HIPROC";
|
||||
break;
|
||||
|
||||
default:
|
||||
return "PT_BOGUS";
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void print_elfhdr(struct elfhdr *ehp)
|
||||
{
|
||||
int i;
|
||||
|
||||
printk("ELFHDR: e_ident<");
|
||||
for(i = 0; i < (EI_NIDENT - 1); i++) printk("%x ", ehp->e_ident[i]);
|
||||
printk("%x>\n", ehp->e_ident[i]);
|
||||
printk(" e_type[%04x] e_machine[%04x] e_version[%08lx]\n",
|
||||
pr_debug("ELFHDR: e_ident<");
|
||||
for (i = 0; i < (EI_NIDENT - 1); i++)
|
||||
pr_debug("%x ", ehp->e_ident[i]);
|
||||
pr_debug("%x>\n", ehp->e_ident[i]);
|
||||
pr_debug(" e_type[%04x] e_machine[%04x] e_version[%08lx]\n",
|
||||
(unsigned short) ehp->e_type, (unsigned short) ehp->e_machine,
|
||||
(unsigned long) ehp->e_version);
|
||||
printk(" e_entry[%08lx] e_phoff[%08lx] e_shoff[%08lx] "
|
||||
pr_debug(" e_entry[%08lx] e_phoff[%08lx] e_shoff[%08lx] "
|
||||
"e_flags[%08lx]\n",
|
||||
(unsigned long) ehp->e_entry, (unsigned long) ehp->e_phoff,
|
||||
(unsigned long) ehp->e_shoff, (unsigned long) ehp->e_flags);
|
||||
printk(" e_ehsize[%04x] e_phentsize[%04x] e_phnum[%04x]\n",
|
||||
(unsigned short) ehp->e_ehsize, (unsigned short) ehp->e_phentsize,
|
||||
pr_debug(" e_ehsize[%04x] e_phentsize[%04x] e_phnum[%04x]\n",
|
||||
(unsigned short) ehp->e_ehsize,
|
||||
(unsigned short) ehp->e_phentsize,
|
||||
(unsigned short) ehp->e_phnum);
|
||||
printk(" e_shentsize[%04x] e_shnum[%04x] e_shstrndx[%04x]\n",
|
||||
(unsigned short) ehp->e_shentsize, (unsigned short) ehp->e_shnum,
|
||||
pr_debug(" e_shentsize[%04x] e_shnum[%04x] e_shstrndx[%04x]\n",
|
||||
(unsigned short) ehp->e_shentsize,
|
||||
(unsigned short) ehp->e_shnum,
|
||||
(unsigned short) ehp->e_shstrndx);
|
||||
}
|
||||
|
||||
static void print_phdr(int i, struct elf_phdr *ep)
|
||||
{
|
||||
printk("PHDR[%d]: p_type[%s] p_offset[%08lx] p_vaddr[%08lx] "
|
||||
pr_debug("PHDR[%d]: p_type[%s] p_offset[%08lx] p_vaddr[%08lx] "
|
||||
"p_paddr[%08lx]\n", i, get_elf_p_type(ep->p_type),
|
||||
(unsigned long) ep->p_offset, (unsigned long) ep->p_vaddr,
|
||||
(unsigned long) ep->p_paddr);
|
||||
printk(" p_filesz[%08lx] p_memsz[%08lx] p_flags[%08lx] "
|
||||
pr_debug(" p_filesz[%08lx] p_memsz[%08lx] p_flags[%08lx] "
|
||||
"p_align[%08lx]\n", (unsigned long) ep->p_filesz,
|
||||
(unsigned long) ep->p_memsz, (unsigned long) ep->p_flags,
|
||||
(unsigned long) ep->p_align);
|
||||
|
@ -117,7 +148,6 @@ static void dump_phdrs(struct elf_phdr *ep, int pnum)
|
|||
print_phdr(i, ep);
|
||||
}
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
static void set_brk(unsigned long start, unsigned long end)
|
||||
{
|
||||
|
@ -156,11 +186,10 @@ static unsigned long * create_irix_tables(char * p, int argc, int envc,
|
|||
elf_addr_t *envp;
|
||||
elf_addr_t *sp, *csp;
|
||||
|
||||
#ifdef DEBUG
|
||||
printk("create_irix_tables: p[%p] argc[%d] envc[%d] "
|
||||
pr_debug("create_irix_tables: p[%p] argc[%d] envc[%d] "
|
||||
"load_addr[%08x] interp_load_addr[%08x]\n",
|
||||
p, argc, envc, load_addr, interp_load_addr);
|
||||
#endif
|
||||
|
||||
sp = (elf_addr_t *) (~15UL & (unsigned long) p);
|
||||
csp = sp;
|
||||
csp -= exec ? DLINFO_ITEMS*2 : 2;
|
||||
|
@ -245,9 +274,7 @@ static unsigned int load_irix_interp(struct elfhdr * interp_elf_ex,
|
|||
last_bss = 0;
|
||||
error = load_addr = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
print_elfhdr(interp_elf_ex);
|
||||
#endif
|
||||
|
||||
/* First of all, some simple consistency checks */
|
||||
if ((interp_elf_ex->e_type != ET_EXEC &&
|
||||
|
@ -286,9 +313,7 @@ static unsigned int load_irix_interp(struct elfhdr * interp_elf_ex,
|
|||
(char *) elf_phdata,
|
||||
sizeof(struct elf_phdr) * interp_elf_ex->e_phnum);
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_phdrs(elf_phdata, interp_elf_ex->e_phnum);
|
||||
#endif
|
||||
|
||||
eppnt = elf_phdata;
|
||||
for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
|
||||
|
@ -296,17 +321,25 @@ static unsigned int load_irix_interp(struct elfhdr * interp_elf_ex,
|
|||
int elf_type = MAP_PRIVATE | MAP_DENYWRITE;
|
||||
int elf_prot = 0;
|
||||
unsigned long vaddr = 0;
|
||||
if (eppnt->p_flags & PF_R) elf_prot = PROT_READ;
|
||||
if (eppnt->p_flags & PF_W) elf_prot |= PROT_WRITE;
|
||||
if (eppnt->p_flags & PF_X) elf_prot |= PROT_EXEC;
|
||||
if (eppnt->p_flags & PF_R)
|
||||
elf_prot = PROT_READ;
|
||||
if (eppnt->p_flags & PF_W)
|
||||
elf_prot |= PROT_WRITE;
|
||||
if (eppnt->p_flags & PF_X)
|
||||
elf_prot |= PROT_EXEC;
|
||||
elf_type |= MAP_FIXED;
|
||||
vaddr = eppnt->p_vaddr;
|
||||
|
||||
pr_debug("INTERP do_mmap(%p, %08lx, %08lx, %08lx, %08lx, %08lx) ",
|
||||
pr_debug("INTERP do_mmap"
|
||||
"(%p, %08lx, %08lx, %08lx, %08lx, %08lx) ",
|
||||
interpreter, vaddr,
|
||||
(unsigned long) (eppnt->p_filesz + (eppnt->p_vaddr & 0xfff)),
|
||||
(unsigned long) elf_prot, (unsigned long) elf_type,
|
||||
(unsigned long) (eppnt->p_offset & 0xfffff000));
|
||||
(unsigned long)
|
||||
(eppnt->p_filesz + (eppnt->p_vaddr & 0xfff)),
|
||||
(unsigned long)
|
||||
elf_prot, (unsigned long) elf_type,
|
||||
(unsigned long)
|
||||
(eppnt->p_offset & 0xfffff000));
|
||||
|
||||
down_write(¤t->mm->mmap_sem);
|
||||
error = do_mmap(interpreter, vaddr,
|
||||
eppnt->p_filesz + (eppnt->p_vaddr & 0xfff),
|
||||
|
@ -315,7 +348,8 @@ static unsigned int load_irix_interp(struct elfhdr * interp_elf_ex,
|
|||
up_write(¤t->mm->mmap_sem);
|
||||
|
||||
if (error < 0 && error > -1024) {
|
||||
printk("Aieee IRIX interp mmap error=%d\n", error);
|
||||
printk("Aieee IRIX interp mmap error=%d\n",
|
||||
error);
|
||||
break; /* Real error */
|
||||
}
|
||||
pr_debug("error=%08lx ", (unsigned long) error);
|
||||
|
@ -324,17 +358,20 @@ static unsigned int load_irix_interp(struct elfhdr * interp_elf_ex,
|
|||
pr_debug("load_addr = error ");
|
||||
}
|
||||
|
||||
/* Find the end of the file mapping for this phdr, and keep
|
||||
* track of the largest address we see for this.
|
||||
/*
|
||||
* Find the end of the file mapping for this phdr, and
|
||||
* keep track of the largest address we see for this.
|
||||
*/
|
||||
k = eppnt->p_vaddr + eppnt->p_filesz;
|
||||
if(k > elf_bss) elf_bss = k;
|
||||
if (k > elf_bss)
|
||||
elf_bss = k;
|
||||
|
||||
/* Do the same thing for the memory mapping - between
|
||||
* elf_bss and last_bss is the bss section.
|
||||
*/
|
||||
k = eppnt->p_memsz + eppnt->p_vaddr;
|
||||
if(k > last_bss) last_bss = k;
|
||||
if (k > last_bss)
|
||||
last_bss = k;
|
||||
pr_debug("\n");
|
||||
}
|
||||
}
|
||||
|
@ -604,9 +641,7 @@ static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs)
|
|||
if (elf_ex.e_shnum > 20)
|
||||
goto out;
|
||||
|
||||
#ifdef DEBUG
|
||||
print_elfhdr(&elf_ex);
|
||||
#endif
|
||||
|
||||
/* Now read in all of the header information */
|
||||
size = elf_ex.e_phentsize * elf_ex.e_phnum;
|
||||
|
@ -622,9 +657,7 @@ static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs)
|
|||
if (retval < 0)
|
||||
goto out_free_ph;
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_phdrs(elf_phdata, elf_ex.e_phnum);
|
||||
#endif
|
||||
|
||||
/* Set some things for later. */
|
||||
for (i = 0; i < elf_ex.e_phnum; i++) {
|
||||
|
@ -889,9 +922,7 @@ unsigned long irix_mapelf(int fd, struct elf_phdr __user *user_phdrp, int cnt)
|
|||
return -EFAULT;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_phdrs(user_phdrp, cnt);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < cnt; i++, hp++) {
|
||||
if (__get_user(type, &hp->p_type))
|
||||
|
@ -1015,8 +1046,6 @@ static int notesize(struct memelfnote *en)
|
|||
return sz;
|
||||
}
|
||||
|
||||
/* #define DEBUG */
|
||||
|
||||
#define DUMP_WRITE(addr, nr) \
|
||||
if (!dump_write(file, (addr), (nr))) \
|
||||
goto end_coredump;
|
||||
|
@ -1093,9 +1122,7 @@ static int irix_core_dump(long signr, struct pt_regs * regs, struct file *file)
|
|||
|
||||
segs++;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printk("irix_core_dump: %d segs taking %d bytes\n", segs, size);
|
||||
#endif
|
||||
pr_debug("irix_core_dump: %d segs taking %d bytes\n", segs, size);
|
||||
|
||||
/* Set up header. */
|
||||
memcpy(elf.e_ident, ELFMAG, SELFMAG);
|
||||
|
@ -1284,9 +1311,7 @@ static int irix_core_dump(long signr, struct pt_regs * regs, struct file *file)
|
|||
if (!maydump(vma))
|
||||
continue;
|
||||
i++;
|
||||
#ifdef DEBUG
|
||||
printk("elf_core_dump: writing %08lx %lx\n", addr, len);
|
||||
#endif
|
||||
pr_debug("elf_core_dump: writing %08lx %lx\n", addr, len);
|
||||
DUMP_WRITE((void __user *)addr, len);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue