~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/powerpc/boot/wrapper

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/powerpc/boot/wrapper (Version linux-6.12-rc7) and /arch/alpha/boot/wrapper (Version linux-4.4.302)


  1 #!/bin/sh                                         
  2 # SPDX-License-Identifier: GPL-2.0-only           
  3                                                   
  4 # Copyright (C) 2006 Paul Mackerras, IBM Corpo<    
  5                                                   
  6 # This script takes a kernel binary and option    
  7 # and/or a device-tree blob, and creates a boo    
  8 # given platform.                                 
  9                                                   
 10 # Options:                                        
 11 # -o zImage     specify output file               
 12 # -p platform   specify platform (links in $pl    
 13 # -i initrd     specify initrd file               
 14 # -d devtree    specify device-tree blob          
 15 # -s tree.dts   specify device-tree source fil    
 16 # -e esm_blob   specify ESM blob for secure im    
 17 # -c            cache $kernel.strip.gz (use if    
 18 # -C prefix     specify command prefix for cro    
 19 #               (strip, objcopy, ld)              
 20 # -D dir        specify directory containing d    
 21 #               (default ./arch/powerpc/boot)     
 22 # -W dir        specify working directory for     
 23 # -z            use gzip (legacy)                 
 24 # -Z zsuffix    compression to use (gz, xz or     
 25                                                   
 26 # Stop execution if any command fails             
 27 set -e                                            
 28                                                   
 29 export LC_ALL=C                                   
 30                                                   
 31 # Allow for verbose output                        
 32 if [ "$V" = 1 ]; then                             
 33     set -x                                        
 34     map="-Map wrapper.map"                        
 35 fi                                                
 36                                                   
 37 # defaults                                        
 38 kernel=                                           
 39 ofile=zImage                                      
 40 platform=of                                       
 41 initrd=                                           
 42 dtb=                                              
 43 dts=                                              
 44 esm_blob=                                         
 45 cacheit=                                          
 46 binary=                                           
 47 compression=.gz                                   
 48 uboot_comp=gzip                                   
 49 pie=                                              
 50 format=                                           
 51 notext=                                           
 52 rodynamic=                                        
 53                                                   
 54 # cross-compilation prefix                        
 55 CROSS=                                            
 56                                                   
 57 # mkimage wrapper script                          
 58 MKIMAGE=$srctree/scripts/mkuboot.sh               
 59                                                   
 60 # directory for object and other files used by    
 61 object=arch/powerpc/boot                          
 62 objbin=$object                                    
 63 dtc=scripts/dtc/dtc                               
 64                                                   
 65 # directory for working files                     
 66 tmpdir=.                                          
 67                                                   
 68 usage() {                                         
 69     echo 'Usage: wrapper [-o output] [-p platf    
 70     echo '       [-d devtree] [-s tree.dts] [-    
 71     echo '       [-c] [-C cross-prefix] [-D da    
 72     echo '       [-Z (gz|xz|none)] [--no-compr    
 73     exit 1                                        
 74 }                                                 
 75                                                   
 76 run_cmd() {                                       
 77     if [ "$V" = 1 ]; then                         
 78         $* 2>&1                                   
 79     else                                          
 80         local msg                                 
 81                                                   
 82         set +e                                    
 83         msg=$($* 2>&1)                            
 84                                                   
 85         if [ $? -ne "0" ]; then                   
 86                 echo $msg                         
 87                 exit 1                            
 88         fi                                        
 89         set -e                                    
 90     fi                                            
 91 }                                                 
 92                                                   
 93 while [ "$#" -gt 0 ]; do                          
 94     case "$1" in                                  
 95     -o)                                           
 96         shift                                     
 97         [ "$#" -gt 0 ] || usage                   
 98         ofile="$1"                                
 99         ;;                                        
100     -p)                                           
101         shift                                     
102         [ "$#" -gt 0 ] || usage                   
103         platform="$1"                             
104         ;;                                        
105     -i)                                           
106         shift                                     
107         [ "$#" -gt 0 ] || usage                   
108         initrd="$1"                               
109         ;;                                        
110     -d)                                           
111         shift                                     
112         [ "$#" -gt 0 ] || usage                   
113         dtb="$1"                                  
114         ;;                                        
115     -e)                                           
116         shift                                     
117         [ "$#" -gt 0 ] || usage                   
118         esm_blob="$1"                             
119         ;;                                        
120     -s)                                           
121         shift                                     
122         [ "$#" -gt 0 ] || usage                   
123         dts="$1"                                  
124         ;;                                        
125     -c)                                           
126         cacheit=y                                 
127         ;;                                        
128     -C)                                           
129         shift                                     
130         [ "$#" -gt 0 ] || usage                   
131         CROSS="$1"                                
132         ;;                                        
133     -D)                                           
134         shift                                     
135         [ "$#" -gt 0 ] || usage                   
136         object="$1"                               
137         objbin="$1"                               
138         ;;                                        
139     -W)                                           
140         shift                                     
141         [ "$#" -gt 0 ] || usage                   
142         tmpdir="$1"                               
143         ;;                                        
144     -z)                                           
145         compression=.gz                           
146         uboot_comp=gzip                           
147         ;;                                        
148     -Z)                                           
149         shift                                     
150         [ "$#" -gt 0 ] || usage                   
151         [ "$1" != "gz" -o "$1" != "xz" -o "$1"    
152                                                   
153         compression=".$1"                         
154         uboot_comp=$1                             
155                                                   
156         if [ $compression = ".none" ]; then       
157                 compression=                      
158                 uboot_comp=none                   
159         fi                                        
160         if [ $uboot_comp = "gz" ]; then           
161                 uboot_comp=gzip                   
162         fi                                        
163         ;;                                        
164     --no-gzip)                                    
165         # a "feature" of the wrapper script is    
166         # the kernel tree. So keeping this aro    
167         compression=                              
168         uboot_comp=none                           
169         ;;                                        
170     -?)                                           
171         usage                                     
172         ;;                                        
173     *)                                            
174         [ -z "$kernel" ] || usage                 
175         kernel="$1"                               
176         ;;                                        
177     esac                                          
178     shift                                         
179 done                                              
180                                                   
181                                                   
182 if [ -n "$dts" ]; then                            
183     if [ ! -r "$dts" -a -r "$object/dts/$dts"     
184         dts="$object/dts/$dts"                    
185     fi                                            
186     if [ -z "$dtb" ]; then                        
187         dtb="$platform.dtb"                       
188     fi                                            
189     $dtc -O dtb -o "$dtb" -b 0 "$dts"             
190 fi                                                
191                                                   
192 if [ -z "$kernel" ]; then                         
193     kernel=vmlinux                                
194 fi                                                
195                                                   
196 LC_ALL=C elfformat="`${CROSS}objdump -p "$kern    
197 case "$elfformat" in                              
198     elf64-powerpcle)    format=elf64lppc          
199     elf64-powerpc)      format=elf32ppc ;;        
200     elf32-powerpc)      format=elf32ppc ;;        
201 esac                                              
202                                                   
203 ld_version()                                      
204 {                                                 
205     # Poached from scripts/ld-version.sh, but     
206     # this script (wrapper) is distributed sep    
207     # Extract linker version number from stdin    
208     awk '{                                        
209         gsub(".*\\)", "");                        
210         gsub(".*version ", "");                   
211         gsub("-.*", "");                          
212         split($1,a, ".");                         
213         if( length(a[3]) == "8" )                 
214                 # a[3] is probably a date of f    
215                 # can assume it to be zero as     
216                 a[3] = 0;                         
217         print a[1]*100000000 + a[2]*1000000 +     
218         exit                                      
219     }'                                            
220 }                                                 
221                                                   
222 ld_is_lld()                                       
223 {                                                 
224         ${CROSS}ld -V 2>&1 | grep -q LLD          
225 }                                                 
226                                                   
227 # Do not include PT_INTERP segment when linkin    
228 # just ignores this option.                       
229 LD_VERSION=$(${CROSS}ld --version | ld_version    
230 LD_NO_DL_MIN_VERSION=$(echo 2.26 | ld_version)    
231 if [ "$LD_VERSION" -ge "$LD_NO_DL_MIN_VERSION"    
232         nodl="--no-dynamic-linker"                
233 fi                                                
234                                                   
235 # suppress some warnings in recent ld versions    
236 nowarn="-z noexecstack"                           
237 if ! ld_is_lld; then                              
238         if [ "$LD_VERSION" -ge "$(echo 2.39 |     
239                 nowarn="$nowarn --no-warn-rwx-    
240         fi                                        
241 fi                                                
242                                                   
243 platformo=$object/"$platform".o                   
244 lds=$object/zImage.lds                            
245 ext=strip                                         
246 objflags=-S                                       
247 tmp=$tmpdir/zImage.$$.o                           
248 ksection=.kernel:vmlinux.strip                    
249 isection=.kernel:initrd                           
250 esection=.kernel:esm_blob                         
251 link_address='0x400000'                           
252 make_space=y                                      
253                                                   
254                                                   
255 if [ -n "$esm_blob" -a "$platform" != "pseries    
256     echo "ESM blob not support on non-pseries     
257     exit 1                                        
258 fi                                                
259                                                   
260 case "$platform" in                               
261 of)                                               
262     platformo="$object/of.o $object/epapr.o"      
263     make_space=n                                  
264     ;;                                            
265 pseries)                                          
266     platformo="$object/pseries-head.o $object/    
267     link_address='0x4000000'                      
268     if [ "$format" != "elf32ppc" ]; then          
269         link_address=                             
270         pie=-pie                                  
271     fi                                            
272     make_space=n                                  
273     ;;                                            
274 maple)                                            
275     platformo="$object/of.o $object/epapr.o"      
276     link_address='0x400000'                       
277     make_space=n                                  
278     ;;                                            
279 pmac|chrp)                                        
280     platformo="$object/of.o $object/epapr.o"      
281     make_space=n                                  
282     ;;                                            
283 coff)                                             
284     platformo="$object/crt0.o $object/of.o $ob    
285     lds=$object/zImage.coff.lds                   
286     link_address='0x500000'                       
287     make_space=n                                  
288     pie=                                          
289     ;;                                            
290 miboot|uboot*)                                    
291     # miboot and U-boot want just the bare bit    
292     ext=bin                                       
293     objflags="-O binary"                          
294     tmp="$ofile"                                  
295     ksection=image                                
296     isection=initrd                               
297     ;;                                            
298 cuboot*)                                          
299     binary=y                                      
300     compression=                                  
301     case "$platform" in                           
302     *-mpc866ads|*-mpc885ads|*-adder875*|*-ep88    
303         platformo=$object/cuboot-8xx.o            
304         ;;                                        
305     *5200*|*-motionpro)                           
306         platformo=$object/cuboot-52xx.o           
307         ;;                                        
308     *-pq2fads|*-ep8248e|*-mpc8272*|*-storcente    
309         platformo=$object/cuboot-pq2.o            
310         ;;                                        
311     *-mpc824*)                                    
312         platformo=$object/cuboot-824x.o           
313         ;;                                        
314     *-mpc83*|*-asp834x*)                          
315         platformo=$object/cuboot-83xx.o           
316         ;;                                        
317     *-tqm8541|*-mpc8560*|*-tqm8560|*-tqm8555|*    
318         platformo=$object/cuboot-85xx-cpm2.o      
319         ;;                                        
320     *-mpc85*|*-tqm85*)                            
321         platformo=$object/cuboot-85xx.o           
322         ;;                                        
323     *-amigaone)                                   
324         link_address='0x800000'                   
325         ;;                                        
326     esac                                          
327     ;;                                            
328 ps3)                                              
329     platformo="$object/ps3-head.o $object/ps3-    
330     lds=$object/zImage.ps3.lds                    
331     compression=                                  
332     ext=bin                                       
333     objflags="-O binary --set-section-flags=.b    
334     ksection=.kernel:vmlinux.bin                  
335     isection=.kernel:initrd                       
336     link_address=''                               
337     make_space=n                                  
338     pie=                                          
339     ;;                                            
340 ep88xc|ep8248e)                                   
341     platformo="$object/fixed-head.o $object/$p    
342     binary=y                                      
343     ;;                                            
344 adder875-redboot)                                 
345     platformo="$object/fixed-head.o $object/re    
346     binary=y                                      
347     ;;                                            
348 simpleboot-*)                                     
349     platformo="$object/fixed-head.o $object/si    
350     binary=y                                      
351     ;;                                            
352 asp834x-redboot)                                  
353     platformo="$object/fixed-head.o $object/re    
354     binary=y                                      
355     ;;                                            
356 xpedite52*)                                       
357     link_address='0x1400000'                      
358     platformo=$object/cuboot-85xx.o               
359     ;;                                            
360 gamecube|wii)                                     
361     link_address='0x600000'                       
362     platformo="$object/$platform-head.o $objec    
363     ;;                                            
364 microwatt)                                        
365     link_address='0x500000'                       
366     platformo="$object/fixed-head.o $object/$p    
367     binary=y                                      
368     ;;                                            
369 treeboot-currituck)                               
370     link_address='0x1000000'                      
371     ;;                                            
372 treeboot-akebono)                                 
373     link_address='0x1000000'                      
374     ;;                                            
375 treeboot-iss4xx-mpic)                             
376     platformo="$object/treeboot-iss4xx.o"         
377     ;;                                            
378 epapr)                                            
379     platformo="$object/pseries-head.o $object/    
380     link_address='0x20000000'                     
381     pie=-pie                                      
382     notext='-z notext'                            
383     rodynamic=$(if ${CROSS}ld -V 2>&1 | grep -    
384     ;;                                            
385 mvme5100)                                         
386     platformo="$object/fixed-head.o $object/mv    
387     binary=y                                      
388     ;;                                            
389 mvme7100)                                         
390     platformo="$object/motload-head.o $object/    
391     link_address='0x4000000'                      
392     binary=y                                      
393     ;;                                            
394 esac                                              
395                                                   
396 vmz="$tmpdir/`basename \"$kernel\"`.$ext"         
397                                                   
398 # Calculate the vmlinux.strip size                
399 ${CROSS}objcopy $objflags "$kernel" "$vmz.$$"     
400 strip_size=$(${CONFIG_SHELL} "${srctree}/scrip    
401                                                   
402 if [ -z "$cacheit" -o ! -f "$vmz$compression"     
403     # recompress the image if we need to          
404     case $compression in                          
405     .xz)                                          
406         xz --check=crc32 -f -6 "$vmz.$$"          
407         ;;                                        
408     .gz)                                          
409         gzip -n -f -9 "$vmz.$$"                   
410         ;;                                        
411     .lzma)                                        
412         xz --format=lzma -f -6 "$vmz.$$"          
413         ;;                                        
414     .lzo)                                         
415         lzop -f -9 "$vmz.$$"                      
416         ;;                                        
417     *)                                            
418         # drop the compression suffix so the s    
419         compression=                              
420         uboot_comp=none                           
421         ;;                                        
422     esac                                          
423                                                   
424     if [ -n "$cacheit" ]; then                    
425         mv -f "$vmz.$$$compression" "$vmz$comp    
426     else                                          
427         vmz="$vmz.$$"                             
428     fi                                            
429 else                                              
430     rm -f $vmz.$$                                 
431 fi                                                
432                                                   
433 vmz="$vmz$compression"                            
434                                                   
435 if [ "$make_space" = "y" ]; then                  
436         # Round the size to next higher MB lim    
437         round_size=$(((strip_size + 0xfffff) &    
438                                                   
439         round_size=0x$(printf "%x" $round_size    
440         link_addr=$(printf "%d" $link_address)    
441                                                   
442         if [ $link_addr -lt $strip_size ]; the    
443             echo "INFO: Uncompressed kernel (s    
444                         "overlaps the address     
445             echo "INFO: Fixing the link_addres    
446             link_address=$round_size              
447         fi                                        
448 fi                                                
449                                                   
450 # Extract kernel version information, some pla    
451 # it in the image header                          
452 version=`${CROSS}strings "$kernel" | grep '^Li    
453     head -n1 | cut -d' ' -f3`                     
454 if [ -n "$version" ]; then                        
455     uboot_version="-n Linux-$version"             
456 fi                                                
457                                                   
458 # physical offset of kernel image                 
459 membase=`${CROSS}objdump -p "$kernel" | grep -    
460                                                   
461 case "$platform" in                               
462 uboot)                                            
463     rm -f "$ofile"                                
464     ${MKIMAGE} -A ppc -O linux -T kernel -C $u    
465         $uboot_version -d "$vmz" "$ofile"         
466     if [ -z "$cacheit" ]; then                    
467         rm -f "$vmz"                              
468     fi                                            
469     exit 0                                        
470     ;;                                            
471 esac                                              
472                                                   
473 addsec() {                                        
474     ${CROSS}objcopy $4 $1 \                       
475         --add-section=$3="$2" \                   
476         --set-section-flags=$3=contents,alloc,    
477 }                                                 
478                                                   
479 addsec $tmp "$vmz" $ksection $object/empty.o      
480 if [ -z "$cacheit" ]; then                        
481     rm -f "$vmz"                                  
482 fi                                                
483                                                   
484 if [ -n "$initrd" ]; then                         
485     addsec $tmp "$initrd" $isection               
486 fi                                                
487                                                   
488 if [ -n "$dtb" ]; then                            
489     addsec $tmp "$dtb" .kernel:dtb                
490     if [ -n "$dts" ]; then                        
491         rm $dtb                                   
492     fi                                            
493 fi                                                
494                                                   
495 if [ -n "$esm_blob" ]; then                       
496     addsec $tmp "$esm_blob" $esection             
497 fi                                                
498                                                   
499 if [ "$platform" != "miboot" ]; then              
500     if [ -n "$link_address" ] ; then              
501         text_start="-Ttext $link_address"         
502     fi                                            
503 #link everything                                  
504     ${CROSS}ld -m $format -T $lds $text_start     
505         $platformo $tmp $object/wrapper.a         
506     rm $tmp                                       
507 fi                                                
508                                                   
509 # Some platforms need the zImage's entry point    
510 base=0x`${CROSS}nm "$ofile" | grep ' _start$'     
511 entry=`${CROSS}objdump -f "$ofile" | grep '^st    
512                                                   
513 if [ -n "$binary" ]; then                         
514     mv "$ofile" "$ofile".elf                      
515     ${CROSS}objcopy -O binary "$ofile".elf "$o    
516 fi                                                
517                                                   
518 # post-processing needed for some platforms       
519 case "$platform" in                               
520 pseries|chrp|maple)                               
521     $objbin/addnote "$ofile"                      
522     ;;                                            
523 coff)                                             
524     ${CROSS}objcopy -O aixcoff-rs6000 --set-st    
525     $objbin/hack-coff "$ofile"                    
526     ;;                                            
527 cuboot*)                                          
528     gzip -n -f -9 "$ofile"                        
529     ${MKIMAGE} -A ppc -O linux -T kernel -C gz    
530             $uboot_version -d "$ofile".gz "$of    
531     ;;                                            
532 treeboot*)                                        
533     mv "$ofile" "$ofile.elf"                      
534     $objbin/mktree "$ofile.elf" "$ofile" "$bas    
535     if [ -z "$cacheit" ]; then                    
536         rm -f "$ofile.elf"                        
537     fi                                            
538     exit 0                                        
539     ;;                                            
540 ps3)                                              
541     # The ps3's loader supports loading a gzip    
542     # rom to ram addr zero. The loader then en    
543     # vector at addr 0x100.  A bootwrapper ove    
544     # a binary image of the kernel to be at ad    
545     # suitable bootwrapper entry at 0x100.  To    
546     # image 512 bytes from offset 0x100 is cop    
547     # place holder at symbol __system_reset_ke    
548     # bootwrapper entry code at symbol __syste    
549     # copied to offset 0x100.  At runtime the     
550     # the data at __system_reset_kernel back t    
551                                                   
552     system_reset_overlay=0x`${CROSS}nm "$ofile    
553         | grep ' __system_reset_overlay$'         
554         | cut -d' ' -f1`                          
555     system_reset_overlay=`printf "%d" $system_    
556     system_reset_kernel=0x`${CROSS}nm "$ofile"    
557         | grep ' __system_reset_kernel$'          
558         | cut -d' ' -f1`                          
559     system_reset_kernel=`printf "%d" $system_r    
560     overlay_dest="256"                            
561     overlay_size="512"                            
562                                                   
563     ${CROSS}objcopy -O binary "$ofile" "$ofile    
564                                                   
565     run_cmd dd if="$ofile.bin" of="$ofile.bin"    
566         skip=$overlay_dest seek=$system_reset_    
567         count=$overlay_size bs=1                  
568                                                   
569     run_cmd dd if="$ofile.bin" of="$ofile.bin"    
570         skip=$system_reset_overlay seek=$overl    
571         count=$overlay_size bs=1                  
572                                                   
573     odir="$(dirname "$ofile.bin")"                
574                                                   
575     # The ps3's flash loader has a size limit     
576     # image.  If a compressed image that excee    
577     # flash the loader will decompress that im    
578     # reached, then enter the system reset vec    
579     # image.  No warning is issued.               
580     rm -f "$odir"/{otheros,otheros-too-big}.bl    
581     size=$(${CROSS}nm --no-sort --radix=d "$of    
582     bld="otheros.bld"                             
583     if [ $size -gt $((0x1000000)) ]; then         
584         bld="otheros-too-big.bld"                 
585     fi                                            
586     gzip -n --force -9 --stdout "$ofile.bin" >    
587     ;;                                            
588 esac                                              
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php