Commit c9170617510059c750cb91207b08f35001571a22
1 parent
3f21cdee41
Exists in
master
and in
7 other branches
[MIPS] IRIX: Linux coding style cleanups.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Showing 1 changed file with 178 additions and 153 deletions Side-by-side Diff
arch/mips/kernel/irixelf.c
... | ... | @@ -10,6 +10,8 @@ |
10 | 10 | * Copyright (C) 1996 - 2004 David S. Miller <dm@engr.sgi.com> |
11 | 11 | * Copyright (C) 2004 - 2005 Steven J. Hill <sjhill@realitydiluted.com> |
12 | 12 | */ |
13 | +#undef DEBUG | |
14 | + | |
13 | 15 | #include <linux/module.h> |
14 | 16 | #include <linux/fs.h> |
15 | 17 | #include <linux/stat.h> |
... | ... | @@ -40,8 +42,6 @@ |
40 | 42 | |
41 | 43 | #include <linux/elf.h> |
42 | 44 | |
43 | -#undef DEBUG | |
44 | - | |
45 | 45 | static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs); |
46 | 46 | static int load_irix_library(struct file *); |
47 | 47 | static int irix_core_dump(long signr, struct pt_regs * regs, |
48 | 48 | |
49 | 49 | |
50 | 50 | |
51 | 51 | |
52 | 52 | |
53 | 53 | |
54 | 54 | |
... | ... | @@ -52,72 +52,102 @@ |
52 | 52 | irix_core_dump, PAGE_SIZE |
53 | 53 | }; |
54 | 54 | |
55 | -#ifdef DEBUG | |
56 | 55 | /* Debugging routines. */ |
57 | 56 | static char *get_elf_p_type(Elf32_Word p_type) |
58 | 57 | { |
59 | - int i = (int) p_type; | |
58 | +#ifdef DEBUG | |
59 | + switch (p_type) { | |
60 | + case PT_NULL: | |
61 | + return "PT_NULL"; | |
62 | + break; | |
60 | 63 | |
61 | - switch(i) { | |
62 | - case PT_NULL: return("PT_NULL"); break; | |
63 | - case PT_LOAD: return("PT_LOAD"); break; | |
64 | - case PT_DYNAMIC: return("PT_DYNAMIC"); break; | |
65 | - case PT_INTERP: return("PT_INTERP"); break; | |
66 | - case PT_NOTE: return("PT_NOTE"); break; | |
67 | - case PT_SHLIB: return("PT_SHLIB"); break; | |
68 | - case PT_PHDR: return("PT_PHDR"); break; | |
69 | - case PT_LOPROC: return("PT_LOPROC/REGINFO"); break; | |
70 | - case PT_HIPROC: return("PT_HIPROC"); break; | |
71 | - default: return("PT_BOGUS"); break; | |
64 | + case PT_LOAD: | |
65 | + return "PT_LOAD"; | |
66 | + break; | |
67 | + | |
68 | + case PT_DYNAMIC: | |
69 | + return "PT_DYNAMIC"; | |
70 | + break; | |
71 | + | |
72 | + case PT_INTERP: | |
73 | + return "PT_INTERP"; | |
74 | + break; | |
75 | + | |
76 | + case PT_NOTE: | |
77 | + return "PT_NOTE"; | |
78 | + break; | |
79 | + | |
80 | + case PT_SHLIB: | |
81 | + return "PT_SHLIB"; | |
82 | + break; | |
83 | + | |
84 | + case PT_PHDR: | |
85 | + return "PT_PHDR"; | |
86 | + break; | |
87 | + | |
88 | + case PT_LOPROC: | |
89 | + return "PT_LOPROC/REGINFO"; | |
90 | + break; | |
91 | + | |
92 | + case PT_HIPROC: | |
93 | + return "PT_HIPROC"; | |
94 | + break; | |
95 | + | |
96 | + default: | |
97 | + return "PT_BOGUS"; | |
98 | + break; | |
72 | 99 | } |
100 | +#endif | |
73 | 101 | } |
74 | 102 | |
75 | 103 | static void print_elfhdr(struct elfhdr *ehp) |
76 | 104 | { |
77 | 105 | int i; |
78 | 106 | |
79 | - printk("ELFHDR: e_ident<"); | |
80 | - for(i = 0; i < (EI_NIDENT - 1); i++) printk("%x ", ehp->e_ident[i]); | |
81 | - printk("%x>\n", ehp->e_ident[i]); | |
82 | - printk(" e_type[%04x] e_machine[%04x] e_version[%08lx]\n", | |
83 | - (unsigned short) ehp->e_type, (unsigned short) ehp->e_machine, | |
84 | - (unsigned long) ehp->e_version); | |
85 | - printk(" e_entry[%08lx] e_phoff[%08lx] e_shoff[%08lx] " | |
86 | - "e_flags[%08lx]\n", | |
87 | - (unsigned long) ehp->e_entry, (unsigned long) ehp->e_phoff, | |
88 | - (unsigned long) ehp->e_shoff, (unsigned long) ehp->e_flags); | |
89 | - printk(" e_ehsize[%04x] e_phentsize[%04x] e_phnum[%04x]\n", | |
90 | - (unsigned short) ehp->e_ehsize, (unsigned short) ehp->e_phentsize, | |
91 | - (unsigned short) ehp->e_phnum); | |
92 | - printk(" e_shentsize[%04x] e_shnum[%04x] e_shstrndx[%04x]\n", | |
93 | - (unsigned short) ehp->e_shentsize, (unsigned short) ehp->e_shnum, | |
94 | - (unsigned short) ehp->e_shstrndx); | |
107 | + pr_debug("ELFHDR: e_ident<"); | |
108 | + for (i = 0; i < (EI_NIDENT - 1); i++) | |
109 | + pr_debug("%x ", ehp->e_ident[i]); | |
110 | + pr_debug("%x>\n", ehp->e_ident[i]); | |
111 | + pr_debug(" e_type[%04x] e_machine[%04x] e_version[%08lx]\n", | |
112 | + (unsigned short) ehp->e_type, (unsigned short) ehp->e_machine, | |
113 | + (unsigned long) ehp->e_version); | |
114 | + pr_debug(" e_entry[%08lx] e_phoff[%08lx] e_shoff[%08lx] " | |
115 | + "e_flags[%08lx]\n", | |
116 | + (unsigned long) ehp->e_entry, (unsigned long) ehp->e_phoff, | |
117 | + (unsigned long) ehp->e_shoff, (unsigned long) ehp->e_flags); | |
118 | + pr_debug(" e_ehsize[%04x] e_phentsize[%04x] e_phnum[%04x]\n", | |
119 | + (unsigned short) ehp->e_ehsize, | |
120 | + (unsigned short) ehp->e_phentsize, | |
121 | + (unsigned short) ehp->e_phnum); | |
122 | + pr_debug(" e_shentsize[%04x] e_shnum[%04x] e_shstrndx[%04x]\n", | |
123 | + (unsigned short) ehp->e_shentsize, | |
124 | + (unsigned short) ehp->e_shnum, | |
125 | + (unsigned short) ehp->e_shstrndx); | |
95 | 126 | } |
96 | 127 | |
97 | 128 | static void print_phdr(int i, struct elf_phdr *ep) |
98 | 129 | { |
99 | - printk("PHDR[%d]: p_type[%s] p_offset[%08lx] p_vaddr[%08lx] " | |
100 | - "p_paddr[%08lx]\n", i, get_elf_p_type(ep->p_type), | |
101 | - (unsigned long) ep->p_offset, (unsigned long) ep->p_vaddr, | |
102 | - (unsigned long) ep->p_paddr); | |
103 | - printk(" p_filesz[%08lx] p_memsz[%08lx] p_flags[%08lx] " | |
104 | - "p_align[%08lx]\n", (unsigned long) ep->p_filesz, | |
105 | - (unsigned long) ep->p_memsz, (unsigned long) ep->p_flags, | |
106 | - (unsigned long) ep->p_align); | |
130 | + pr_debug("PHDR[%d]: p_type[%s] p_offset[%08lx] p_vaddr[%08lx] " | |
131 | + "p_paddr[%08lx]\n", i, get_elf_p_type(ep->p_type), | |
132 | + (unsigned long) ep->p_offset, (unsigned long) ep->p_vaddr, | |
133 | + (unsigned long) ep->p_paddr); | |
134 | + pr_debug(" p_filesz[%08lx] p_memsz[%08lx] p_flags[%08lx] " | |
135 | + "p_align[%08lx]\n", (unsigned long) ep->p_filesz, | |
136 | + (unsigned long) ep->p_memsz, (unsigned long) ep->p_flags, | |
137 | + (unsigned long) ep->p_align); | |
107 | 138 | } |
108 | 139 | |
109 | 140 | static void dump_phdrs(struct elf_phdr *ep, int pnum) |
110 | 141 | { |
111 | 142 | int i; |
112 | 143 | |
113 | - for(i = 0; i < pnum; i++, ep++) { | |
114 | - if((ep->p_type == PT_LOAD) || | |
115 | - (ep->p_type == PT_INTERP) || | |
116 | - (ep->p_type == PT_PHDR)) | |
144 | + for (i = 0; i < pnum; i++, ep++) { | |
145 | + if ((ep->p_type == PT_LOAD) || | |
146 | + (ep->p_type == PT_INTERP) || | |
147 | + (ep->p_type == PT_PHDR)) | |
117 | 148 | print_phdr(i, ep); |
118 | 149 | } |
119 | 150 | } |
120 | -#endif /* DEBUG */ | |
121 | 151 | |
122 | 152 | static void set_brk(unsigned long start, unsigned long end) |
123 | 153 | { |
... | ... | @@ -156,11 +186,10 @@ |
156 | 186 | elf_addr_t *envp; |
157 | 187 | elf_addr_t *sp, *csp; |
158 | 188 | |
159 | -#ifdef DEBUG | |
160 | - printk("create_irix_tables: p[%p] argc[%d] envc[%d] " | |
161 | - "load_addr[%08x] interp_load_addr[%08x]\n", | |
162 | - p, argc, envc, load_addr, interp_load_addr); | |
163 | -#endif | |
189 | + pr_debug("create_irix_tables: p[%p] argc[%d] envc[%d] " | |
190 | + "load_addr[%08x] interp_load_addr[%08x]\n", | |
191 | + p, argc, envc, load_addr, interp_load_addr); | |
192 | + | |
164 | 193 | sp = (elf_addr_t *) (~15UL & (unsigned long) p); |
165 | 194 | csp = sp; |
166 | 195 | csp -= exec ? DLINFO_ITEMS*2 : 2; |
... | ... | @@ -181,7 +210,7 @@ |
181 | 210 | sp -= 2; |
182 | 211 | NEW_AUX_ENT(0, AT_NULL, 0); |
183 | 212 | |
184 | - if(exec) { | |
213 | + if (exec) { | |
185 | 214 | sp -= 11*2; |
186 | 215 | |
187 | 216 | NEW_AUX_ENT (0, AT_PHDR, load_addr + exec->e_phoff); |
188 | 217 | |
... | ... | @@ -245,9 +274,7 @@ |
245 | 274 | last_bss = 0; |
246 | 275 | error = load_addr = 0; |
247 | 276 | |
248 | -#ifdef DEBUG | |
249 | 277 | print_elfhdr(interp_elf_ex); |
250 | -#endif | |
251 | 278 | |
252 | 279 | /* First of all, some simple consistency checks */ |
253 | 280 | if ((interp_elf_ex->e_type != ET_EXEC && |
... | ... | @@ -258,7 +285,7 @@ |
258 | 285 | } |
259 | 286 | |
260 | 287 | /* Now read in all of the header information */ |
261 | - if(sizeof(struct elf_phdr) * interp_elf_ex->e_phnum > PAGE_SIZE) { | |
288 | + if (sizeof(struct elf_phdr) * interp_elf_ex->e_phnum > PAGE_SIZE) { | |
262 | 289 | printk("IRIX interp header bigger than a page (%d)\n", |
263 | 290 | (sizeof(struct elf_phdr) * interp_elf_ex->e_phnum)); |
264 | 291 | return 0xffffffff; |
265 | 292 | |
... | ... | @@ -267,15 +294,15 @@ |
267 | 294 | elf_phdata = kmalloc(sizeof(struct elf_phdr) * interp_elf_ex->e_phnum, |
268 | 295 | GFP_KERNEL); |
269 | 296 | |
270 | - if(!elf_phdata) { | |
271 | - printk("Cannot kmalloc phdata for IRIX interp.\n"); | |
272 | - return 0xffffffff; | |
297 | + if (!elf_phdata) { | |
298 | + printk("Cannot kmalloc phdata for IRIX interp.\n"); | |
299 | + return 0xffffffff; | |
273 | 300 | } |
274 | 301 | |
275 | 302 | /* If the size of this structure has changed, then punt, since |
276 | 303 | * we will be doing the wrong thing. |
277 | 304 | */ |
278 | - if(interp_elf_ex->e_phentsize != 32) { | |
305 | + if (interp_elf_ex->e_phentsize != 32) { | |
279 | 306 | printk("IRIX interp e_phentsize == %d != 32 ", |
280 | 307 | interp_elf_ex->e_phentsize); |
281 | 308 | kfree(elf_phdata); |
282 | 309 | |
283 | 310 | |
284 | 311 | |
285 | 312 | |
286 | 313 | |
287 | 314 | |
288 | 315 | |
... | ... | @@ -286,61 +313,71 @@ |
286 | 313 | (char *) elf_phdata, |
287 | 314 | sizeof(struct elf_phdr) * interp_elf_ex->e_phnum); |
288 | 315 | |
289 | -#ifdef DEBUG | |
290 | 316 | dump_phdrs(elf_phdata, interp_elf_ex->e_phnum); |
291 | -#endif | |
292 | 317 | |
293 | 318 | eppnt = elf_phdata; |
294 | - for(i=0; i<interp_elf_ex->e_phnum; i++, eppnt++) { | |
295 | - if(eppnt->p_type == PT_LOAD) { | |
296 | - int elf_type = MAP_PRIVATE | MAP_DENYWRITE; | |
297 | - int elf_prot = 0; | |
298 | - unsigned long vaddr = 0; | |
299 | - if (eppnt->p_flags & PF_R) elf_prot = PROT_READ; | |
300 | - if (eppnt->p_flags & PF_W) elf_prot |= PROT_WRITE; | |
301 | - if (eppnt->p_flags & PF_X) elf_prot |= PROT_EXEC; | |
302 | - elf_type |= MAP_FIXED; | |
303 | - vaddr = eppnt->p_vaddr; | |
319 | + for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) { | |
320 | + if (eppnt->p_type == PT_LOAD) { | |
321 | + int elf_type = MAP_PRIVATE | MAP_DENYWRITE; | |
322 | + int elf_prot = 0; | |
323 | + unsigned long vaddr = 0; | |
324 | + if (eppnt->p_flags & PF_R) | |
325 | + elf_prot = PROT_READ; | |
326 | + if (eppnt->p_flags & PF_W) | |
327 | + elf_prot |= PROT_WRITE; | |
328 | + if (eppnt->p_flags & PF_X) | |
329 | + elf_prot |= PROT_EXEC; | |
330 | + elf_type |= MAP_FIXED; | |
331 | + vaddr = eppnt->p_vaddr; | |
304 | 332 | |
305 | - pr_debug("INTERP do_mmap(%p, %08lx, %08lx, %08lx, %08lx, %08lx) ", | |
306 | - interpreter, vaddr, | |
307 | - (unsigned long) (eppnt->p_filesz + (eppnt->p_vaddr & 0xfff)), | |
308 | - (unsigned long) elf_prot, (unsigned long) elf_type, | |
309 | - (unsigned long) (eppnt->p_offset & 0xfffff000)); | |
310 | - down_write(¤t->mm->mmap_sem); | |
311 | - error = do_mmap(interpreter, vaddr, | |
312 | - eppnt->p_filesz + (eppnt->p_vaddr & 0xfff), | |
313 | - elf_prot, elf_type, | |
314 | - eppnt->p_offset & 0xfffff000); | |
315 | - up_write(¤t->mm->mmap_sem); | |
333 | + pr_debug("INTERP do_mmap" | |
334 | + "(%p, %08lx, %08lx, %08lx, %08lx, %08lx) ", | |
335 | + interpreter, vaddr, | |
336 | + (unsigned long) | |
337 | + (eppnt->p_filesz + (eppnt->p_vaddr & 0xfff)), | |
338 | + (unsigned long) | |
339 | + elf_prot, (unsigned long) elf_type, | |
340 | + (unsigned long) | |
341 | + (eppnt->p_offset & 0xfffff000)); | |
316 | 342 | |
317 | - if(error < 0 && error > -1024) { | |
318 | - printk("Aieee IRIX interp mmap error=%d\n", error); | |
319 | - break; /* Real error */ | |
320 | - } | |
321 | - pr_debug("error=%08lx ", (unsigned long) error); | |
322 | - if(!load_addr && interp_elf_ex->e_type == ET_DYN) { | |
323 | - load_addr = error; | |
324 | - pr_debug("load_addr = error "); | |
325 | - } | |
343 | + down_write(¤t->mm->mmap_sem); | |
344 | + error = do_mmap(interpreter, vaddr, | |
345 | + eppnt->p_filesz + (eppnt->p_vaddr & 0xfff), | |
346 | + elf_prot, elf_type, | |
347 | + eppnt->p_offset & 0xfffff000); | |
348 | + up_write(¤t->mm->mmap_sem); | |
326 | 349 | |
327 | - /* Find the end of the file mapping for this phdr, and keep | |
328 | - * track of the largest address we see for this. | |
329 | - */ | |
330 | - k = eppnt->p_vaddr + eppnt->p_filesz; | |
331 | - if(k > elf_bss) elf_bss = k; | |
350 | + if (error < 0 && error > -1024) { | |
351 | + printk("Aieee IRIX interp mmap error=%d\n", | |
352 | + error); | |
353 | + break; /* Real error */ | |
354 | + } | |
355 | + pr_debug("error=%08lx ", (unsigned long) error); | |
356 | + if (!load_addr && interp_elf_ex->e_type == ET_DYN) { | |
357 | + load_addr = error; | |
358 | + pr_debug("load_addr = error "); | |
359 | + } | |
332 | 360 | |
333 | - /* Do the same thing for the memory mapping - between | |
334 | - * elf_bss and last_bss is the bss section. | |
335 | - */ | |
336 | - k = eppnt->p_memsz + eppnt->p_vaddr; | |
337 | - if(k > last_bss) last_bss = k; | |
338 | - pr_debug("\n"); | |
339 | - } | |
361 | + /* | |
362 | + * Find the end of the file mapping for this phdr, and | |
363 | + * keep track of the largest address we see for this. | |
364 | + */ | |
365 | + k = eppnt->p_vaddr + eppnt->p_filesz; | |
366 | + if (k > elf_bss) | |
367 | + elf_bss = k; | |
368 | + | |
369 | + /* Do the same thing for the memory mapping - between | |
370 | + * elf_bss and last_bss is the bss section. | |
371 | + */ | |
372 | + k = eppnt->p_memsz + eppnt->p_vaddr; | |
373 | + if (k > last_bss) | |
374 | + last_bss = k; | |
375 | + pr_debug("\n"); | |
376 | + } | |
340 | 377 | } |
341 | 378 | |
342 | 379 | /* Now use mmap to map the library into memory. */ |
343 | - if(error < 0 && error > -1024) { | |
380 | + if (error < 0 && error > -1024) { | |
344 | 381 | pr_debug("got error %d\n", error); |
345 | 382 | kfree(elf_phdata); |
346 | 383 | return 0xffffffff; |
... | ... | @@ -377,7 +414,7 @@ |
377 | 414 | return -ENOEXEC; |
378 | 415 | |
379 | 416 | /* First of all, some simple consistency checks */ |
380 | - if((ehp->e_type != ET_EXEC && ehp->e_type != ET_DYN) || | |
417 | + if ((ehp->e_type != ET_EXEC && ehp->e_type != ET_DYN) || | |
381 | 418 | !bprm->file->f_op->mmap) { |
382 | 419 | return -ENOEXEC; |
383 | 420 | } |
... | ... | @@ -388,7 +425,7 @@ |
388 | 425 | * XXX all registers as 64bits on cpu's capable of this at |
389 | 426 | * XXX exception time plus frob the XTLB exception vector. |
390 | 427 | */ |
391 | - if((ehp->e_flags & EF_MIPS_ABI2)) | |
428 | + if ((ehp->e_flags & EF_MIPS_ABI2)) | |
392 | 429 | return -ENOEXEC; |
393 | 430 | |
394 | 431 | return 0; |
... | ... | @@ -410,7 +447,7 @@ |
410 | 447 | struct file *file = NULL; |
411 | 448 | |
412 | 449 | *name = NULL; |
413 | - for(i = 0; i < pnum; i++, epp++) { | |
450 | + for (i = 0; i < pnum; i++, epp++) { | |
414 | 451 | if (epp->p_type != PT_INTERP) |
415 | 452 | continue; |
416 | 453 | |
... | ... | @@ -467,8 +504,8 @@ |
467 | 504 | unsigned int tmp; |
468 | 505 | int i, prot; |
469 | 506 | |
470 | - for(i = 0; i < pnum; i++, epp++) { | |
471 | - if(epp->p_type != PT_LOAD) | |
507 | + for (i = 0; i < pnum; i++, epp++) { | |
508 | + if (epp->p_type != PT_LOAD) | |
472 | 509 | continue; |
473 | 510 | |
474 | 511 | /* Map it. */ |
475 | 512 | |
476 | 513 | |
477 | 514 | |
478 | 515 | |
479 | 516 | |
480 | 517 | |
... | ... | @@ -483,23 +520,23 @@ |
483 | 520 | up_write(¤t->mm->mmap_sem); |
484 | 521 | |
485 | 522 | /* Fixup location tracking vars. */ |
486 | - if((epp->p_vaddr & 0xfffff000) < *estack) | |
523 | + if ((epp->p_vaddr & 0xfffff000) < *estack) | |
487 | 524 | *estack = (epp->p_vaddr & 0xfffff000); |
488 | - if(!*laddr) | |
525 | + if (!*laddr) | |
489 | 526 | *laddr = epp->p_vaddr - epp->p_offset; |
490 | - if(epp->p_vaddr < *scode) | |
527 | + if (epp->p_vaddr < *scode) | |
491 | 528 | *scode = epp->p_vaddr; |
492 | 529 | |
493 | 530 | tmp = epp->p_vaddr + epp->p_filesz; |
494 | - if(tmp > *ebss) | |
531 | + if (tmp > *ebss) | |
495 | 532 | *ebss = tmp; |
496 | - if((epp->p_flags & PF_X) && *ecode < tmp) | |
533 | + if ((epp->p_flags & PF_X) && *ecode < tmp) | |
497 | 534 | *ecode = tmp; |
498 | - if(*edata < tmp) | |
535 | + if (*edata < tmp) | |
499 | 536 | *edata = tmp; |
500 | 537 | |
501 | 538 | tmp = epp->p_vaddr + epp->p_memsz; |
502 | - if(tmp > *ebrk) | |
539 | + if (tmp > *ebrk) | |
503 | 540 | *ebrk = tmp; |
504 | 541 | } |
505 | 542 | |
506 | 543 | |
... | ... | @@ -513,12 +550,12 @@ |
513 | 550 | int i; |
514 | 551 | |
515 | 552 | *eentry = 0xffffffff; |
516 | - for(i = 0; i < pnum; i++, epp++) { | |
517 | - if(epp->p_type != PT_INTERP) | |
553 | + for (i = 0; i < pnum; i++, epp++) { | |
554 | + if (epp->p_type != PT_INTERP) | |
518 | 555 | continue; |
519 | 556 | |
520 | 557 | /* We should have fielded this error elsewhere... */ |
521 | - if(*eentry != 0xffffffff) | |
558 | + if (*eentry != 0xffffffff) | |
522 | 559 | return -1; |
523 | 560 | |
524 | 561 | set_fs(old_fs); |
525 | 562 | |
... | ... | @@ -604,9 +641,7 @@ |
604 | 641 | if (elf_ex.e_shnum > 20) |
605 | 642 | goto out; |
606 | 643 | |
607 | -#ifdef DEBUG | |
608 | 644 | print_elfhdr(&elf_ex); |
609 | -#endif | |
610 | 645 | |
611 | 646 | /* Now read in all of the header information */ |
612 | 647 | size = elf_ex.e_phentsize * elf_ex.e_phnum; |
613 | 648 | |
614 | 649 | |
... | ... | @@ -622,13 +657,11 @@ |
622 | 657 | if (retval < 0) |
623 | 658 | goto out_free_ph; |
624 | 659 | |
625 | -#ifdef DEBUG | |
626 | 660 | dump_phdrs(elf_phdata, elf_ex.e_phnum); |
627 | -#endif | |
628 | 661 | |
629 | 662 | /* Set some things for later. */ |
630 | - for(i = 0; i < elf_ex.e_phnum; i++) { | |
631 | - switch(elf_phdata[i].p_type) { | |
663 | + for (i = 0; i < elf_ex.e_phnum; i++) { | |
664 | + switch (elf_phdata[i].p_type) { | |
632 | 665 | case PT_INTERP: |
633 | 666 | has_interp = 1; |
634 | 667 | elf_ihdr = &elf_phdata[i]; |
... | ... | @@ -667,7 +700,7 @@ |
667 | 700 | |
668 | 701 | if (elf_interpreter) { |
669 | 702 | retval = verify_irix_interpreter(&interp_elf_ex); |
670 | - if(retval) | |
703 | + if (retval) | |
671 | 704 | goto out_free_interp; |
672 | 705 | } |
673 | 706 | |
674 | 707 | |
... | ... | @@ -706,12 +739,12 @@ |
706 | 739 | &load_addr, &start_code, &elf_bss, &end_code, |
707 | 740 | &end_data, &elf_brk); |
708 | 741 | |
709 | - if(elf_interpreter) { | |
742 | + if (elf_interpreter) { | |
710 | 743 | retval = map_interpreter(elf_phdata, &interp_elf_ex, |
711 | 744 | interpreter, &interp_load_addr, |
712 | 745 | elf_ex.e_phnum, old_fs, &elf_entry); |
713 | 746 | kfree(elf_interpreter); |
714 | - if(retval) { | |
747 | + if (retval) { | |
715 | 748 | set_fs(old_fs); |
716 | 749 | printk("Unable to load IRIX ELF interpreter\n"); |
717 | 750 | send_sig(SIGSEGV, current, 0); |
718 | 751 | |
... | ... | @@ -809,12 +842,12 @@ |
809 | 842 | return -ENOEXEC; |
810 | 843 | |
811 | 844 | /* First of all, some simple consistency checks. */ |
812 | - if(elf_ex.e_type != ET_EXEC || elf_ex.e_phnum > 2 || | |
845 | + if (elf_ex.e_type != ET_EXEC || elf_ex.e_phnum > 2 || | |
813 | 846 | !file->f_op->mmap) |
814 | 847 | return -ENOEXEC; |
815 | 848 | |
816 | 849 | /* Now read in all of the header information. */ |
817 | - if(sizeof(struct elf_phdr) * elf_ex.e_phnum > PAGE_SIZE) | |
850 | + if (sizeof(struct elf_phdr) * elf_ex.e_phnum > PAGE_SIZE) | |
818 | 851 | return -ENOEXEC; |
819 | 852 | |
820 | 853 | elf_phdata = kmalloc(sizeof(struct elf_phdr) * elf_ex.e_phnum, GFP_KERNEL); |
821 | 854 | |
822 | 855 | |
... | ... | @@ -825,15 +858,15 @@ |
825 | 858 | sizeof(struct elf_phdr) * elf_ex.e_phnum); |
826 | 859 | |
827 | 860 | j = 0; |
828 | - for(i=0; i<elf_ex.e_phnum; i++) | |
829 | - if((elf_phdata + i)->p_type == PT_LOAD) j++; | |
861 | + for (i=0; i<elf_ex.e_phnum; i++) | |
862 | + if ((elf_phdata + i)->p_type == PT_LOAD) j++; | |
830 | 863 | |
831 | - if(j != 1) { | |
864 | + if (j != 1) { | |
832 | 865 | kfree(elf_phdata); |
833 | 866 | return -ENOEXEC; |
834 | 867 | } |
835 | 868 | |
836 | - while(elf_phdata->p_type != PT_LOAD) elf_phdata++; | |
869 | + while (elf_phdata->p_type != PT_LOAD) elf_phdata++; | |
837 | 870 | |
838 | 871 | /* Now use mmap to map the library into memory. */ |
839 | 872 | down_write(¤t->mm->mmap_sem); |
840 | 873 | |
... | ... | @@ -889,9 +922,7 @@ |
889 | 922 | return -EFAULT; |
890 | 923 | } |
891 | 924 | |
892 | -#ifdef DEBUG | |
893 | 925 | dump_phdrs(user_phdrp, cnt); |
894 | -#endif | |
895 | 926 | |
896 | 927 | for (i = 0; i < cnt; i++, hp++) { |
897 | 928 | if (__get_user(type, &hp->p_type)) |
898 | 929 | |
... | ... | @@ -905,14 +936,14 @@ |
905 | 936 | filp = fget(fd); |
906 | 937 | if (!filp) |
907 | 938 | return -EACCES; |
908 | - if(!filp->f_op) { | |
939 | + if (!filp->f_op) { | |
909 | 940 | printk("irix_mapelf: Bogon filp!\n"); |
910 | 941 | fput(filp); |
911 | 942 | return -EACCES; |
912 | 943 | } |
913 | 944 | |
914 | 945 | hp = user_phdrp; |
915 | - for(i = 0; i < cnt; i++, hp++) { | |
946 | + for (i = 0; i < cnt; i++, hp++) { | |
916 | 947 | int prot; |
917 | 948 | |
918 | 949 | retval = __get_user(vaddr, &hp->p_vaddr); |
... | ... | @@ -1015,8 +1046,6 @@ |
1015 | 1046 | return sz; |
1016 | 1047 | } |
1017 | 1048 | |
1018 | -/* #define DEBUG */ | |
1019 | - | |
1020 | 1049 | #define DUMP_WRITE(addr, nr) \ |
1021 | 1050 | if (!dump_write(file, (addr), (nr))) \ |
1022 | 1051 | goto end_coredump; |
... | ... | @@ -1093,9 +1122,7 @@ |
1093 | 1122 | |
1094 | 1123 | segs++; |
1095 | 1124 | } |
1096 | -#ifdef DEBUG | |
1097 | - printk("irix_core_dump: %d segs taking %d bytes\n", segs, size); | |
1098 | -#endif | |
1125 | + pr_debug("irix_core_dump: %d segs taking %d bytes\n", segs, size); | |
1099 | 1126 | |
1100 | 1127 | /* Set up header. */ |
1101 | 1128 | memcpy(elf.e_ident, ELFMAG, SELFMAG); |
... | ... | @@ -1221,7 +1248,7 @@ |
1221 | 1248 | struct elf_phdr phdr; |
1222 | 1249 | int sz = 0; |
1223 | 1250 | |
1224 | - for(i = 0; i < numnote; i++) | |
1251 | + for (i = 0; i < numnote; i++) | |
1225 | 1252 | sz += notesize(¬es[i]); |
1226 | 1253 | |
1227 | 1254 | phdr.p_type = PT_NOTE; |
... | ... | @@ -1241,7 +1268,7 @@ |
1241 | 1268 | dataoff = offset = roundup(offset, PAGE_SIZE); |
1242 | 1269 | |
1243 | 1270 | /* Write program headers for segments dump. */ |
1244 | - for(vma = current->mm->mmap, i = 0; | |
1271 | + for (vma = current->mm->mmap, i = 0; | |
1245 | 1272 | i < segs && vma != NULL; vma = vma->vm_next) { |
1246 | 1273 | struct elf_phdr phdr; |
1247 | 1274 | size_t sz; |
... | ... | @@ -1267,7 +1294,7 @@ |
1267 | 1294 | DUMP_WRITE(&phdr, sizeof(phdr)); |
1268 | 1295 | } |
1269 | 1296 | |
1270 | - for(i = 0; i < numnote; i++) | |
1297 | + for (i = 0; i < numnote; i++) | |
1271 | 1298 | if (!writenote(¬es[i], file)) |
1272 | 1299 | goto end_coredump; |
1273 | 1300 | |
... | ... | @@ -1275,7 +1302,7 @@ |
1275 | 1302 | |
1276 | 1303 | DUMP_SEEK(dataoff); |
1277 | 1304 | |
1278 | - for(i = 0, vma = current->mm->mmap; | |
1305 | + for (i = 0, vma = current->mm->mmap; | |
1279 | 1306 | i < segs && vma != NULL; |
1280 | 1307 | vma = vma->vm_next) { |
1281 | 1308 | unsigned long addr = vma->vm_start; |
... | ... | @@ -1284,9 +1311,7 @@ |
1284 | 1311 | if (!maydump(vma)) |
1285 | 1312 | continue; |
1286 | 1313 | i++; |
1287 | -#ifdef DEBUG | |
1288 | - printk("elf_core_dump: writing %08lx %lx\n", addr, len); | |
1289 | -#endif | |
1314 | + pr_debug("elf_core_dump: writing %08lx %lx\n", addr, len); | |
1290 | 1315 | DUMP_WRITE((void __user *)addr, len); |
1291 | 1316 | } |
1292 | 1317 |