Sparc patch for modutils-2.3.6
Hi!
Attached is a merger of my modutils 2.1.121 SPARC patch with modutils 2.3.6.
By default it will compile insmod, depmod and modinfo binaries which will be able to handle both 32bit and 64bit modules on SPARC.
If you don't want that and e.g. want a somewhat smaller insmod &tc., just pass configure
--disable-combined-sparc
The advantage is of course that the /sbin/insmod64 hack is gone, not to say that modinfo did not work previously (is fixed in RedHat 6.1 though).
Enjoy :)
Cheers,
Jakub
___________________________________________________________________
Jakub Jelinek | [email protected] | http://sunsite.mff.cuni.cz/~jj
Linux version 2.3.18 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________
ChangeLog renamed from ChangeLog.jj +7 -0
@@ -1,3 +1,10 @@ +1999-11-16 Jakub Jelinek <[email protected]> + + * --enable-combined-sparc support (default on sparc and sparc64), + which compiles executables handling both 32bit and 64bit SPARC + modules + * fixes a few issues with SPARC 64bit support by a 32bit binary + 1999-10-18 Keith Owens <[email protected]> modutils 2.3.6
obj/Makefile.in renamed from obj/Makefile.in.jj +15 -4
@@ -12,8 +12,8 @@ CC = @CC@ CFLAGS = @CFLAGS@ -Wall RANLIB = @RANLIB@ -DEFS = -I$(srcdir)/../include -D_GNU_SOURCE @DEFS@ -DEFS += -DELF_MACHINE_H='"elf_$(ARCH).h"' -DARCH_$(ARCH) $(EXTRA_DEFS) +DEFSNOARCH = -I$(srcdir)/../include -D_GNU_SOURCE @DEFS@ $(EXTRA_DEFS) +DEFS = $(DEFSNOARCH) -DELF_MACHINE_H='"elf_$(ARCH).h"' -DARCH_$(ARCH) %.o: %.c $(CC) $(CFLAGS) $(DEFS) -c -o $@ $<
@@ -22,7 +22,18 @@ DEFS += -DELF_MACHINE_H='"elf_$(ARCH).h" all: .depend libobj.a -LIBOBJ_OBJS = obj_common.o obj_load.o obj_reloc.o obj_$(ARCH).o +LIBOBJ_OBJS := obj_common.o obj_load.o obj_reloc.o obj_$(ARCH).o +LIBOBJ_SRCS := $(LIBOBJ_OBJS:.o=.c) + +ifeq (@COMBINE_sparc@,yes) + +LIBOBJ_OBJS += obj_common_64.o obj_load_64.o obj_reloc_64.o obj_sparc64_64.o + +%_64.o: %.c + $(CC) $(CFLAGS) $(DEFSNOARCH) -DELF_MACHINE_H='"elf_sparc64.h"' \ + -DARCH_sparc64 -c -o $@ $< + +endif libobj.a: $(LIBOBJ_OBJS) ar rv $@ $?
@@ -39,7 +50,7 @@ distclean: realclean install-bin: all -dep depend .depend: $(LIBOBJ_OBJS:.o=.c) +dep depend .depend: $(LIBOBJ_SRCS) $(CC) -M $(CFLAGS) $(DEFS) $^ > .depend ifeq (.depend,$(wildcard .depend))
obj/obj_reloc.c renamed from obj/obj_reloc.c.jj +4 -4
@@ -34,7 +34,7 @@ int obj_string_patch(struct obj_file *f, int secidx, ElfW(Addr) offset, const char *string) { - struct obj_string_patch *p; + struct obj_string_patch_struct *p;struct obj_section *strsec;size_t len =strlen (string)+1 ;char *loc;
@@ -66,7 +66,7 @@ int obj_symbol_patch(struct obj_file *f, int secidx, ElfW(Addr) offset, struct obj_symbol *sym) { - struct obj_symbol_patch *p; + struct obj_symbol_patch_struct *p; p =xmalloc (sizeof (*p)); p->next = f->symbol_patches;
@@ -366,7 +366,7 @@ obj_relocate (struct obj_file *f, ElfW(Aif (f->string_patches) { -struct obj_string_patch *p; +struct obj_string_patch_struct *p;struct obj_section *strsec;ElfW (Addr) strsec_base; strsec =obj_find_section (f,".kstrtab" );
@@ -382,7 +382,7 @@ obj_relocate (struct obj_file *f, ElfW(Aif (f->symbol_patches) { -struct obj_symbol_patch *p; +struct obj_symbol_patch_struct *p;for (p = f->symbol_patches; p; p = p->next) {
insmod/insmod.c renamed from insmod/insmod.c.jj +42 -12
101 lines not on this page · raw message
insmod/Makefile.in renamed from insmod/Makefile.in.jj +23 -6
@@ -13,8 +13,8 @@ CFLAGS = @CFLAGS@ -Wall LDFLAGS = @LDFLAGS@ INSTALL = @INSTALL@ -DEFS = -I$(srcdir)/../include -D_GNU_SOURCE @DEFS@ -DEFS += -DELF_MACHINE_H='"elf_$(ARCH).h"' -DARCH_$(ARCH) $(EXTRA_DEFS) +DEFSNOARCH = -I$(srcdir)/../include -D_GNU_SOURCE @DEFS@ $(EXTRA_DEFS) +DEFS = $(DEFSNOARCH) -DELF_MACHINE_H='"elf_$(ARCH).h"' -DARCH_$(ARCH) TARGETS = insmod modprobe rmmod lsmod ksyms modinfo
@@ -23,12 +23,29 @@ COMB = @COMBINE_rmmod@ @COMBINE_modprobe COMBDEFS = $(addprefix -DCOMBINE_, $(COMB)) COMBOBJS = $(addsuffix .o, $(COMB)) +INSMODOBJS = insmod.o +MODINFOOBJS = modinfo.o + +ifeq (@COMBINE_sparc@,yes) +INSMODOBJS += insmod_64.o +MODINFOOBJS += modinfo_64.o +DEFSNOARCH += -DCOMBINE_sparc +endif + +INSMODOBJS += $(COMBOBJS) + #===================================================================== # Rule for building "to-be-combined" modutils object files %.o: %.c $(CC) $(CFLAGS) $(DEFS) $(COMBDEFS) -c -o $@ $< +ifeq (@COMBINE_sparc@,yes) +%_64.o: %.c + $(CC) $(CFLAGS) $(DEFSNOARCH) -DELF_MACHINE_H='"elf_sparc64.h"' \ + -DARCH_sparc64 $(COMBDEFS) -c -o $@ $< +endif + # Rule for building "normal" modutils executables (non-combined) %: %.c ../util/libutil.a $(CC) $(CFLAGS) $(DEFS) -o $@ $< ../util/libutil.a $(LDFLAGS)
@@ -37,17 +54,17 @@ COMBOBJS = $(addsuffix .o, $(COMB)) all: .depend $(TARGETS) -insmod: insmod.o $(COMBOBJS) ../obj/libobj.a ../util/libutil.a +insmod: $(INSMODOBJS) ../obj/libobj.a ../util/libutil.a $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) -insmod.static: insmod.o $(COMBOBJS) ../obj/libobj.a ../util/libutil.a +insmod.static: $(INSMODOBJS) ../obj/libobj.a ../util/libutil.a $(CC) -static $(CFLAGS) -o $@ $^ $(LDFLAGS) $(COMB): insmod ln -sf $^ $@ -modinfo: modinfo.c ../obj/libobj.a ../util/libutil.a - $(CC) $(CFLAGS) $(DEFS) -o $@ $^ $(LDFLAGS) +modinfo: $(MODINFOOBJS) ../obj/libobj.a ../util/libutil.a + $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) install install-bin: all @set -x;\
insmod/modinfo.c renamed from insmod/modinfo.c.jj +27 -0
@@ -37,6 +37,7 @@#include <unistd.h> #include <sys/param.h> #include <sys/stat.h> +#include <sys/utsname.h> #include "module.h" #include "obj.h"
@@ -44,6 +45,14 @@#include "version.h" #include "config.h" +#if defined(COMBINE_sparc) +#if defined(ARCH_sparc) +#define main modinfo32_main +#elif defined(ARCH_sparc64) +#define main modinfo64_main +#endif +#endif +static char *get_modinfo_value (struct obj_file *f,const char *key) {struct obj_section *sec;
@@ -363,3 +372,21 @@ int main(int argc, char *argv[])return 0 ; } + +#if defined(COMBINE_sparc) && defined(ARCH_sparc) + +#undef main + +extern int modinfo64_main (int argc,char **argv); + +int +main (int argc,char **argv) +{ +struct utsname u; + +if (!uname (&u) && !strcmp (u.machine,"sparc64" )) +return modinfo64_main (argc, argv); +else +return modinfo32_main (argc, argv); +} +#endif
include/obj.h renamed from include/obj.h.jj +48 -9
94 lines not on this page · raw message
include/modstat.h renamed from include/modstat.h.jj +1 -1
@@ -28,7 +28,7 @@struct module_stat {char *name; -ElfW (Addr) addr; +unsigned long addr;unsigned long modstruct;/* COMPAT_2_0! *//* depends on architecture? */ unsigned long size;unsigned long flags;
depmod/depmod.c renamed from depmod/depmod.c.jj +27 -0
@@ -45,6 +45,7 @@#include <syslog.h> #include <elf.h> #include ELF_MACHINE_H +#include <sys/utsname.h> #include "module.h" #include "version.h"
@@ -53,6 +54,14 @@#include "config.h" #include "modstat.h" +#if defined(COMBINE_sparc) +#if defined(ARCH_sparc) +#define main depmod32_main +#elif defined(ARCH_sparc64) +#define main depmod64_main +#endif +#endif +#define ALLOC_MODULE 5000/* Number of modules we can handle... */ #define ALLOC_SYM 10000/* Number of symbols allocated per chunk */
@@ -699,3 +708,21 @@ int main(int argc, char *argv[])return ret; } + +#if defined(COMBINE_sparc) && defined(ARCH_sparc) + +#undef main + +extern int depmod64_main (int argc,char **argv); + +int +main (int argc,char **argv) +{ +struct utsname u; + +if (!uname (&u) && !strcmp (u.machine,"sparc64" )) +return depmod64_main (argc, argv); +else +return depmod32_main (argc, argv); +} +#endif
depmod/Makefile.in renamed from depmod/Makefile.in.jj +13 -5
@@ -13,16 +13,24 @@ CFLAGS = @CFLAGS@ -Wall LDFLAGS = @LDFLAGS@ INSTALL = @INSTALL@ -DEFS = -I$(srcdir)/../include -D_GNU_SOURCE @DEFS@ -DEFS += -DELF_MACHINE_H='"elf_$(ARCH).h"' -DARCH_$(ARCH) $(EXTRA_DEFS) +DEFSNOARCH = -I$(srcdir)/../include -D_GNU_SOURCE @DEFS@ $(EXTRA_DEFS) +DEFS = $(DEFSNOARCH) -DELF_MACHINE_H='"elf_$(ARCH).h"' -DARCH_$(ARCH) +OBJS = depmod.o + +ifeq (@COMBINE_sparc@,yes) +DEFSNOARCH += -DCOMBINE_sparc +OBJS += depmod_64.o + +%_64.o: %.c + $(CC) $(CFLAGS) $(DEFSNOARCH) -DELF_MACHINE_H='"elf_sparc64.h"' \ + -DARCH_sparc64 -c -o $@ $< +endif %.o: %.c $(CC) $(CFLAGS) $(DEFS) -c -o $@ $< ###################################################################### -OBJS = depmod.o - all: .depend depmod depmod: $(OBJS) ../util/libutil.a ../obj/libobj.a
@@ -41,7 +49,7 @@ distclean: realclean install install-bin: all $(INSTALL) depmod $(sbindir) -dep depend .depend: $(OBJS:.o=.c) +dep depend .depend: depmod.c $(CC) -M $(CFLAGS) $(DEFS) $^ > .depend ifeq (.depend,$(wildcard .depend))
configure.in renamed from configure.in.jj +25 -8
@@ -3,6 +3,31 @@ dnl $Id: configure.in 1.1 Wed, 25 Aug 19 AC_INIT(insmod/insmod.c) AC_PREFIX_DEFAULT(/usr) +AC_CANONICAL_SYSTEM + +case "$target_cpu" in + alpha*) ARCH=alpha ;; + i?86) ARCH=i386 ;; + arm*) ARCH=arm ;; + powerpc) ARCH=ppc ;; + *) ARCH=$target_cpu ;; +esac + +COMBINE_sparc=yes +AC_ARG_ENABLE(combined-sparc, +[ --enable-combined-sparc Make all the utilities work on both sparc32 and sparc64 as one executable (default on sparc)], +[if test "$enableval" = "yes"; then + COMBINE_sparc=yes + else + COMBINE_sparc=no +fi]) +case "$ARCH" in + sparc64) if test "$COMBINE_sparc" = "yes"; then ARCH="sparc"; fi ;; + sparc*) ;; + *) COMBINE_sparc=no ;; +esac +AC_SUBST(COMBINE_sparc) + AC_ARG_ENABLE(combined-rmmod, [ --enable-combined-rmmod Create insmod and rmmod as one executable (default)], [if test "$enableval" = "yes"; then
@@ -27,14 +52,6 @@ AC_ARG_ENABLE(compat-2-0, AC_DEFINE(COMPAT_2_0) fi],[AC_DEFINE(COMPAT_2_0)]) -AC_CANONICAL_SYSTEM -case "$target_cpu" in - alpha*) ARCH=alpha ;; - i?86) ARCH=i386 ;; - arm*) ARCH=arm ;; - powerpc) ARCH=ppc ;; - *) ARCH=$target_cpu ;; -esac AC_SUBST(ARCH) AC_PROG_CC
configure renamed from configure.jj +188 -102
592 lines not on this page · raw message