]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
use objcopy instead of creating mod-*.c and mod-*.o
authorBVK Chaitanya <bvk@dbook>
Sun, 29 Aug 2010 11:13:07 +0000 (16:43 +0530)
committerBVK Chaitanya <bvk@dbook>
Sun, 29 Aug 2010 11:13:07 +0000 (16:43 +0530)
gentpl.py
grub-core/Makefile.am
grub-core/Makefile.core.def
grub-core/genmod.sh.in [new file with mode: 0644]
grub-core/genmoddep.awk

index b153452cdf0e97fa5298686206868d4b4c0a600c..81b44316b9c5273a88cdb3ee859b29e06960bf73 100644 (file)
--- a/gentpl.py
+++ b/gentpl.py
@@ -285,31 +285,11 @@ def module(platform):
     r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)")
 
     r += gvar_add("MOD_FILES", "[+ name +].mod")
-    r += gvar_add("platform_DATA", "[+ name +].mod")
-    r += gvar_add("CLEANFILES", "def-[+ name +].lst und-[+ name +].lst mod-[+ name +].c mod-[+ name +].o [+ name +].mod")
-
     r += gvar_add("PP_FILES", "[+ name +].pp")
     r += gvar_add("CLEANFILES", "[+ name +].pp")
     r += """
 [+ name +].pp: $(""" + cname() + """_SOURCES) $(nodist_""" + cname() + """_SOURCES)
        $(TARGET_CPP) -DGRUB_LST_GENERATOR $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(""" + cname() + """_CPPFLAGS) $(CPPFLAGS) $^ > $@ || (rm -f $@; exit 1)
-
-mod-[+ name +].c: [+ name +].module$(EXEEXT) moddep.lst genmodsrc.sh
-       sh $(srcdir)/genmodsrc.sh [+ name +] moddep.lst > $@ || (rm -f $@; exit 1)
-
-mod-[+ name +].o: mod-[+ name +].c
-       $(TARGET_CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(""" + cname() + """_CPPFLAGS) $(CPPFLAGS) $(""" + cname() + """_CFLAGS) $(CFLAGS) -c -o $@ $<
-
-[+ name +].mod: [+ name +].module$(EXEEXT) mod-[+ name +].o
-       if test x$(USE_APPLE_CC_FIXES) = xyes; then \
-         $(CCLD) $(""" + cname() + """_LDFLAGS) $(LDFLAGS) -o $@.bin $^; \
-         $(OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -wd1106 -nu -nd $@.bin $@; \
-         rm -f $@.bin; \
-       else \
-         $(CCLD) -o $@ $(""" + cname() + """_LDFLAGS) $(LDFLAGS) $^; \
-         if test ! -z '$(TARGET_OBJ2ELF)'; then $(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi; \
-         $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -K _grub_mod_init -K _grub_mod_fini -R .note -R .comment $@; \
-       fi
 """
     return r
 
index d8b7dbc0f70253fadef6324823161ce08be9ad21..c277cd47e6ad78164595b77f20ef0472a4aad093 100644 (file)
@@ -346,6 +346,11 @@ moddep.lst: syminfo.lst genmoddep.awk
 platform_DATA += moddep.lst
 CLEANFILES += config.log syminfo.lst moddep.lst
 
+$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT)
+       sh $^ $@
+platform_DATA += $(MOD_FILES)
+CLEANFILES += $(MOD_FILES)
+
 if COND_i386_pc
 if COND_ENABLE_EFIEMU
 efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF)
index 5587f0f40ed60c28a3fc42fba2af01a41507293f..c852c344f8156238e0e26b04c5b87410ccc3110e 100644 (file)
@@ -1408,3 +1408,8 @@ script = {
   name = gensyminfo.sh;
   common = gensyminfo.sh.in;
 };
+
+script = {
+  name = genmod.sh;
+  common = genmod.sh.in;
+};
diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in
new file mode 100644 (file)
index 0000000..a267ca5
--- /dev/null
@@ -0,0 +1,73 @@
+#! /bin/sh -e
+#
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This gensymlist.sh is free software; the author
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+#
+# Example:
+#
+# genmod.sh moddep.lst normal.module echo.module
+#
+
+moddep=$1
+infile=$2
+outfile=$3
+
+tmpfile=${outfile}.tmp
+modname=`echo $infile | sed -e 's@\.module.*$@@'`
+
+if ! grep ^$modname: $moddep >/dev/null; then
+    echo "warning: moddep.lst has no dependencies for $modname" >&2
+    exit 0
+fi
+
+deps=`grep ^$modname: $moddep | sed s@^.*:@@`
+
+# remove old files if any
+rm -f $tmpfile $outfile
+
+# stripout .modname and .moddeps sections from input module
+objcopy -R .modname -R .moddeps $infile $tmpfile
+
+# Attach .modname and .moddeps sections
+t1=`mktemp`
+printf "$modname\0" >$t1
+
+t2=`mktemp`
+for dep in $deps; do printf "$dep\0" >> $t2; done
+
+if test -n "$deps"; then
+       objcopy --add-section .modname=$t1 --add-section .moddeps=$t2 $tmpfile
+else
+       objcopy --add-section .modname=$t1 $tmpfile
+fi
+rm -f $t1 $t2
+
+if test x@TARGET_APPLE_CC@ != x1; then
+       if ! test -z "@TARGET_OBJ2ELF@"; then
+           ./@TARGET_OBJ2ELF@ $tmpfile || exit 1
+       fi
+       if test x@platform@ != xemu; then
+           @STRIP@ --strip-unneeded \
+               -K grub_mod_init -K grub_mod_fini \
+               -K _grub_mod_init -K _grub_mod_fini \
+               -R .note -R .comment $tmpfile || exit 1
+       fi
+else
+# XXX Test these Apple CC fixes
+       cp $tmpfile $tmpfile.bin
+       @OBJCONV@ -f@TARGET_MODULE_FORMAT@ \
+           -nr:_grub_mod_init:grub_mod_init \
+           -nr:_grub_mod_fini:grub_mod_fini \
+           -wd1106 -ew2030 -ew2050 -nu -nd $tmpfile.bin $tmpfile || exit 1
+       rm -f $name.bin
+fi
+mv $tmpfile $outfile
index dfc9246667c225b3bed0f8cd01813133305f2b37..e412d437029f893ed8881cf1833d49f1d28c3b07 100644 (file)
@@ -17,9 +17,10 @@ BEGIN {
   lineno = 0;
   while (getline <"/dev/stdin") {
     lineno++;
-    if ($1 == "defined")
+    if ($1 == "defined") {
       symtab[$3] = $2;
-    else if ($1 == "undefined") {
+      modtab[$2] = "" modtab[$2]
+    } else if ($1 == "undefined") {
       if ($3 in symtab)
        modtab[$2] = modtab[$2] " " symtab[$3];
       else if ($3 != "__gnu_local_gp") {