~ubuntu-branches/ubuntu/trusty/grub2/trusty-updates

« back to all changes in this revision

Viewing changes to grub-core/genmod.sh.in

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-09-13 18:02:04 UTC
  • mfrom: (1.17.15 upstream)
  • mto: (17.6.27 experimental)
  • mto: This revision was merged to the branch mainline in revision 145.
  • Revision ID: package-import@ubuntu.com-20120913180204-mojnmocbimlom4im
Tags: upstream-2.00
ImportĀ upstreamĀ versionĀ 2.00

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh -e
2
 
#
 
1
#! /bin/sh
 
2
set -e
 
3
 
3
4
# Copyright (C) 2010 Free Software Foundation, Inc.
4
5
#
5
6
# This gensymlist.sh is free software; the author
34
35
# remove old files if any
35
36
rm -f $tmpfile $outfile
36
37
 
37
 
# stripout .modname and .moddeps sections from input module
38
 
@OBJCOPY@ -R .modname -R .moddeps $infile $tmpfile
39
 
 
40
 
# Attach .modname and .moddeps sections
41
 
t1=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
42
 
printf "$modname\0" >$t1
43
 
 
44
 
t2=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
45
 
for dep in $deps; do printf "$dep\0" >> $t2; done
46
 
 
47
 
if test -n "$deps"; then
 
38
if test x@TARGET_APPLE_CC@ != x1; then
 
39
    # stripout .modname and .moddeps sections from input module
 
40
    @OBJCOPY@ -R .modname -R .moddeps $infile $tmpfile
 
41
 
 
42
    # Attach .modname and .moddeps sections
 
43
    t1=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
 
44
    printf "$modname\0" >$t1
 
45
 
 
46
    t2=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1
 
47
    for dep in $deps; do printf "$dep\0" >> $t2; done
 
48
 
 
49
    if test -n "$deps"; then
48
50
        @OBJCOPY@ --add-section .modname=$t1 --add-section .moddeps=$t2 $tmpfile
49
 
else
 
51
    else
50
52
        @OBJCOPY@ --add-section .modname=$t1 $tmpfile
51
 
fi
52
 
rm -f $t1 $t2
 
53
    fi
 
54
    rm -f $t1 $t2
53
55
 
54
 
if test x@TARGET_APPLE_CC@ != x1; then
55
56
        if ! test -z "${TARGET_OBJ2ELF}"; then
56
57
            ./${TARGET_OBJ2ELF} $tmpfile || exit 1
57
58
        fi
59
60
            @STRIP@ --strip-unneeded \
60
61
                -K grub_mod_init -K grub_mod_fini \
61
62
                -K _grub_mod_init -K _grub_mod_fini \
 
63
                -R .note.gnu.gold-version -R .note.GNU-stack \
62
64
                -R .note -R .comment $tmpfile || exit 1
63
65
        fi
64
66
else
65
 
# XXX Test these Apple CC fixes
 
67
    tmpfile2=${outfile}.tmp2
 
68
    t1=${outfile}.t1.c
 
69
    t2=${outfile}.t2.c
 
70
 
 
71
    # remove old files if any
 
72
    rm -f $t1 $t2
 
73
 
 
74
    cp $infile $tmpfile
 
75
 
 
76
    # Attach .modname and .moddeps sections
 
77
    echo "char modname[]  __attribute__ ((section(\"_modname, _modname\"))) = \"$modname\";" >$t1
 
78
 
 
79
    for dep in $deps; do echo "char moddep_$dep[] __attribute__ ((section(\"_moddeps, _moddeps\"))) = \"$dep\";" >>$t2; done
 
80
 
 
81
    if test -n "$deps"; then
 
82
        @TARGET_CC@ @TARGET_LDFLAGS@ -ffreestanding -nostdlib -o $tmpfile2 $t1 $t2 $tmpfile -Wl,-r,-d
 
83
    else
 
84
        @TARGET_CC@ @TARGET_LDFLAGS@ -ffreestanding -nostdlib -o $tmpfile2 $t1 $tmpfile -Wl,-r,-d
 
85
    fi
 
86
    rm -f $t1 $t2 $tmpfile
 
87
    mv $tmpfile2 $tmpfile
 
88
 
66
89
        cp $tmpfile $tmpfile.bin
67
90
        @OBJCONV@ -f@TARGET_MODULE_FORMAT@ \
68
91
            -nr:_grub_mod_init:grub_mod_init \
69
92
            -nr:_grub_mod_fini:grub_mod_fini \
70
 
            -wd1106 -ew2030 -ew2050 -nu -nd $tmpfile.bin $tmpfile || exit 1
 
93
            -wd1106 -nu -nd $tmpfile.bin $tmpfile || exit 1
71
94
        rm -f $name.bin
72
95
fi
73
96
mv $tmpfile $outfile