annotate extra/ld @ 230:0df2a39a268c

Added --6809/--6309 switches and some cleanups in error reporting
author lost
date Fri, 12 Jun 2009 03:18:32 +0000
parents f481641b3371
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
181
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
1 #!/bin/sh
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
2 #
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
3 #
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
4 # Copyright 2009 by William Astle <lost@l-w.ca>
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
5 #
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
6 #This file is part of LWTOOLS.
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
7 #
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
8 #LWTOOLS is free software: you can redistribute it and/or modify it under the
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
9 #terms of the GNU General Public License as published by the Free Software
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
10 #Foundation, either version 3 of the License, or (at your option) any later
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
11 #version.
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
12 #
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
13 #This program is distributed in the hope that it will be useful, but WITHOUT
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
14 #ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
15 #FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
16 #more details.
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
17 #
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
18 #You should have received a copy of the GNU General Public License along with
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
19 #this program. If not, see <http://www.gnu.org/licenses/>.
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
20
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
21 # this was based somewhat on the "as" script from gcc6809
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
22
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
23 echo "LWTOOLS-as $0 $*"
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
24 path_to_lwlink=lwlink
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
25
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
26 # Set defaults. Some are based on the target type, which is
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
27 # determined by the name by which the program was invoked.
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
28 output_file=a.out
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
29 libpaths=
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
30 libs=
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
31 verbose=
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
32 case $0 in
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
33 *m6809-coco-*)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
34 options="--format=decb"
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
35 # options="-b .text=0x2000 -b .data=0x7000 -b .bss=0x7C00 -b .ctors=0x7F00 -b .dtors=0x7F80 -b vector=0x7FF0"
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
36 # aslink_options="-nwxst"
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
37 # exe_suffix=.bin
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
38 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
39 *)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
40 options="--format=decb"
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
41 # options="-b .text=0x8000 -b .data=0x1000 -b .bss=0x0100 -b .ctors=0xFD00 -b .dtors=0xFE00 -b vector=0xFFF0"
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
42 # aslink_options="-nwxso"
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
43 # exe_suffix=.s19
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
44 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
45 esac
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
46
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
47
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
48 while [ "$1" != "" ]; do
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
49 arg=$1; shift
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
50 case $arg in
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
51 -gn)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
52 # Generate NoICE debug file
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
53 # ignored because debugging not supported by targets
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
54 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
55 -gs)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
56 # Generate SDCC debug file
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
57 # ignored because debugging not supported by targets
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
58 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
59 -o)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
60 output_file=$1; shift
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
61 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
62 -L*)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
63 arg=${arg#-L}
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
64 libpaths="$libpaths --library-path=$arg"
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
65 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
66 -l*)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
67 arg=${arg#-l}
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
68 libs="$libs --library=$arg"
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
69 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
70 --section-start)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
71 section_value=$1; shift
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
72 options="$options --section-start=$section_value"
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
73 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
74 -Tbss)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
75 options="$options --section-start=.bss=$1"; shift
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
76 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
77 -Tdata)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
78 options="$options --section-start=.data=$1"; shift
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
79 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
80 -Ttext|-Tcode)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
81 options="$options --section-start=.text=$1"; shift
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
82 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
83 -v|--verbose)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
84 verbose=1
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
85 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
86 *crt0.o)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
87 startup_files=$arg
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
88 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
89 -g)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
90 # Ignored by GNU ld; we should do the same
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
91 true
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
92 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
93 -h|--help)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
94 echo "ld (m6809)"
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
95 exit 0
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
96 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
97 -T)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
98 echo "-T scripts not supported";
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
99 exit 1;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
100 ;;
210
f481641b3371 Added ability to specify lwex target for ld
lost
parents: 181
diff changeset
101 --format-lwex)
f481641b3371 Added ability to specify lwex target for ld
lost
parents: 181
diff changeset
102 options="$options --format=lwex"
f481641b3371 Added ability to specify lwex target for ld
lost
parents: 181
diff changeset
103 ;;
f481641b3371 Added ability to specify lwex target for ld
lost
parents: 181
diff changeset
104
181
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
105 -*)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
106 echo "ld (m6809): unknown option $arg"
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
107 exit 1
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
108 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
109 *)
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
110 input_files="$input_files $arg"
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
111 ;;
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
112 esac
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
113 done
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
114
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
115 options="$options -o $output_file"
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
116
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
117 if [ "$verbose" = "1" ]; then
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
118 echo "$path_to_lwlink $options $input_files $startup_files $libpaths $libs"
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
119 fi
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
120
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
121 $path_to_lwlink $options $input_files $startup_files $libpaths $libs
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
122 rc=$?
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
123
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
124 if [ "$rc" != "0" ]; then
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
125 rm -f $output_file
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
126 exit $rc
14878196ed5b Initial version of a wrapper script to behave something like 'ld'
lost
parents:
diff changeset
127 fi