@@ -374,6 +374,7 @@ calc_reloc(unsigned long r, struct lib_info *p, int curid, int internalp)
374374
375375/****************************************************************************/
376376
377+ #ifdef CONFIG_BINFMT_FLAT_OLD
377378static void old_reloc (unsigned long rl )
378379{
379380 static const char * segment [] = { "TEXT" , "DATA" , "BSS" , "*UNKNOWN*" };
@@ -411,6 +412,7 @@ static void old_reloc(unsigned long rl)
411412
412413 pr_debug ("Relocation became %lx\n" , val );
413414}
415+ #endif /* CONFIG_BINFMT_FLAT_OLD */
414416
415417/****************************************************************************/
416418
@@ -461,6 +463,7 @@ static int load_flat_file(struct linux_binprm *bprm,
461463 if (flags & FLAT_FLAG_KTRACE )
462464 pr_info ("Loading file: %s\n" , bprm -> filename );
463465
466+ #ifdef CONFIG_BINFMT_FLAT_OLD
464467 if (rev != FLAT_VERSION && rev != OLD_FLAT_VERSION ) {
465468 pr_err ("bad flat file version 0x%x (supported 0x%lx and 0x%lx)\n" ,
466469 rev , FLAT_VERSION , OLD_FLAT_VERSION );
@@ -476,6 +479,23 @@ static int load_flat_file(struct linux_binprm *bprm,
476479 goto err ;
477480 }
478481
482+ /*
483+ * fix up the flags for the older format, there were all kinds
484+ * of endian hacks, this only works for the simple cases
485+ */
486+ if (rev == OLD_FLAT_VERSION &&
487+ (flags || IS_ENABLED (CONFIG_BINFMT_FLAT_OLD_ALWAYS_RAM )))
488+ flags = FLAT_FLAG_RAM ;
489+
490+ #else /* CONFIG_BINFMT_FLAT_OLD */
491+ if (rev != FLAT_VERSION ) {
492+ pr_err ("bad flat file version 0x%x (supported 0x%lx)\n" ,
493+ rev , FLAT_VERSION );
494+ ret = - ENOEXEC ;
495+ goto err ;
496+ }
497+ #endif /* !CONFIG_BINFMT_FLAT_OLD */
498+
479499 /*
480500 * Make sure the header params are sane.
481501 * 28 bits (256 MB) is way more than reasonable in this case.
@@ -487,14 +507,6 @@ static int load_flat_file(struct linux_binprm *bprm,
487507 goto err ;
488508 }
489509
490- /*
491- * fix up the flags for the older format, there were all kinds
492- * of endian hacks, this only works for the simple cases
493- */
494- if (rev == OLD_FLAT_VERSION &&
495- (flags || IS_ENABLED (CONFIG_BINFMT_FLAT_OLD_ALWAYS_RAM )))
496- flags = FLAT_FLAG_RAM ;
497-
498510#ifndef CONFIG_BINFMT_ZFLAT
499511 if (flags & (FLAT_FLAG_GZIP |FLAT_FLAG_GZDATA )) {
500512 pr_err ("Support for ZFLAT executables is not enabled.\n" );
@@ -833,13 +845,15 @@ static int load_flat_file(struct linux_binprm *bprm,
833845 goto err ;
834846 }
835847 }
848+ #ifdef CONFIG_BINFMT_FLAT_OLD
836849 } else {
837850 for (i = 0 ; i < relocs ; i ++ ) {
838851 __be32 relval ;
839852 if (get_user (relval , reloc + i ))
840853 return - EFAULT ;
841854 old_reloc (ntohl (relval ));
842855 }
856+ #endif /* CONFIG_BINFMT_FLAT_OLD */
843857 }
844858
845859 flush_icache_range (start_code , end_code );
0 commit comments