Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: tools/lk/embed_program_in_binary.sh

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/linux_dist_support/debian/rules ('k') | tools/lk/run_snapshot_lk.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 function usage { 3 function usage {
4 echo "Usage: $0 [--fletch <fletch binary directory>] <elf-file>" 4 echo "Usage: $0 [--dartino <dartino binary directory>] <elf-file>"
5 echo " <snapshot-file> <symbol-name>" 5 echo " <snapshot-file> <symbol-name>"
6 echo 6 echo
7 echo "This will generate an object file <symbol-name> that can be linked" 7 echo "This will generate an object file <symbol-name> that can be linked"
8 echo "against the original <elf-file> and adds the following symbols:" 8 echo "against the original <elf-file> and adds the following symbols:"
9 echo 9 echo
10 echo " __fletch__<symbol-name>_heap_start" 10 echo " __dartino__<symbol-name>_heap_start"
11 echo " __fletch__<symbol-name>_heap_end" 11 echo " __dartino__<symbol-name>_heap_end"
12 echo " __fletch__<symbol-name>_heap_size" 12 echo " __dartino__<symbol-name>_heap_size"
13 echo 13 echo
14 echo "for the program heap." 14 echo "for the program heap."
15 echo 15 echo
16 echo "The generated output file will be named <symbol-name.o>." 16 echo "The generated output file will be named <symbol-name.o>."
17 } 17 }
18 18
19 if [ $# -lt 3 ]; then 19 if [ $# -lt 3 ]; then
20 usage 20 usage
21 exit 1 21 exit 1
22 fi 22 fi
23 23
24 while [ $# -gt 3 ]; do 24 while [ $# -gt 3 ]; do
25 case $1 in 25 case $1 in
26 --fletch | -f) 26 --dartino | -f)
27 FLETCHHOME="$2/" 27 DARTINOHOME="$2/"
28 shift 2 28 shift 2
29 ;; 29 ;;
30 --help | -h) 30 --help | -h)
31 usage 31 usage
32 exit 1 32 exit 1
33 ;; 33 ;;
34 *) 34 *)
35 echo "Unknown argument: $1" 35 echo "Unknown argument: $1"
36 exit 1 36 exit 1
37 ;; 37 ;;
38 esac 38 esac
39 done 39 done
40 40
41 if [ ! -e $1 ]; then 41 if [ ! -e $1 ]; then
42 echo "Cannot find linked elf file `$1` to embed into..." 42 echo "Cannot find linked elf file `$1` to embed into..."
43 exit 1 43 exit 1
44 fi 44 fi
45 45
46 if [ ! -e $2 ]; then 46 if [ ! -e $2 ]; then
47 echo "Cannot find snapshot file `$2` to embed..." 47 echo "Cannot find snapshot file `$2` to embed..."
48 exit 1 48 exit 1
49 fi 49 fi
50 50
51 if [ ! -e "${FLETCHHOME}flashtool" ]; then 51 if [ ! -e "${DARTINOHOME}flashtool" ]; then
52 echo "Cannot find flashtool relocator. Use --fletch to set fletch path..." 52 echo "Cannot find flashtool relocator. Use --dartino to set dartino path..."
53 exit 1 53 exit 1
54 fi 54 fi
55 55
56 SNAPSHOT=$(objdump -h $1 | grep '[0-9][0-9]* \.snapshot') 56 SNAPSHOT=$(objdump -h $1 | grep '[0-9][0-9]* \.snapshot')
57 57
58 if [ -z "$SNAPSHOT" ]; then 58 if [ -z "$SNAPSHOT" ]; then
59 echo "The elf file does not contain a .snapshot section. Add the following" 59 echo "The elf file does not contain a .snapshot section. Add the following"
60 echo "lines to the flash section of your linker script: " 60 echo "lines to the flash section of your linker script: "
61 echo 61 echo
62 echo ".snapshot ALIGN(4096) :" 62 echo ".snapshot ALIGN(4096) :"
63 echo "{ " 63 echo "{ "
64 echo " __fletch_program_heap_start = .; " 64 echo " __dartino_program_heap_start = .; "
65 echo " KEEP(*(.snapshot)) " 65 echo " KEEP(*(.snapshot)) "
66 echo " __fletch_program_heap_end = .; " 66 echo " __dartino_program_heap_end = .; "
67 echo "} " 67 echo "} "
68 exit 1 68 exit 1
69 fi 69 fi
70 70
71 INTRINSICS=$(objdump -t $1 | grep -o -E '^[[:xdigit:]]+ .* Intrinsic_([[:alpha:] ])+$' | sed -e 's/^\([[:xdigit:]]*\) .* Intrinsic_\([[:alpha:]]*\)$/-i \2=0x\1/g ') 71 INTRINSICS=$(objdump -t $1 | grep -o -E '^[[:xdigit:]]+ .* Intrinsic_([[:alpha:] ])+$' | sed -e 's/^\([[:xdigit:]]*\) .* Intrinsic_\([[:alpha:]]*\)$/-i \2=0x\1/g ')
72 72
73 PARTS=($SNAPSHOT) 73 PARTS=($SNAPSHOT)
74 ADDRESS=0x${PARTS[3]} 74 ADDRESS=0x${PARTS[3]}
75 echo "Found .snapshot section at $ADDRESS..." 75 echo "Found .snapshot section at $ADDRESS..."
76 76
77 TEMPDIR=$(mktemp -d fletchflash.XXX) 77 TEMPDIR=$(mktemp -d dartinoflash.XXX)
78 mkdir ${TEMPDIR}/fletch 78 mkdir ${TEMPDIR}/dartino
79 79
80 echo "Generating output in $TEMPDIR..." 80 echo "Generating output in $TEMPDIR..."
81 81
82 ${FLETCHHOME}flashtool $INTRINSICS $2 ${ADDRESS} ${TEMPDIR}/fletch/programheap.b in 82 ${DARTINOHOME}flashtool $INTRINSICS $2 ${ADDRESS} ${TEMPDIR}/dartino/programheap .bin
83 83
84 (cd ${TEMPDIR}; arm-none-eabi-objcopy --rename-section .data=.snapshot --redefin e-sym _binary_fletch_programheap_bin_start=__fletch_${3}_heap_start --redefine-s ym _binary_fletch_programheap_bin_end=__fletch_${3}_heap_end --redefine-sym _bin ary_fletch_programheap_bin_size=__fletch_${3}_heap_size -I binary -B armv4t -O e lf32-littlearm fletch/programheap.bin fletch/programheap.o) 84 (cd ${TEMPDIR}; arm-none-eabi-objcopy --rename-section .data=.snapshot --redefin e-sym _binary_dartino_programheap_bin_start=__dartino_${3}_heap_start --redefine -sym _binary_dartino_programheap_bin_end=__dartino_${3}_heap_end --redefine-sym _binary_dartino_programheap_bin_size=__dartino_${3}_heap_size -I binary -B armv4 t -O elf32-littlearm dartino/programheap.bin dartino/programheap.o)
85 85
86 arm-none-eabi-ld -r ${TEMPDIR}/fletch/programheap.o -o ${3}.o 86 arm-none-eabi-ld -r ${TEMPDIR}/dartino/programheap.o -o ${3}.o
87 87
88 (cd ${TEMPDIR}; rm fletch/*; rmdir fletch) 88 (cd ${TEMPDIR}; rm dartino/*; rmdir dartino)
89 rmdir ${TEMPDIR} 89 rmdir ${TEMPDIR}
90 90
91 echo "Written output to ${3}.o..." 91 echo "Written output to ${3}.o..."
OLDNEW
« no previous file with comments | « tools/linux_dist_support/debian/rules ('k') | tools/lk/run_snapshot_lk.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698