Mercurial > hg > index.cgi
annotate lwlink/script.c @ 256:bc25269d96bc
Fix crash on expression range calculation
When attempting to calculate the range of a NULL expression, just indicate
failure and bail out rather than dereferencing the expression and crashing
out with no feedback.
author | William Astle <lost@l-w.ca> |
---|---|
date | Wed, 30 Jan 2013 21:47:15 -0700 |
parents | ce1fdc8d6568 |
children | ebda5c96665e |
rev | line source |
---|---|
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
1 /* |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
2 script.c |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
3 Copyright © 2009 William Astle |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
4 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
5 This file is part of LWLINK. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
6 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
7 LWLINK is free software: you can redistribute it and/or modify it under the |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
8 terms of the GNU General Public License as published by the Free Software |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
9 Foundation, either version 3 of the License, or (at your option) any later |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
10 version. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
11 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
12 This program is distributed in the hope that it will be useful, but WITHOUT |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
15 more details. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
16 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License along with |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
18 this program. If not, see <http://www.gnu.org/licenses/>. |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
19 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
20 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
21 Read and parse linker scripts |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
22 */ |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
23 |
2
7317fbe024af
Clean up insane number of compiler warnings under -Wall
lost@l-w.ca
parents:
0
diff
changeset
|
24 #include <ctype.h> |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
25 #include <errno.h> |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
26 #include <stdio.h> |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
27 #include <stdlib.h> |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
28 #include <string.h> |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
29 |
8
fdc11ef4115b
Switched lwlink to lw_cmdline from argp and also brought in lw_alloc and lw_string to replace util.c
lost@l-w.ca
parents:
2
diff
changeset
|
30 #include <lw_alloc.h> |
fdc11ef4115b
Switched lwlink to lw_cmdline from argp and also brought in lw_alloc and lw_string to replace util.c
lost@l-w.ca
parents:
2
diff
changeset
|
31 #include <lw_string.h> |
fdc11ef4115b
Switched lwlink to lw_cmdline from argp and also brought in lw_alloc and lw_string to replace util.c
lost@l-w.ca
parents:
2
diff
changeset
|
32 |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
33 #include "lwlink.h" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
34 |
148 | 35 // the built-in OS9 script |
151
3b58d76ea032
Fix up some minor thinkos in handling the module layout and header
lost@l-w.ca
parents:
148
diff
changeset
|
36 // the 000D bit is to handle the module header! |
148 | 37 static char *os9_script = |
234
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
38 "define basesympat s_%s\n" |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
39 "define lensympat l_%s\n" |
151
3b58d76ea032
Fix up some minor thinkos in handling the module layout and header
lost@l-w.ca
parents:
148
diff
changeset
|
40 "section code load 000D\n" |
148 | 41 "section .text\n" |
42 "section data\n" | |
43 "section .data\n" | |
44 "section bss,bss load 0000\n" | |
45 "section .bss,bss\n" | |
151
3b58d76ea032
Fix up some minor thinkos in handling the module layout and header
lost@l-w.ca
parents:
148
diff
changeset
|
46 "entry __start\n" |
148 | 47 ; |
48 | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
49 // the built-in DECB target linker script |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
50 static char *decb_script = |
234
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
51 "define basesympat s_%s\n" |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
52 "define lensympat l_%s\n" |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
53 "section init load 2000\n" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
54 "section code\n" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
55 "section *,!bss\n" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
56 "section *,bss\n" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
57 "entry 2000\n" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
58 ; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
59 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
60 // the built-in RAW target linker script |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
61 static char *raw_script = |
234
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
62 "define basesympat s_%s\n" |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
63 "define lensympat l_%s\n" |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
64 "section init load 0000\n" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
65 "section code\n" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
66 "section *,!bss\n" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
67 "section *,bss\n" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
68 ; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
69 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
70 static char *lwex0_script = |
234
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
71 "define basesympat s_%s\n" |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
72 "define lensympat l_%s\n" |
236
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
73 "sectopt .ctors padafter 00,00\n" |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
74 "sectopt .dtors padafter 00,00\n" |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
75 "section init load 0100\n" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
76 "section .text\n" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
77 "section .data\n" |
78 | 78 "section .ctors_start\n" |
79 "section .ctors\n" | |
80 "section .ctors_end\n" | |
81 "section .dtors_start\n" | |
82 "section .dtors\n" | |
83 "section .dtors_end\n" | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
84 "section *,!bss\n" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
85 "section *,bss\n" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
86 "entry __start\n" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
87 "stacksize 0100\n" // default 256 byte stack |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
88 ; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
89 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
90 // the "simple" script |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
91 static char *simple_script = |
234
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
92 "define basesympat s_%s\n" |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
93 "define lensympat l_%s\n" |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
94 "section *,!bss\n" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
95 "section *,bss\n" |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
96 ; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
97 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
98 linkscript_t linkscript = { 0, NULL, -1 }; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
99 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
100 void setup_script() |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
101 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
102 char *script, *oscript; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
103 long size; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
104 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
105 // read the file if needed |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
106 if (scriptfile) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
107 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
108 FILE *f; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
109 long bread; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
110 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
111 f = fopen(scriptfile, "rb"); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
112 if (!f) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
113 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
114 fprintf(stderr, "Can't open file %s:", scriptfile); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
115 perror(""); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
116 exit(1); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
117 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
118 fseek(f, 0, SEEK_END); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
119 size = ftell(f); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
120 rewind(f); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
121 |
8
fdc11ef4115b
Switched lwlink to lw_cmdline from argp and also brought in lw_alloc and lw_string to replace util.c
lost@l-w.ca
parents:
2
diff
changeset
|
122 script = lw_alloc(size + 2); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
123 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
124 bread = fread(script, 1, size, f); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
125 if (bread < size) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
126 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
127 fprintf(stderr, "Short read on file %s (%ld/%ld):", scriptfile, bread, size); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
128 perror(""); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
129 exit(1); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
130 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
131 fclose(f); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
132 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
133 script[size] = '\n'; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
134 script[size + 1] = '\0'; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
135 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
136 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
137 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
138 // fetch defaults based on output mode |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
139 switch (outformat) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
140 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
141 case OUTPUT_RAW: |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
142 script = raw_script; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
143 break; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
144 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
145 case OUTPUT_DECB: |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
146 script = decb_script; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
147 break; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
148 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
149 case OUTPUT_LWEX0: |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
150 script = lwex0_script; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
151 break; |
148 | 152 |
153 case OUTPUT_OS9: | |
154 script = os9_script; | |
155 break; | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
156 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
157 default: |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
158 script = simple_script; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
159 break; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
160 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
161 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
162 size = strlen(script); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
163 if (nscriptls) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
164 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
165 char *rscript; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
166 int i; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
167 // prepend the "extra" script lines |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
168 for (i = 0; i < nscriptls; i++) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
169 size += strlen(scriptls[i]) + 1; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
170 |
8
fdc11ef4115b
Switched lwlink to lw_cmdline from argp and also brought in lw_alloc and lw_string to replace util.c
lost@l-w.ca
parents:
2
diff
changeset
|
171 rscript = lw_alloc(size + 1); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
172 oscript = rscript; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
173 for (i = 0; i < nscriptls; i++) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
174 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
175 oscript += sprintf(oscript, "%s\n", scriptls[i]); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
176 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
177 strcpy(oscript, script); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
178 script = rscript; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
179 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
180 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
181 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
182 if (outformat == OUTPUT_LWEX0) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
183 linkscript.stacksize = 0x100; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
184 |
148 | 185 if (outformat == OUTPUT_OS9) |
186 { | |
187 linkscript.modtype = 0x01; | |
188 linkscript.modlang = 0x01; | |
189 linkscript.modattr = 0x08; | |
190 linkscript.modrev = 0x00; | |
191 linkscript.name = NULL; | |
192 } | |
193 | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
194 oscript = script; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
195 // now parse the script file |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
196 while (*script) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
197 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
198 char *ptr, *ptr2, *line; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
199 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
200 for (ptr = script; *ptr && *ptr != '\n' && *ptr != '\r'; ptr++) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
201 /* do nothing */ ; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
202 |
8
fdc11ef4115b
Switched lwlink to lw_cmdline from argp and also brought in lw_alloc and lw_string to replace util.c
lost@l-w.ca
parents:
2
diff
changeset
|
203 line = lw_alloc(ptr - script + 1); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
204 memcpy(line, script, ptr - script); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
205 line[ptr - script] = '\0'; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
206 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
207 // skip line terms |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
208 for (script = ptr + 1; *script == '\n' || *script == '\r'; script++) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
209 /* do nothing */ ; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
210 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
211 // ignore leading whitespace |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
212 for (ptr = line; *ptr && isspace(*ptr); ptr++) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
213 /* do nothing */ ; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
214 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
215 // ignore blank lines |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
216 if (!*ptr) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
217 continue; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
218 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
219 for (ptr = line; *ptr && !isspace(*ptr); ptr++) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
220 /* do nothing */ ; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
221 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
222 // now ptr points to the char past the first word |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
223 // NUL it out |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
224 if (*ptr) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
225 *ptr++ = '\0'; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
226 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
227 // skip spaces after the first word |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
228 for ( ; *ptr && isspace(*ptr); ptr++) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
229 /* do nothing */ ; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
230 |
236
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
231 if (!strcmp(line, "sectopt")) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
232 { |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
233 char *sn; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
234 char *ptr3; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
235 sectopt_t *so; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
236 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
237 for (ptr2 = ptr; *ptr && !isspace(*ptr2); ptr2++) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
238 /* do nothing */ ; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
239 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
240 if (*ptr2) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
241 *ptr2++ = '\0'; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
242 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
243 while (*ptr2 && isspace(*ptr2)) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
244 ptr2++; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
245 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
246 // section name is at ptr |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
247 // ptr2 is the option type |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
248 sn = ptr; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
249 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
250 // now ptr2 points to the section option name |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
251 for (ptr3 = ptr2; *ptr3 && !isspace(*ptr3); ptr3++) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
252 /* do nothing */ ; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
253 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
254 if (*ptr3) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
255 *ptr3++ = 0; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
256 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
257 while (*ptr3 && isspace(*ptr3)) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
258 ptr3++; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
259 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
260 // now ptr3 points to option value |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
261 for (so = section_opts; so; so = so -> next) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
262 { |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
263 if (!strcmp(so -> name, sn)) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
264 break; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
265 } |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
266 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
267 if (!so) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
268 { |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
269 so = lw_alloc(sizeof(sectopt_t)); |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
270 so -> name = lw_strdup(sn); |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
271 so -> aftersize = 0; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
272 so -> afterbytes = NULL; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
273 so -> next = section_opts; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
274 section_opts = so; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
275 } |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
276 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
277 if (!strcmp(ptr2, "padafter")) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
278 { |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
279 if (so -> afterbytes) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
280 lw_free(so -> afterbytes); |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
281 so -> aftersize = 0; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
282 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
283 for (;;) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
284 { |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
285 int v; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
286 char *ptr4; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
287 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
288 while (*ptr3 && isspace(*ptr3)) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
289 ptr3++; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
290 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
291 if (!ptr3) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
292 break; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
293 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
294 v = strtoul(ptr3, &ptr4, 16); |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
295 if (ptr3 == ptr4) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
296 break; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
297 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
298 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
299 so -> afterbytes = lw_realloc(so -> afterbytes, so -> aftersize + 1); |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
300 so -> afterbytes[so -> aftersize] = v; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
301 so -> aftersize++; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
302 ptr3 = ptr4; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
303 while (*ptr3 && isspace(*ptr3)) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
304 ptr3++; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
305 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
306 if (*ptr3 != ',') |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
307 break; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
308 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
309 ptr3++; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
310 } |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
311 } |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
312 else |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
313 { |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
314 fprintf(stderr, "%s: bad script line: %s %s\n", scriptfile, line, ptr2); |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
315 exit(1); |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
316 } |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
317 } |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
318 else if (!strcmp(line, "define")) |
234
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
319 { |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
320 // parse out the definition type |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
321 for (ptr2 = ptr; *ptr2 && !isspace(*ptr2); ptr2++) |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
322 /* do nothing */ ; |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
323 |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
324 if (*ptr2) |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
325 *ptr2++ = '\0'; |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
326 |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
327 while (*ptr2 && isspace(*ptr2)) |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
328 ptr2++; |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
329 |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
330 // now ptr points to the define type |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
331 if (!strcmp(ptr, "basesympat")) |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
332 { |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
333 /* section base symbol pattern */ |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
334 lw_free(linkscript.basesympat); |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
335 linkscript.basesympat = lw_strdup(ptr2); |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
336 } |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
337 else if (!strcmp(ptr, "lensympat")) |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
338 { |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
339 /* section length symbol pattern */ |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
340 lw_free(linkscript.lensympat); |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
341 linkscript.lensympat = lw_strdup(ptr2); |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
342 } |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
343 else |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
344 { |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
345 } |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
346 } |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
347 else if (!strcmp(line, "pad")) |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
348 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
349 // padding |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
350 // parse the hex number and stow it |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
351 linkscript.padsize = strtol(ptr, NULL, 16); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
352 if (linkscript.padsize < 0) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
353 linkscript.padsize = 0; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
354 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
355 else if (!strcmp(line, "stacksize")) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
356 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
357 // stack size for targets that support it |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
358 // parse the hex number and stow it |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
359 linkscript.padsize = strtol(ptr, NULL, 16); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
360 if (linkscript.stacksize < 0) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
361 linkscript.stacksize = 0x100; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
362 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
363 else if (!strcmp(line, "entry")) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
364 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
365 int eaddr; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
366 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
367 eaddr = strtol(ptr, &ptr2, 16); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
368 if (*ptr2) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
369 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
370 linkscript.execaddr = -1; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
371 linkscript.execsym = lw_strdup(ptr); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
372 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
373 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
374 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
375 linkscript.execaddr = eaddr; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
376 linkscript.execsym = NULL; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
377 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
378 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
379 else if (!strcmp(line, "section")) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
380 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
381 // section |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
382 // parse out the section name and flags |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
383 for (ptr2 = ptr; *ptr2 && !isspace(*ptr2); ptr2++) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
384 /* do nothing */ ; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
385 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
386 if (*ptr2) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
387 *ptr2++ = '\0'; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
388 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
389 while (*ptr2 && isspace(*ptr2)) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
390 ptr2++; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
391 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
392 // ptr now points to the section name and flags and ptr2 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
393 // to the first non-space character following |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
394 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
395 // then look for "load <addr>" clause |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
396 if (*ptr2) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
397 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
398 if (!strncmp(ptr2, "load", 4)) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
399 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
400 ptr2 += 4; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
401 while (*ptr2 && isspace(*ptr2)) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
402 ptr2++; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
403 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
404 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
405 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
406 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
407 fprintf(stderr, "%s: bad script\n", scriptfile); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
408 exit(1); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
409 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
410 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
411 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
412 // now ptr2 points to the load address if there is one |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
413 // or NUL if not |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
414 linkscript.lines = lw_realloc(linkscript.lines, sizeof(struct scriptline_s) * (linkscript.nlines + 1)); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
415 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
416 linkscript.lines[linkscript.nlines].noflags = 0; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
417 linkscript.lines[linkscript.nlines].yesflags = 0; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
418 if (*ptr2) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
419 linkscript.lines[linkscript.nlines].loadat = strtol(ptr2, NULL, 16); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
420 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
421 linkscript.lines[linkscript.nlines].loadat = -1; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
422 for (ptr2 = ptr; *ptr2 && *ptr2 != ','; ptr2++) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
423 /* do nothing */ ; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
424 if (*ptr2) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
425 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
426 *ptr2++ = '\0'; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
427 if (!strcmp(ptr2, "!bss")) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
428 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
429 linkscript.lines[linkscript.nlines].noflags = SECTION_BSS; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
430 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
431 else if (!strcmp(ptr2, "bss")) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
432 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
433 linkscript.lines[linkscript.nlines].yesflags = SECTION_BSS; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
434 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
435 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
436 { |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
437 fprintf(stderr, "%s: bad script\n", scriptfile); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
438 exit(1); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
439 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
440 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
441 if (ptr[0] == '*' && ptr[1] == '\0') |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
442 linkscript.lines[linkscript.nlines].sectname = NULL; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
443 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
444 linkscript.lines[linkscript.nlines].sectname = lw_strdup(ptr); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
445 linkscript.nlines++; |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
446 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
447 else |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
448 { |
67
554831f03338
Make lwlink more verbose about unrecognized linkscript lines
lost@l-w.ca
parents:
8
diff
changeset
|
449 fprintf(stderr, "%s: bad script line: %s\n", scriptfile, line); |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
450 exit(1); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
451 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
452 lw_free(line); |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
453 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
454 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
455 if (scriptfile || nscriptls) |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
456 lw_free(oscript); |
183 | 457 |
458 if (entrysym) | |
459 { | |
460 int eaddr; | |
461 char *ptr2; | |
462 | |
463 lw_free(linkscript.execsym); | |
464 | |
465 eaddr = strtol(entrysym, &ptr2, 0); | |
466 if (*ptr2) | |
467 { | |
468 linkscript.execaddr = -1; | |
469 linkscript.execsym = lw_strdup(entrysym); | |
470 } | |
471 else | |
472 { | |
473 linkscript.execaddr = eaddr; | |
474 linkscript.execsym = NULL; | |
475 } | |
476 | |
477 } | |
0
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
478 } |