Convert a chunk of usage.h to USE_ and SKIP_ (more to do there), and fix a
[oweals/busybox.git] / modutils / insmod.c
index 26dd9783b74d0f96ad51f23c9efd35b68bc703e5..f38daa257cc24e0e8837f022d08427e9c5989d17 100644 (file)
  *   Restructured (and partly rewritten) by:
  *   Björn Ekwall <bj0rn@blox.se> February 1999
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
 
 #include <stdlib.h>
@@ -516,12 +503,6 @@ int delete_module(const char *);
 #include <elf.h>
 #include <endian.h>
 
-#if BB_LITTLE_ENDIAN
-# define ELFDATAM      ELFDATA2LSB
-#else
-# define ELFDATAM      ELFDATA2MSB
-#endif
-
 #ifndef ElfW
 # if ELFCLASSM == ELFCLASS32
 #  define ElfW(x)  Elf32_ ## x
@@ -687,9 +668,9 @@ static enum obj_reloc arch_apply_relocation (struct obj_file *f,
                                      ElfW(RelM) *rel, ElfW(Addr) value);
 
 static void arch_create_got (struct obj_file *f);
-
+#if ENABLE_FEATURE_CHECK_TAINTED_MODULE
 static int obj_gpl_license(struct obj_file *f, const char **license);
-
+#endif /* ENABLE_FEATURE_CHECK_TAINTED_MODULE */
 #endif /* obj.h */
 //----------------------------------------------------------------------------
 //--------end of modutils obj.h
@@ -3331,7 +3312,8 @@ static struct obj_file *obj_load(FILE * fp, int loadprogbits)
                return NULL;
        }
        if (f->header.e_ident[EI_CLASS] != ELFCLASSM
-                       || f->header.e_ident[EI_DATA] != ELFDATAM
+                       || f->header.e_ident[EI_DATA] != (BB_BIG_ENDIAN
+                               ? ELFDATA2MSB : ELFDATA2LSB)
                        || f->header.e_ident[EI_VERSION] != EV_CURRENT
                        || !MATCH_MACHINE(f->header.e_machine)) {
                bb_error_msg("ELF file not for this architecture");
@@ -4302,9 +4284,7 @@ int insmod_ng_main( int argc, char **argv)
                strcat(options, " ");
        }
 
-       if ((fd = open(filename, O_RDONLY, 0)) < 0) {
-               bb_perror_msg_and_die("cannot open module `%s'", filename);
-       }
+       fd = bb_xopen3(filename, O_RDONLY, 0);
 
        fstat(fd, &st);
        len = st.st_size;