1515 along with this program; if not, write to the Free Software
1616 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1717*/
18+
19+ #define pr_fmt (fmt ) KBUILD_MODNAME ": " fmt
20+
1821#include <linux/module.h>
1922#include <linux/elf.h>
2023#include <linux/moduleloader.h>
3639 Using a magic allocator which places modules within 32MB solves
3740 this, and makes other things simpler. Anton?
3841 --RR. */
39- #if 0
40- #define DEBUGP printk
41- #else
42- #define DEBUGP (fmt , ...)
43- #endif
4442
4543#if defined(_CALL_ELF ) && _CALL_ELF == 2
4644#define R2_STACK_OFFSET 24
@@ -279,8 +277,8 @@ static unsigned long get_stubs_size(const Elf64_Ehdr *hdr,
279277 /* Every relocated section... */
280278 for (i = 1 ; i < hdr -> e_shnum ; i ++ ) {
281279 if (sechdrs [i ].sh_type == SHT_RELA ) {
282- DEBUGP ("Found relocations in section %u\n" , i );
283- DEBUGP ("Ptr: %p. Number: %lu \n" ,
280+ pr_debug ("Found relocations in section %u\n" , i );
281+ pr_debug ("Ptr: %p. Number: %Lu \n" ,
284282 (void * )sechdrs [i ].sh_addr ,
285283 sechdrs [i ].sh_size / sizeof (Elf64_Rela ));
286284
@@ -304,7 +302,7 @@ static unsigned long get_stubs_size(const Elf64_Ehdr *hdr,
304302 relocs ++ ;
305303#endif
306304
307- DEBUGP ("Looks like a total of %lu stubs, max\n" , relocs );
305+ pr_debug ("Looks like a total of %lu stubs, max\n" , relocs );
308306 return relocs * sizeof (struct ppc64_stub_entry );
309307}
310308
@@ -390,7 +388,7 @@ int module_frob_arch_sections(Elf64_Ehdr *hdr,
390388 }
391389
392390 if (!me -> arch .stubs_section ) {
393- printk ("%s: doesn't contain .stubs.\n" , me -> name );
391+ pr_err ("%s: doesn't contain .stubs.\n" , me -> name );
394392 return - ENOEXEC ;
395393 }
396394
@@ -434,11 +432,11 @@ static inline int create_stub(Elf64_Shdr *sechdrs,
434432 /* Stub uses address relative to r2. */
435433 reladdr = (unsigned long )entry - my_r2 (sechdrs , me );
436434 if (reladdr > 0x7FFFFFFF || reladdr < - (0x80000000L )) {
437- printk ("%s: Address %p of stub out of range of %p.\n" ,
435+ pr_err ("%s: Address %p of stub out of range of %p.\n" ,
438436 me -> name , (void * )reladdr , (void * )my_r2 );
439437 return 0 ;
440438 }
441- DEBUGP ("Stub %p get data from reladdr %li\n" , entry , reladdr );
439+ pr_debug ("Stub %p get data from reladdr %li\n" , entry , reladdr );
442440
443441 entry -> jump [0 ] |= PPC_HA (reladdr );
444442 entry -> jump [1 ] |= PPC_LO (reladdr );
@@ -477,7 +475,7 @@ static unsigned long stub_for_addr(Elf64_Shdr *sechdrs,
477475static int restore_r2 (u32 * instruction , struct module * me )
478476{
479477 if (* instruction != PPC_INST_NOP ) {
480- printk ("%s: Expect noop after relocate, got %08x\n" ,
478+ pr_err ("%s: Expect noop after relocate, got %08x\n" ,
481479 me -> name , * instruction );
482480 return 0 ;
483481 }
@@ -498,7 +496,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
498496 unsigned long * location ;
499497 unsigned long value ;
500498
501- DEBUGP ("Applying ADD relocate section %u to %u\n" , relsec ,
499+ pr_debug ("Applying ADD relocate section %u to %u\n" , relsec ,
502500 sechdrs [relsec ].sh_info );
503501
504502 /* First time we're called, we can fix up .TOC. */
@@ -519,7 +517,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
519517 sym = (Elf64_Sym * )sechdrs [symindex ].sh_addr
520518 + ELF64_R_SYM (rela [i ].r_info );
521519
522- DEBUGP ("RELOC at %p: %li-type as %s (%lu ) + %li\n" ,
520+ pr_debug ("RELOC at %p: %li-type as %s (0x%lx ) + %li\n" ,
523521 location , (long )ELF64_R_TYPE (rela [i ].r_info ),
524522 strtab + sym -> st_name , (unsigned long )sym -> st_value ,
525523 (long )rela [i ].r_addend );
@@ -546,7 +544,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
546544 /* Subtract TOC pointer */
547545 value -= my_r2 (sechdrs , me );
548546 if (value + 0x8000 > 0xffff ) {
549- printk ("%s: bad TOC16 relocation (%lu )\n" ,
547+ pr_err ("%s: bad TOC16 relocation (0x%lx )\n" ,
550548 me -> name , value );
551549 return - ENOEXEC ;
552550 }
@@ -567,7 +565,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
567565 /* Subtract TOC pointer */
568566 value -= my_r2 (sechdrs , me );
569567 if ((value & 3 ) != 0 || value + 0x8000 > 0xffff ) {
570- printk ("%s: bad TOC16_DS relocation (%lu )\n" ,
568+ pr_err ("%s: bad TOC16_DS relocation (0x%lx )\n" ,
571569 me -> name , value );
572570 return - ENOEXEC ;
573571 }
@@ -580,7 +578,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
580578 /* Subtract TOC pointer */
581579 value -= my_r2 (sechdrs , me );
582580 if ((value & 3 ) != 0 ) {
583- printk ("%s: bad TOC16_LO_DS relocation (%lu )\n" ,
581+ pr_err ("%s: bad TOC16_LO_DS relocation (0x%lx )\n" ,
584582 me -> name , value );
585583 return - ENOEXEC ;
586584 }
@@ -613,7 +611,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
613611 /* Convert value to relative */
614612 value -= (unsigned long )location ;
615613 if (value + 0x2000000 > 0x3ffffff || (value & 3 ) != 0 ){
616- printk ("%s: REL24 %li out of range!\n" ,
614+ pr_err ("%s: REL24 %li out of range!\n" ,
617615 me -> name , (long int )value );
618616 return - ENOEXEC ;
619617 }
@@ -655,7 +653,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
655653 break ;
656654
657655 default :
658- printk ("%s: Unknown ADD relocation: %lu\n" ,
656+ pr_err ("%s: Unknown ADD relocation: %lu\n" ,
659657 me -> name ,
660658 (unsigned long )ELF64_R_TYPE (rela [i ].r_info ));
661659 return - ENOEXEC ;
0 commit comments