blob: 404b3aabdb4dcda41e2e06f2b90d9c73b2b3fe39 [file] [log] [blame]
Paul Mackerras2bf11812006-09-27 22:47:03 +10001#!/bin/sh
2
3# Copyright (C) 2006 Paul Mackerras, IBM Corporation <paulus@samba.org>
4# This program may be used under the terms of version 2 of the GNU
5# General Public License.
6
7# This script takes a kernel binary and optionally an initrd image
8# and/or a device-tree blob, and creates a bootable zImage for a
9# given platform.
10
11# Options:
12# -o zImage specify output file
13# -p platform specify platform (links in $platform.o)
14# -i initrd specify initrd file
15# -d devtree specify device-tree blob
16# -s tree.dts specify device-tree source file (needs dtc installed)
17# -c cache $kernel.strip.gz (use if present & newer, else make)
18# -C prefix specify command prefix for cross-building tools
19# (strip, objcopy, ld)
20# -D dir specify directory containing data files used by script
21# (default ./arch/powerpc/boot)
22# -W dir specify working directory for temporary files (default .)
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +100023# -z use gzip (legacy)
24# -Z zsuffix compression to use (gz, xz or none)
Paul Mackerras2bf11812006-09-27 22:47:03 +100025
Grant Likelyd4740372007-10-23 14:27:36 +100026# Stop execution if any command fails
27set -e
28
Grant Likely7f66c1f2007-10-23 14:27:31 +100029# Allow for verbose output
30if [ "$V" = 1 ]; then
31 set -x
32fi
33
Paul Mackerras2bf11812006-09-27 22:47:03 +100034# defaults
35kernel=
36ofile=zImage
37platform=of
38initrd=
39dtb=
40dts=
41cacheit=
Scott Wood11c146c2007-09-14 14:58:25 -050042binary=
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +100043compression=.gz
Michael Ellerman6975a782011-04-12 20:38:55 +000044pie=
Cédric Le Goater147c0512014-04-24 09:23:39 +020045format=
Paul Mackerras2bf11812006-09-27 22:47:03 +100046
47# cross-compilation prefix
48CROSS=
49
Peter Tyser3f884bf2009-12-30 15:23:26 -070050# mkimage wrapper script
51MKIMAGE=$srctree/scripts/mkuboot.sh
52
Paul Mackerras2bf11812006-09-27 22:47:03 +100053# directory for object and other files used by this script
54object=arch/powerpc/boot
David Woodhouse5c539ee2007-12-03 13:52:05 +110055objbin=$object
Lucian Adrian Grijincuc79b2972009-07-23 00:13:37 +000056dtc=scripts/dtc/dtc
Paul Mackerras2bf11812006-09-27 22:47:03 +100057
58# directory for working files
59tmpdir=.
60
61usage() {
62 echo 'Usage: wrapper [-o output] [-p platform] [-i initrd]' >&2
63 echo ' [-d devtree] [-s tree.dts] [-c] [-C cross-prefix]' >&2
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +100064 echo ' [-D datadir] [-W workingdir] [-Z (gz|xz|none)]' >&2
65 echo ' [--no-compression] [vmlinux]' >&2
Paul Mackerras2bf11812006-09-27 22:47:03 +100066 exit 1
67}
68
Geoff Levand879c26d2015-10-19 10:53:26 -070069run_cmd() {
70 if [ "$V" = 1 ]; then
71 $* 2>&1
72 else
73 local msg
74
75 set +e
76 msg=$($* 2>&1)
77
78 if [ $? -ne "0" ]; then
79 echo $msg
80 exit 1
81 fi
82 set -e
83 fi
84}
85
Paul Mackerras2bf11812006-09-27 22:47:03 +100086while [ "$#" -gt 0 ]; do
87 case "$1" in
88 -o)
89 shift
90 [ "$#" -gt 0 ] || usage
91 ofile="$1"
92 ;;
93 -p)
94 shift
95 [ "$#" -gt 0 ] || usage
96 platform="$1"
97 ;;
98 -i)
99 shift
100 [ "$#" -gt 0 ] || usage
101 initrd="$1"
102 ;;
103 -d)
104 shift
105 [ "$#" -gt 0 ] || usage
106 dtb="$1"
107 ;;
108 -s)
109 shift
110 [ "$#" -gt 0 ] || usage
111 dts="$1"
112 ;;
113 -c)
114 cacheit=y
115 ;;
116 -C)
117 shift
118 [ "$#" -gt 0 ] || usage
119 CROSS="$1"
120 ;;
121 -D)
122 shift
123 [ "$#" -gt 0 ] || usage
124 object="$1"
David Woodhouse5c539ee2007-12-03 13:52:05 +1100125 objbin="$1"
Paul Mackerras2bf11812006-09-27 22:47:03 +1000126 ;;
127 -W)
128 shift
129 [ "$#" -gt 0 ] || usage
130 tmpdir="$1"
131 ;;
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000132 -z)
133 compression=.gz
134 ;;
135 -Z)
136 shift
137 [ "$#" -gt 0 ] || usage
138 [ "$1" != "gz" -o "$1" != "xz" -o "$1" != "none" ] || usage
139
140 compression=".$1"
141
142 if [ $compression = ".none" ]; then
143 compression=
144 fi
145 ;;
Scott Wooda9903812007-03-16 12:27:59 -0500146 --no-gzip)
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000147 # a "feature" of the the wrapper script is that it can be used outside
148 # the kernel tree. So keeping this around for backwards compatibility.
149 compression=
Scott Wooda9903812007-03-16 12:27:59 -0500150 ;;
Paul Mackerras2bf11812006-09-27 22:47:03 +1000151 -?)
152 usage
153 ;;
154 *)
155 [ -z "$kernel" ] || usage
156 kernel="$1"
157 ;;
158 esac
159 shift
160done
161
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000162
Paul Mackerras2bf11812006-09-27 22:47:03 +1000163if [ -n "$dts" ]; then
David Woodhouse701172d12007-12-03 13:49:24 +1100164 if [ ! -r "$dts" -a -r "$object/dts/$dts" ]; then
165 dts="$object/dts/$dts"
166 fi
Paul Mackerras2bf11812006-09-27 22:47:03 +1000167 if [ -z "$dtb" ]; then
168 dtb="$platform.dtb"
169 fi
Lucian Adrian Grijincuc79b2972009-07-23 00:13:37 +0000170 $dtc -O dtb -o "$dtb" -b 0 "$dts"
Paul Mackerras2bf11812006-09-27 22:47:03 +1000171fi
172
173if [ -z "$kernel" ]; then
174 kernel=vmlinux
175fi
176
Laurent Vivier58531b02015-11-05 12:31:34 +0100177LANG=C elfformat="`${CROSS}objdump -p "$kernel" | grep 'file format' | awk '{print $4}'`"
Cédric Le Goater147c0512014-04-24 09:23:39 +0200178case "$elfformat" in
179 elf64-powerpcle) format=elf64lppc ;;
180 elf64-powerpc) format=elf32ppc ;;
181 elf32-powerpc) format=elf32ppc ;;
182esac
183
184
Paul Mackerras2bf11812006-09-27 22:47:03 +1000185platformo=$object/"$platform".o
186lds=$object/zImage.lds
187ext=strip
188objflags=-S
189tmp=$tmpdir/zImage.$$.o
190ksection=.kernel:vmlinux.strip
191isection=.kernel:initrd
Tony Breeds9b09c6d2008-06-24 14:20:29 +1000192link_address='0x400000'
Stephen Rothwelldfbc2d72012-03-20 14:13:51 +1100193make_space=y
Paul Mackerras2bf11812006-09-27 22:47:03 +1000194
195case "$platform" in
Benjamin Herrenschmidt44790a02013-11-05 10:09:11 +1100196of)
197 platformo="$object/of.o $object/epapr.o"
198 make_space=n
199 ;;
Tony Breeds9b09c6d2008-06-24 14:20:29 +1000200pseries)
Cédric Le Goater2d9afb32014-04-24 09:23:38 +0200201 platformo="$object/pseries-head.o $object/of.o $object/epapr.o"
Tony Breeds9b09c6d2008-06-24 14:20:29 +1000202 link_address='0x4000000'
Cédric Le Goater147c0512014-04-24 09:23:39 +0200203 if [ "$format" != "elf32ppc" ]; then
204 link_address=
205 pie=-pie
206 fi
Paul Mackerrasf5467e22013-10-29 16:21:26 +1100207 make_space=n
Tony Breeds9b09c6d2008-06-24 14:20:29 +1000208 ;;
Corey Minyard58706ef2010-01-29 14:18:20 +0000209maple)
Benjamin Herrenschmidt0c9fa292013-09-24 16:10:38 +1000210 platformo="$object/of.o $object/epapr.o"
Corey Minyard58706ef2010-01-29 14:18:20 +0000211 link_address='0x400000'
Paul Mackerrasf5467e22013-10-29 16:21:26 +1100212 make_space=n
Corey Minyard58706ef2010-01-29 14:18:20 +0000213 ;;
Tony Breeds9b09c6d2008-06-24 14:20:29 +1000214pmac|chrp)
Benjamin Herrenschmidt0c9fa292013-09-24 16:10:38 +1000215 platformo="$object/of.o $object/epapr.o"
Paul Mackerrasf5467e22013-10-29 16:21:26 +1100216 make_space=n
Paul Mackerras2bf11812006-09-27 22:47:03 +1000217 ;;
Milton Miller627aa942007-05-31 01:29:01 +1000218coff)
Benjamin Herrenschmidt0c9fa292013-09-24 16:10:38 +1000219 platformo="$object/crt0.o $object/of.o $object/epapr.o"
Paul Mackerras2bf11812006-09-27 22:47:03 +1000220 lds=$object/zImage.coff.lds
Tony Breeds9b09c6d2008-06-24 14:20:29 +1000221 link_address='0x500000'
Paul Mackerrasf5467e22013-10-29 16:21:26 +1100222 make_space=n
Michael Ellerman6975a782011-04-12 20:38:55 +0000223 pie=
Paul Mackerras2bf11812006-09-27 22:47:03 +1000224 ;;
Benjamin Herrenschmidt11eab2972011-12-01 19:35:08 +0000225miboot|uboot*)
Paul Mackerras2bf11812006-09-27 22:47:03 +1000226 # miboot and U-boot want just the bare bits, not an ELF binary
227 ext=bin
228 objflags="-O binary"
229 tmp="$ofile"
230 ksection=image
231 isection=initrd
232 ;;
Scott Wood0fdd7172007-04-17 09:25:50 +1000233cuboot*)
Scott Wood11c146c2007-09-14 14:58:25 -0500234 binary=y
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000235 compression=
Grant Likely25431332008-02-07 05:18:34 +1100236 case "$platform" in
Scott Wood8dd217b2008-07-31 19:10:22 +0300237 *-mpc866ads|*-mpc885ads|*-adder875*|*-ep88xc)
Grant Likely25431332008-02-07 05:18:34 +1100238 platformo=$object/cuboot-8xx.o
239 ;;
240 *5200*|*-motionpro)
241 platformo=$object/cuboot-52xx.o
242 ;;
243 *-pq2fads|*-ep8248e|*-mpc8272*|*-storcenter)
244 platformo=$object/cuboot-pq2.o
245 ;;
246 *-mpc824*)
247 platformo=$object/cuboot-824x.o
248 ;;
Bryan O'Donoghue59d13f92008-05-08 13:47:00 +0100249 *-mpc83*|*-asp834x*)
Grant Likely25431332008-02-07 05:18:34 +1100250 platformo=$object/cuboot-83xx.o
251 ;;
Alexandr Smirnovff880112008-03-04 19:34:26 +0300252 *-tqm8541|*-mpc8560*|*-tqm8560|*-tqm8555|*-ksi8560*)
Grant Likely25431332008-02-07 05:18:34 +1100253 platformo=$object/cuboot-85xx-cpm2.o
254 ;;
Wolfgang Grandegger6dd1b642008-06-06 13:50:04 +0200255 *-mpc85*|*-tqm85*|*-sbc85*)
Grant Likely25431332008-02-07 05:18:34 +1100256 platformo=$object/cuboot-85xx.o
257 ;;
Gerhard Pircher8f237352009-02-10 12:26:11 +0000258 *-amigaone)
259 link_address='0x800000'
260 ;;
Grant Likely25431332008-02-07 05:18:34 +1100261 esac
Scott Wood0fdd7172007-04-17 09:25:50 +1000262 ;;
Geoff Levandbafdb642007-07-04 09:07:18 +1000263ps3)
264 platformo="$object/ps3-head.o $object/ps3-hvcall.o $object/ps3.o"
265 lds=$object/zImage.ps3.lds
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000266 compression=
Geoff Levandbafdb642007-07-04 09:07:18 +1000267 ext=bin
268 objflags="-O binary --set-section-flags=.bss=contents,alloc,load,data"
269 ksection=.kernel:vmlinux.bin
270 isection=.kernel:initrd
Tony Breeds9b09c6d2008-06-24 14:20:29 +1000271 link_address=''
Stephen Rothwelldfbc2d72012-03-20 14:13:51 +1100272 make_space=n
Michael Ellerman6975a782011-04-12 20:38:55 +0000273 pie=
Geoff Levandbafdb642007-07-04 09:07:18 +1000274 ;;
Scott Wooda55387e2008-02-20 12:33:38 -0600275ep88xc|ep405|ep8248e)
Scott Wood11c146c2007-09-14 14:58:25 -0500276 platformo="$object/fixed-head.o $object/$platform.o"
277 binary=y
278 ;;
Scott Wooda55387e2008-02-20 12:33:38 -0600279adder875-redboot)
280 platformo="$object/fixed-head.o $object/redboot-8xx.o"
281 binary=y
282 ;;
Grant Likelyd2477b52008-03-19 04:07:43 +1100283simpleboot-virtex405-*)
John Linnd58577d2008-07-02 15:11:28 -0700284 platformo="$object/virtex405-head.o $object/simpleboot.o $object/virtex.o"
285 binary=y
286 ;;
287simpleboot-virtex440-*)
Grant Likelya7e1cf02009-03-11 09:36:26 -0600288 platformo="$object/fixed-head.o $object/simpleboot.o $object/virtex.o"
Grant Likelyd2477b52008-03-19 04:07:43 +1100289 binary=y
290 ;;
Grant Likely1d46e372008-07-04 00:59:37 -0600291simpleboot-*)
Grant Likelya7e1cf02009-03-11 09:36:26 -0600292 platformo="$object/fixed-head.o $object/simpleboot.o"
Grant Likely1d46e372008-07-04 00:59:37 -0600293 binary=y
294 ;;
Bryan O'Donoghue59d13f92008-05-08 13:47:00 +0100295asp834x-redboot)
296 platformo="$object/fixed-head.o $object/redboot-83xx.o"
297 binary=y
298 ;;
Nate Case24760822009-06-11 14:43:01 -0500299xpedite52*)
300 link_address='0x1400000'
301 platformo=$object/cuboot-85xx.o
302 ;;
Albert Herranz6cdd24172009-12-12 06:31:45 +0000303gamecube|wii)
Albert Herranzb68a24b2009-12-12 06:31:36 +0000304 link_address='0x600000'
305 platformo="$object/$platform-head.o $object/$platform.o"
306 ;;
Tony Breeds228d5502011-11-30 21:39:24 +0000307treeboot-currituck)
308 link_address='0x1000000'
309 ;;
Alistair Popple2a2c74b2014-03-06 14:52:27 +1100310treeboot-akebono)
311 link_address='0x1000000'
312 ;;
Torez Smithb4e8c8d2010-03-05 10:45:54 +0000313treeboot-iss4xx-mpic)
314 platformo="$object/treeboot-iss4xx.o"
315 ;;
David Gibson6c5b59b2011-04-14 18:29:16 +0000316epapr)
Jeremy Kerr90d1d442015-02-11 12:55:44 +0800317 platformo="$object/pseries-head.o $object/epapr.o $object/epapr-wrapper.o"
David Gibson6c5b59b2011-04-14 18:29:16 +0000318 link_address='0x20000000'
319 pie=-pie
320 ;;
Stephen Chiversbe201982014-01-09 13:01:22 +1100321mvme5100)
322 platformo="$object/fixed-head.o $object/mvme5100.o"
323 binary=y
324 ;;
Alessio Igor Bogani97493e2e2016-05-30 11:47:16 +0200325mvme7100)
326 platformo="$object/motload-head.o $object/mvme7100.o"
327 link_address='0x4000000'
328 binary=y
329 ;;
Paul Mackerras2bf11812006-09-27 22:47:03 +1000330esac
331
332vmz="$tmpdir/`basename \"$kernel\"`.$ext"
Scott Wooda9903812007-03-16 12:27:59 -0500333
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000334# Calculate the vmlinux.strip size
335${CROSS}objcopy $objflags "$kernel" "$vmz.$$"
336strip_size=$(stat -c %s $vmz.$$)
Suzuki Poulosec55aef02011-12-14 22:59:57 +0000337
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000338if [ -z "$cacheit" -o ! -f "$vmz$compression" -o "$vmz$compression" -ot "$kernel" ]; then
339 # recompress the image if we need to
340 case $compression in
341 .xz)
342 xz --check=crc32 -f -6 "$vmz.$$"
343 ;;
344 .gz)
Michal Marekc4f56af2011-04-05 04:58:50 +0000345 gzip -n -f -9 "$vmz.$$"
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000346 ;;
347 *)
348 # drop the compression suffix so the stripped vmlinux is used
349 compression=
350 ;;
351 esac
Scott Wooda9903812007-03-16 12:27:59 -0500352
Paul Mackerras2bf11812006-09-27 22:47:03 +1000353 if [ -n "$cacheit" ]; then
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000354 mv -f "$vmz.$$$compression" "$vmz$compression"
Paul Mackerras2bf11812006-09-27 22:47:03 +1000355 else
356 vmz="$vmz.$$"
357 fi
Suzuki Poulosec55aef02011-12-14 22:59:57 +0000358else
Suzuki Poulosec55aef02011-12-14 22:59:57 +0000359 rm -f $vmz.$$
360fi
361
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000362vmz="$vmz$compression"
363
Stephen Rothwelldfbc2d72012-03-20 14:13:51 +1100364if [ "$make_space" = "y" ]; then
365 # Round the size to next higher MB limit
366 round_size=$(((strip_size + 0xfffff) & 0xfff00000))
Suzuki Poulosec55aef02011-12-14 22:59:57 +0000367
Stephen Rothwelldfbc2d72012-03-20 14:13:51 +1100368 round_size=0x$(printf "%x" $round_size)
369 link_addr=$(printf "%d" $link_address)
Suzuki Poulosec55aef02011-12-14 22:59:57 +0000370
Stephen Rothwelldfbc2d72012-03-20 14:13:51 +1100371 if [ $link_addr -lt $strip_size ]; then
372 echo "INFO: Uncompressed kernel (size 0x$(printf "%x\n" $strip_size))" \
373 "overlaps the address of the wrapper($link_address)"
374 echo "INFO: Fixing the link_address of wrapper to ($round_size)"
375 link_address=$round_size
376 fi
Paul Mackerras2bf11812006-09-27 22:47:03 +1000377fi
378
David Gibsona6afacb2007-05-01 10:20:20 +1000379# Extract kernel version information, some platforms want to include
380# it in the image header
381version=`${CROSS}strings "$kernel" | grep '^Linux version [-0-9.]' | \
382 cut -d' ' -f3`
383if [ -n "$version" ]; then
384 uboot_version="-n Linux-$version"
385fi
Scott Wood0fdd7172007-04-17 09:25:50 +1000386
Kumar Galab18796d2008-04-16 05:52:29 +1000387# physical offset of kernel image
388membase=`${CROSS}objdump -p "$kernel" | grep -m 1 LOAD | awk '{print $7}'`
389
Scott Wood0fdd7172007-04-17 09:25:50 +1000390case "$platform" in
391uboot)
392 rm -f "$ofile"
Peter Tyser3f884bf2009-12-30 15:23:26 -0700393 ${MKIMAGE} -A ppc -O linux -T kernel -C gzip -a $membase -e $membase \
David Gibsona6afacb2007-05-01 10:20:20 +1000394 $uboot_version -d "$vmz" "$ofile"
Paul Mackerras2bf11812006-09-27 22:47:03 +1000395 if [ -z "$cacheit" ]; then
Scott Wooda9903812007-03-16 12:27:59 -0500396 rm -f "$vmz"
Paul Mackerras2bf11812006-09-27 22:47:03 +1000397 fi
398 exit 0
399 ;;
Benjamin Herrenschmidt11eab2972011-12-01 19:35:08 +0000400uboot-obs600)
401 rm -f "$ofile"
402 # obs600 wants a multi image with an initrd, so we need to put a fake
403 # one in even when building a "normal" image.
404 if [ -n "$initrd" ]; then
405 real_rd="$initrd"
406 else
407 real_rd=`mktemp`
408 echo "\0" >>"$real_rd"
409 fi
410 ${MKIMAGE} -A ppc -O linux -T multi -C gzip -a $membase -e $membase \
411 $uboot_version -d "$vmz":"$real_rd":"$dtb" "$ofile"
412 if [ -z "$initrd" ]; then
413 rm -f "$real_rd"
414 fi
415 if [ -z "$cacheit" ]; then
416 rm -f "$vmz"
417 fi
418 exit 0
419 ;;
Paul Mackerras2bf11812006-09-27 22:47:03 +1000420esac
421
422addsec() {
423 ${CROSS}objcopy $4 $1 \
424 --add-section=$3="$2" \
425 --set-section-flags=$3=contents,alloc,load,readonly,data
426}
427
Scott Wooda9903812007-03-16 12:27:59 -0500428addsec $tmp "$vmz" $ksection $object/empty.o
Paul Mackerras2bf11812006-09-27 22:47:03 +1000429if [ -z "$cacheit" ]; then
Scott Wooda9903812007-03-16 12:27:59 -0500430 rm -f "$vmz"
Paul Mackerras2bf11812006-09-27 22:47:03 +1000431fi
432
433if [ -n "$initrd" ]; then
Mark A. Greerc8885542006-10-16 13:49:27 -0700434 addsec $tmp "$initrd" $isection
Paul Mackerras2bf11812006-09-27 22:47:03 +1000435fi
436
437if [ -n "$dtb" ]; then
Mark A. Greerc8885542006-10-16 13:49:27 -0700438 addsec $tmp "$dtb" .kernel:dtb
Mark A. Greere9c4b4b2006-11-08 17:50:44 -0700439 if [ -n "$dts" ]; then
440 rm $dtb
441 fi
Paul Mackerras2bf11812006-09-27 22:47:03 +1000442fi
443
444if [ "$platform" != "miboot" ]; then
Tony Breeds9b09c6d2008-06-24 14:20:29 +1000445 if [ -n "$link_address" ] ; then
Michael Ellerman6975a782011-04-12 20:38:55 +0000446 text_start="-Ttext $link_address"
Tony Breeds9b09c6d2008-06-24 14:20:29 +1000447 fi
Oliver O'Halloranf1e510b2016-09-22 16:54:33 +1000448#link everything
Cédric Le Goater147c0512014-04-24 09:23:39 +0200449 ${CROSS}ld -m $format -T $lds $text_start $pie -o "$ofile" \
David Gibsoncd197ff2007-03-05 14:24:52 +1100450 $platformo $tmp $object/wrapper.a
Paul Mackerras2bf11812006-09-27 22:47:03 +1000451 rm $tmp
452fi
453
David Gibsona6afacb2007-05-01 10:20:20 +1000454# Some platforms need the zImage's entry point and base address
455base=0x`${CROSS}nm "$ofile" | grep ' _start$' | cut -d' ' -f1`
456entry=`${CROSS}objdump -f "$ofile" | grep '^start address ' | cut -d' ' -f3`
457
Scott Wood11c146c2007-09-14 14:58:25 -0500458if [ -n "$binary" ]; then
459 mv "$ofile" "$ofile".elf
Scott Woodaeb45522007-10-25 02:56:28 +1000460 ${CROSS}objcopy -O binary "$ofile".elf "$ofile"
Scott Wood11c146c2007-09-14 14:58:25 -0500461fi
462
Paul Mackerras2bf11812006-09-27 22:47:03 +1000463# post-processing needed for some platforms
464case "$platform" in
Corey Minyard58706ef2010-01-29 14:18:20 +0000465pseries|chrp|maple)
Paul Mackerras5663a122008-10-31 22:27:17 +1100466 $objbin/addnote "$ofile"
Paul Mackerras0dcd4402008-10-20 17:42:42 +0000467 ;;
Milton Miller627aa942007-05-31 01:29:01 +1000468coff)
David Gibsoncd197ff2007-03-05 14:24:52 +1100469 ${CROSS}objcopy -O aixcoff-rs6000 --set-start "$entry" "$ofile"
David Woodhouse5c539ee2007-12-03 13:52:05 +1100470 $objbin/hack-coff "$ofile"
Paul Mackerras2bf11812006-09-27 22:47:03 +1000471 ;;
Scott Wood0fdd7172007-04-17 09:25:50 +1000472cuboot*)
Michal Marekc4f56af2011-04-05 04:58:50 +0000473 gzip -n -f -9 "$ofile"
Peter Tyser3f884bf2009-12-30 15:23:26 -0700474 ${MKIMAGE} -A ppc -O linux -T kernel -C gzip -a "$base" -e "$entry" \
Scott Woodaeb45522007-10-25 02:56:28 +1000475 $uboot_version -d "$ofile".gz "$ofile"
Scott Wood0fdd7172007-04-17 09:25:50 +1000476 ;;
David Gibsonf6dfc802007-05-08 14:10:01 +1000477treeboot*)
478 mv "$ofile" "$ofile.elf"
David Woodhouse5c539ee2007-12-03 13:52:05 +1100479 $objbin/mktree "$ofile.elf" "$ofile" "$base" "$entry"
David Gibsonf6dfc802007-05-08 14:10:01 +1000480 if [ -z "$cacheit" ]; then
481 rm -f "$ofile.elf"
482 fi
483 exit 0
484 ;;
Geoff Levandbafdb642007-07-04 09:07:18 +1000485ps3)
Geoff Levand5761eaa2008-03-28 07:41:45 +1100486 # The ps3's loader supports loading a gzipped binary image from flash
487 # rom to ram addr zero. The loader then enters the system reset
488 # vector at addr 0x100. A bootwrapper overlay is used to arrange for
489 # a binary image of the kernel to be at addr zero, and yet have a
490 # suitable bootwrapper entry at 0x100. To construct the final rom
491 # image 512 bytes from offset 0x100 is copied to the bootwrapper
492 # place holder at symbol __system_reset_kernel. The 512 bytes of the
493 # bootwrapper entry code at symbol __system_reset_overlay is then
494 # copied to offset 0x100. At runtime the bootwrapper program copies
495 # the data at __system_reset_kernel back to addr 0x100.
Geoff Levandbafdb642007-07-04 09:07:18 +1000496
Scott Woodaeb45522007-10-25 02:56:28 +1000497 system_reset_overlay=0x`${CROSS}nm "$ofile" \
Geoff Levandbafdb642007-07-04 09:07:18 +1000498 | grep ' __system_reset_overlay$' \
499 | cut -d' ' -f1`
500 system_reset_overlay=`printf "%d" $system_reset_overlay`
Scott Woodaeb45522007-10-25 02:56:28 +1000501 system_reset_kernel=0x`${CROSS}nm "$ofile" \
Geoff Levandbafdb642007-07-04 09:07:18 +1000502 | grep ' __system_reset_kernel$' \
503 | cut -d' ' -f1`
504 system_reset_kernel=`printf "%d" $system_reset_kernel`
505 overlay_dest="256"
Geoff Levand5761eaa2008-03-28 07:41:45 +1100506 overlay_size="512"
Geoff Levandbafdb642007-07-04 09:07:18 +1000507
Scott Woodaeb45522007-10-25 02:56:28 +1000508 ${CROSS}objcopy -O binary "$ofile" "$ofile.bin"
509
Geoff Levand879c26d2015-10-19 10:53:26 -0700510 run_cmd dd if="$ofile.bin" of="$ofile.bin" conv=notrunc \
511 skip=$overlay_dest seek=$system_reset_kernel \
Grant Likelyd4740372007-10-23 14:27:36 +1000512 count=$overlay_size bs=1
Geoff Levandbafdb642007-07-04 09:07:18 +1000513
Geoff Levand879c26d2015-10-19 10:53:26 -0700514 run_cmd dd if="$ofile.bin" of="$ofile.bin" conv=notrunc \
515 skip=$system_reset_overlay seek=$overlay_dest \
Grant Likelyd4740372007-10-23 14:27:36 +1000516 count=$overlay_size bs=1
Geoff Levandbafdb642007-07-04 09:07:18 +1000517
David Woodhouse928b9692007-12-03 13:48:03 +1100518 odir="$(dirname "$ofile.bin")"
519 rm -f "$odir/otheros.bld"
Michal Marekc4f56af2011-04-05 04:58:50 +0000520 gzip -n --force -9 --stdout "$ofile.bin" > "$odir/otheros.bld"
Geoff Levandbafdb642007-07-04 09:07:18 +1000521 ;;
Paul Mackerras2bf11812006-09-27 22:47:03 +1000522esac