]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/genmod.sh.in: Rewrite the Apple part.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 29 Feb 2012 15:00:27 +0000 (16:00 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 29 Feb 2012 15:00:27 +0000 (16:00 +0100)
ChangeLog
grub-core/genmod.sh.in

index d1285e37869a96ffdea119189c6a43b03a7c19c1..391e62658e5194df26ced348277271ef128f392e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2012-02-29  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/genmod.sh.in: Rewrite the Apple part.
+
 2012-02-29  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/loader/machoXX.c (grub_macho_load): Fix signed vs unsigned
index 4411c6b1bba954f5952161883951964369d33580..62a64ffa6f1f0e2f9a71d50aa68a42fbf954c9bc 100644 (file)
@@ -35,24 +35,24 @@ 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
+if test x@TARGET_APPLE_CC@ != x1; then
+    # stripout .modname and .moddeps sections from input module
+    @OBJCOPY@ -R .modname -R .moddeps $infile $tmpfile
 
-# Attach .modname and .moddeps sections
-t1=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
-printf "$modname\0" >$t1
+    # Attach .modname and .moddeps sections
+    t1=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
+    printf "$modname\0" >$t1
 
-t2=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
-for dep in $deps; do printf "$dep\0" >> $t2; done
+    t2=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
+    for dep in $deps; do printf "$dep\0" >> $t2; done
 
-if test -n "$deps"; then
+    if test -n "$deps"; then
        @OBJCOPY@ --add-section .modname=$t1 --add-section .moddeps=$t2 $tmpfile
-else
+    else
        @OBJCOPY@ --add-section .modname=$t1 $tmpfile
-fi
-rm -f $t1 $t2
+    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
@@ -63,12 +63,33 @@ if test x@TARGET_APPLE_CC@ != x1; then
                -R .note.GNU-stack -R .note -R .comment $tmpfile || exit 1
        fi
 else
-# XXX Test these Apple CC fixes
+    tmpfile2=${outfile}.tmp2
+    t1=${outfile}.t1.c
+    t2=${outfile}.t2.c
+
+    # remove old files if any
+    rm -f $t1 $t2
+
+    cp $infile $tmpfile
+
+    # Attach .modname and .moddeps sections
+    echo "char modname[]  __attribute__ ((section(\"_modname, _modname\"))) = \"$modname\";" >$t1
+
+    for dep in $deps; do echo "char moddep_$dep[] __attribute__ ((section(\"_moddeps, _moddeps\"))) = \"$dep\";" >$t2; done
+
+    if test -n "$deps"; then
+       @TARGET_CC@ @TARGET_LDFLAGS@ -ffreestanding -nostdlib -o $tmpfile2 $t1 $t2 $tmpfile -Wl,-r,-d
+    else
+       @TARGET_CC@ @TARGET_LDFLAGS@ -ffreestanding -nostdlib -o $tmpfile2 $t1 $tmpfile -Wl,-r,-d
+    fi
+    rm -f $t1 $t2 $tmpfile
+    mv $tmpfile2 $tmpfile
+
        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
+           -wd1106 -ew2030 -ew2050 -ew2031 -nu -nd $tmpfile.bin $tmpfile || exit 1
        rm -f $name.bin
 fi
 mv $tmpfile $outfile