[MIPS] IRIX: Linux coding style cleanups.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
Ralf Baechle
2007-02-05 00:05:08 +00:00
parent 3f21cdee41
commit c917061751

View File

@@ -10,6 +10,8 @@
* Copyright (C) 1996 - 2004 David S. Miller <dm@engr.sgi.com> * Copyright (C) 1996 - 2004 David S. Miller <dm@engr.sgi.com>
* Copyright (C) 2004 - 2005 Steven J. Hill <sjhill@realitydiluted.com> * Copyright (C) 2004 - 2005 Steven J. Hill <sjhill@realitydiluted.com>
*/ */
#undef DEBUG
#include <linux/module.h> #include <linux/module.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/stat.h> #include <linux/stat.h>
@@ -40,8 +42,6 @@
#include <linux/elf.h> #include <linux/elf.h>
#undef DEBUG
static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs); static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs);
static int load_irix_library(struct file *); static int load_irix_library(struct file *);
static int irix_core_dump(long signr, struct pt_regs * regs, 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 irix_core_dump, PAGE_SIZE
}; };
#ifdef DEBUG
/* Debugging routines. */ /* Debugging routines. */
static char *get_elf_p_type(Elf32_Word p_type) 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_LOAD:
case PT_NULL: return("PT_NULL"); break; return "PT_LOAD";
case PT_LOAD: return("PT_LOAD"); break; break;
case PT_DYNAMIC: return("PT_DYNAMIC"); break;
case PT_INTERP: return("PT_INTERP"); break; case PT_DYNAMIC:
case PT_NOTE: return("PT_NOTE"); break; return "PT_DYNAMIC";
case PT_SHLIB: return("PT_SHLIB"); break; break;
case PT_PHDR: return("PT_PHDR"); break;
case PT_LOPROC: return("PT_LOPROC/REGINFO"); break; case PT_INTERP:
case PT_HIPROC: return("PT_HIPROC"); break; return "PT_INTERP";
default: return("PT_BOGUS"); break; 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) static void print_elfhdr(struct elfhdr *ehp)
{ {
int i; int i;
printk("ELFHDR: e_ident<"); pr_debug("ELFHDR: e_ident<");
for(i = 0; i < (EI_NIDENT - 1); i++) printk("%x ", ehp->e_ident[i]); for (i = 0; i < (EI_NIDENT - 1); i++)
printk("%x>\n", ehp->e_ident[i]); pr_debug("%x ", ehp->e_ident[i]);
printk(" e_type[%04x] e_machine[%04x] e_version[%08lx]\n", 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 short) ehp->e_type, (unsigned short) ehp->e_machine,
(unsigned long) ehp->e_version); (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", "e_flags[%08lx]\n",
(unsigned long) ehp->e_entry, (unsigned long) ehp->e_phoff, (unsigned long) ehp->e_entry, (unsigned long) ehp->e_phoff,
(unsigned long) ehp->e_shoff, (unsigned long) ehp->e_flags); (unsigned long) ehp->e_shoff, (unsigned long) ehp->e_flags);
printk(" e_ehsize[%04x] e_phentsize[%04x] e_phnum[%04x]\n", 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_ehsize,
(unsigned short) ehp->e_phentsize,
(unsigned short) ehp->e_phnum); (unsigned short) ehp->e_phnum);
printk(" e_shentsize[%04x] e_shnum[%04x] e_shstrndx[%04x]\n", 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_shentsize,
(unsigned short) ehp->e_shnum,
(unsigned short) ehp->e_shstrndx); (unsigned short) ehp->e_shstrndx);
} }
static void print_phdr(int i, struct elf_phdr *ep) 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), "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_offset, (unsigned long) ep->p_vaddr,
(unsigned long) ep->p_paddr); (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, "p_align[%08lx]\n", (unsigned long) ep->p_filesz,
(unsigned long) ep->p_memsz, (unsigned long) ep->p_flags, (unsigned long) ep->p_memsz, (unsigned long) ep->p_flags,
(unsigned long) ep->p_align); (unsigned long) ep->p_align);
@@ -117,7 +148,6 @@ static void dump_phdrs(struct elf_phdr *ep, int pnum)
print_phdr(i, ep); print_phdr(i, ep);
} }
} }
#endif /* DEBUG */
static void set_brk(unsigned long start, unsigned long end) 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 *envp;
elf_addr_t *sp, *csp; elf_addr_t *sp, *csp;
#ifdef DEBUG pr_debug("create_irix_tables: p[%p] argc[%d] envc[%d] "
printk("create_irix_tables: p[%p] argc[%d] envc[%d] "
"load_addr[%08x] interp_load_addr[%08x]\n", "load_addr[%08x] interp_load_addr[%08x]\n",
p, argc, envc, load_addr, interp_load_addr); p, argc, envc, load_addr, interp_load_addr);
#endif
sp = (elf_addr_t *) (~15UL & (unsigned long) p); sp = (elf_addr_t *) (~15UL & (unsigned long) p);
csp = sp; csp = sp;
csp -= exec ? DLINFO_ITEMS*2 : 2; csp -= exec ? DLINFO_ITEMS*2 : 2;
@@ -245,9 +274,7 @@ static unsigned int load_irix_interp(struct elfhdr * interp_elf_ex,
last_bss = 0; last_bss = 0;
error = load_addr = 0; error = load_addr = 0;
#ifdef DEBUG
print_elfhdr(interp_elf_ex); print_elfhdr(interp_elf_ex);
#endif
/* First of all, some simple consistency checks */ /* First of all, some simple consistency checks */
if ((interp_elf_ex->e_type != ET_EXEC && 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, (char *) elf_phdata,
sizeof(struct elf_phdr) * interp_elf_ex->e_phnum); sizeof(struct elf_phdr) * interp_elf_ex->e_phnum);
#ifdef DEBUG
dump_phdrs(elf_phdata, interp_elf_ex->e_phnum); dump_phdrs(elf_phdata, interp_elf_ex->e_phnum);
#endif
eppnt = elf_phdata; eppnt = elf_phdata;
for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) { 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_type = MAP_PRIVATE | MAP_DENYWRITE;
int elf_prot = 0; int elf_prot = 0;
unsigned long vaddr = 0; unsigned long vaddr = 0;
if (eppnt->p_flags & PF_R) elf_prot = PROT_READ; if (eppnt->p_flags & PF_R)
if (eppnt->p_flags & PF_W) elf_prot |= PROT_WRITE; elf_prot = PROT_READ;
if (eppnt->p_flags & PF_X) elf_prot |= PROT_EXEC; if (eppnt->p_flags & PF_W)
elf_prot |= PROT_WRITE;
if (eppnt->p_flags & PF_X)
elf_prot |= PROT_EXEC;
elf_type |= MAP_FIXED; elf_type |= MAP_FIXED;
vaddr = eppnt->p_vaddr; 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, interpreter, vaddr,
(unsigned long) (eppnt->p_filesz + (eppnt->p_vaddr & 0xfff)), (unsigned long)
(unsigned long) elf_prot, (unsigned long) elf_type, (eppnt->p_filesz + (eppnt->p_vaddr & 0xfff)),
(unsigned long) (eppnt->p_offset & 0xfffff000)); (unsigned long)
elf_prot, (unsigned long) elf_type,
(unsigned long)
(eppnt->p_offset & 0xfffff000));
down_write(&current->mm->mmap_sem); down_write(&current->mm->mmap_sem);
error = do_mmap(interpreter, vaddr, error = do_mmap(interpreter, vaddr,
eppnt->p_filesz + (eppnt->p_vaddr & 0xfff), eppnt->p_filesz + (eppnt->p_vaddr & 0xfff),
@@ -315,7 +348,8 @@ static unsigned int load_irix_interp(struct elfhdr * interp_elf_ex,
up_write(&current->mm->mmap_sem); up_write(&current->mm->mmap_sem);
if (error < 0 && error > -1024) { 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 */ break; /* Real error */
} }
pr_debug("error=%08lx ", (unsigned long) 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 "); 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; 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 /* Do the same thing for the memory mapping - between
* elf_bss and last_bss is the bss section. * elf_bss and last_bss is the bss section.
*/ */
k = eppnt->p_memsz + eppnt->p_vaddr; k = eppnt->p_memsz + eppnt->p_vaddr;
if(k > last_bss) last_bss = k; if (k > last_bss)
last_bss = k;
pr_debug("\n"); 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) if (elf_ex.e_shnum > 20)
goto out; goto out;
#ifdef DEBUG
print_elfhdr(&elf_ex); print_elfhdr(&elf_ex);
#endif
/* Now read in all of the header information */ /* Now read in all of the header information */
size = elf_ex.e_phentsize * elf_ex.e_phnum; 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) if (retval < 0)
goto out_free_ph; goto out_free_ph;
#ifdef DEBUG
dump_phdrs(elf_phdata, elf_ex.e_phnum); dump_phdrs(elf_phdata, elf_ex.e_phnum);
#endif
/* Set some things for later. */ /* Set some things for later. */
for (i = 0; i < elf_ex.e_phnum; i++) { 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; return -EFAULT;
} }
#ifdef DEBUG
dump_phdrs(user_phdrp, cnt); dump_phdrs(user_phdrp, cnt);
#endif
for (i = 0; i < cnt; i++, hp++) { for (i = 0; i < cnt; i++, hp++) {
if (__get_user(type, &hp->p_type)) if (__get_user(type, &hp->p_type))
@@ -1015,8 +1046,6 @@ static int notesize(struct memelfnote *en)
return sz; return sz;
} }
/* #define DEBUG */
#define DUMP_WRITE(addr, nr) \ #define DUMP_WRITE(addr, nr) \
if (!dump_write(file, (addr), (nr))) \ if (!dump_write(file, (addr), (nr))) \
goto end_coredump; goto end_coredump;
@@ -1093,9 +1122,7 @@ static int irix_core_dump(long signr, struct pt_regs * regs, struct file *file)
segs++; segs++;
} }
#ifdef DEBUG pr_debug("irix_core_dump: %d segs taking %d bytes\n", segs, size);
printk("irix_core_dump: %d segs taking %d bytes\n", segs, size);
#endif
/* Set up header. */ /* Set up header. */
memcpy(elf.e_ident, ELFMAG, SELFMAG); 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)) if (!maydump(vma))
continue; continue;
i++; i++;
#ifdef DEBUG pr_debug("elf_core_dump: writing %08lx %lx\n", addr, len);
printk("elf_core_dump: writing %08lx %lx\n", addr, len);
#endif
DUMP_WRITE((void __user *)addr, len); DUMP_WRITE((void __user *)addr, len);
} }