-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_yaboot_in_srcdir.sh
executable file
·93 lines (90 loc) · 1.72 KB
/
make_yaboot_in_srcdir.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
# $Id$
set -e
# set -x
obj_dir=`pwd`
tmp=
outputfile=
yabootconf=
do_addnote=false
until [ "$#" = "0" ] ; do
case "$1" in
--help|-h|--version)
echo "Relink yaboot and include a yaboot.conf into the boot binary."
echo "This is useful on CHRP when booting from 0x41 PReP partition and"
echo "more than one Linux installation on the same drive."
echo "Usage: ${0##*/} --configfile <yaboot.conf> --output <yaboot> [--tmp <tempdir>] [--addnote]"
exit 1
;;
--addnote)
do_addnote=true
shift
;;
--configfile)
shift
if [ "$#" = "0" -o "$1" = "" ] ; then
echo "option --configfile requires a filename"
exit 1
fi
yabootconf=$1
shift
;;
--output)
shift
if [ "$#" = "0" -o "$1" = "" ] ; then
echo "option --output requires a filename"
exit 1
fi
output=$1
shift
;;
--tmp)
shift
if [ "$#" = "0" -o "$1" = "" ] ; then
echo "option --tmp requires a diretory"
exit 1
fi
tmp=$1
shift
;;
*)
echo "ERROR: unknown option $1"
exec $0 --help
exit 1
esac
done
if [ -z "$yabootconf" ] ; then
echo "ERROR: no config file"
exec $0 --help
exit 1
fi
if [ -z "$tmp" ] ; then
tmp=`mktemp -d ${TMPDIR:-/tmp}/mkzimage_chrp.$$.XXXXXX`
else
tmp=`mktemp -d $tmp/mkzimage_chrp.$$.XXXXXX`
fi
#
cp $obj_dir/second/empty.o $tmp/empty.o
#
objcopy $tmp/empty.o \
--add-section=.yaboot.conf=$yabootconf \
--set-section-flags=.yaboot.conf=contents,alloc,load,readonly,data
#
rm -f $tmp/output
#
ld \
-m elf32ppc \
-T $obj_dir/ld.script \
-o $tmp/output \
$obj_dir/second/crt0.o \
$tmp/empty.o \
$obj_dir/second/yaboot.a
#
if [ "$do_addnote" = "true" ] ; then
echo add note section for RS6K
$obj_dir/util/addnote $tmp/output
fi
#
rm -f "$output"
cp "$tmp/output" "$output"
rm -rf $tmp