Mercurial > hg > index.cgi
annotate lwlink/script.c @ 273:1409debcb1a0
Fix crash on listing when nested noexpand macros are used
Macros flagged noexpand were causing a segfault during listing. The problem
was incorrect accounting for nesting levels for noexpand macros causing the
listing handler to fall off the end of the program in certain circumstances
and in other circumstances it would fail to suppress expansion. Both the
segfault in the case of misbehaviour and the misbhaviour itself are
corrected with this update.
If you do not use nested noexpand macros, this bug has no effect.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sat, 25 May 2013 13:35:46 -0600 |
parents | 7de7b14ebaee |
children | 86eb8814a05c |
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" | |
258
ebda5c96665e
Improved stack handling for os9 target in lwlink
William Astle <lost@l-w.ca>
parents:
236
diff
changeset
|
46 "stacksize 32\n" |
151
3b58d76ea032
Fix up some minor thinkos in handling the module layout and header
lost@l-w.ca
parents:
148
diff
changeset
|
47 "entry __start\n" |
148 | 48 ; |
49 | |
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
|
50 // 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
|
51 static char *decb_script = |
234
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
52 "define basesympat s_%s\n" |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
53 "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
|
54 "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
|
55 "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
|
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 "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
|
58 "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
|
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 |
2c24602be78f
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 // 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
|
62 static char *raw_script = |
234
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
63 "define basesympat s_%s\n" |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
64 "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
|
65 "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
|
66 "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
|
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 "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
|
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 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
71 static char *lwex0_script = |
234
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
72 "define basesympat s_%s\n" |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
73 "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
|
74 "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
|
75 "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
|
76 "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
|
77 "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
|
78 "section .data\n" |
78 | 79 "section .ctors_start\n" |
80 "section .ctors\n" | |
81 "section .ctors_end\n" | |
82 "section .dtors_start\n" | |
83 "section .dtors\n" | |
84 "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
|
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 "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
|
87 "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
|
88 "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
|
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 |
2c24602be78f
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 // 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
|
92 static char *simple_script = |
234
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
93 "define basesympat s_%s\n" |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
94 "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
|
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 "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
|
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 |
2c24602be78f
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 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
|
100 |
2c24602be78f
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 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
|
102 { |
2c24602be78f
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 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
|
104 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
|
105 |
2c24602be78f
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 // 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
|
107 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
|
108 { |
2c24602be78f
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 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
|
110 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
|
111 |
2c24602be78f
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 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
|
113 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
|
114 { |
2c24602be78f
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 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
|
116 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
|
117 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
|
118 } |
2c24602be78f
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 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
|
120 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
|
121 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
|
122 |
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
|
123 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
|
124 |
2c24602be78f
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 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
|
126 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
|
127 { |
2c24602be78f
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 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
|
129 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
|
130 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
|
131 } |
2c24602be78f
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 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
|
133 |
2c24602be78f
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] = '\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
|
135 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
|
136 } |
2c24602be78f
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 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
|
138 { |
2c24602be78f
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 // 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
|
140 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
|
141 { |
2c24602be78f
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 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
|
143 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
|
144 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
|
145 |
2c24602be78f
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 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
|
147 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
|
148 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
|
149 |
2c24602be78f
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 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
|
151 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
|
152 break; |
148 | 153 |
154 case OUTPUT_OS9: | |
155 script = os9_script; | |
156 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
|
157 |
2c24602be78f
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 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
|
159 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
|
160 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
|
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 |
2c24602be78f
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 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
|
164 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
|
165 { |
2c24602be78f
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 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
|
167 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
|
168 // 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
|
169 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
|
170 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
|
171 |
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
|
172 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
|
173 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
|
174 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
|
175 { |
2c24602be78f
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 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
|
177 } |
2c24602be78f
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 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
|
179 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
|
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 |
2c24602be78f
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 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
|
184 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
|
185 |
148 | 186 if (outformat == OUTPUT_OS9) |
187 { | |
188 linkscript.modtype = 0x01; | |
189 linkscript.modlang = 0x01; | |
190 linkscript.modattr = 0x08; | |
191 linkscript.modrev = 0x00; | |
262
7de7b14ebaee
Add support for os9 module edition byte
William Astle <lost@l-w.ca>
parents:
258
diff
changeset
|
192 linkscript.edition = -1; |
148 | 193 linkscript.name = NULL; |
194 } | |
195 | |
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
|
196 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
|
197 // 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
|
198 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
|
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 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
|
201 |
2c24602be78f
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 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
|
203 /* 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
|
204 |
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
|
205 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
|
206 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
|
207 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
|
208 |
2c24602be78f
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 // 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
|
210 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
|
211 /* 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
|
212 |
2c24602be78f
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 // 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
|
214 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
|
215 /* 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
|
216 |
2c24602be78f
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 // 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
|
218 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
|
219 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
|
220 |
2c24602be78f
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 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
|
222 /* 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
|
223 |
2c24602be78f
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 // 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
|
225 // 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
|
226 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
|
227 *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
|
228 |
2c24602be78f
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 // 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
|
230 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
|
231 /* 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
|
232 |
236
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
233 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
|
234 { |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
235 char *sn; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
236 char *ptr3; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
237 sectopt_t *so; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
238 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
239 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
|
240 /* do nothing */ ; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
241 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
242 if (*ptr2) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
243 *ptr2++ = '\0'; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
244 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
245 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
|
246 ptr2++; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
247 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
248 // 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
|
249 // 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
|
250 sn = ptr; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
251 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
252 // 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
|
253 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
|
254 /* do nothing */ ; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
255 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
256 if (*ptr3) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
257 *ptr3++ = 0; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
258 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
259 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
|
260 ptr3++; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
261 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
262 // 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
|
263 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
|
264 { |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
265 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
|
266 break; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
267 } |
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 if (!so) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
270 { |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
271 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
|
272 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
|
273 so -> aftersize = 0; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
274 so -> afterbytes = NULL; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
275 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
|
276 section_opts = so; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
277 } |
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 (!strcmp(ptr2, "padafter")) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
280 { |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
281 if (so -> afterbytes) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
282 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
|
283 so -> aftersize = 0; |
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 for (;;) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
286 { |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
287 int v; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
288 char *ptr4; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
289 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
290 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
|
291 ptr3++; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
292 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
293 if (!ptr3) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
294 break; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
295 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
296 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
|
297 if (ptr3 == ptr4) |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
298 break; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
299 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
300 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
301 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
|
302 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
|
303 so -> aftersize++; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
304 ptr3 = ptr4; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
305 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
|
306 ptr3++; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
307 |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
308 if (*ptr3 != ',') |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
309 break; |
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 ptr3++; |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
312 } |
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 else |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
315 { |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
316 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
|
317 exit(1); |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
318 } |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
319 } |
ce1fdc8d6568
Added ability to add padding after a section when linking.
William Astle <lost@l-w.ca>
parents:
234
diff
changeset
|
320 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
|
321 { |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
322 // parse out the definition type |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
323 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
|
324 /* do nothing */ ; |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
325 |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
326 if (*ptr2) |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
327 *ptr2++ = '\0'; |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
328 |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
329 while (*ptr2 && isspace(*ptr2)) |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
330 ptr2++; |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
331 |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
332 // 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
|
333 if (!strcmp(ptr, "basesympat")) |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
334 { |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
335 /* section base symbol pattern */ |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
336 lw_free(linkscript.basesympat); |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
337 linkscript.basesympat = lw_strdup(ptr2); |
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 else if (!strcmp(ptr, "lensympat")) |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
340 { |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
341 /* section length symbol pattern */ |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
342 lw_free(linkscript.lensympat); |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
343 linkscript.lensympat = lw_strdup(ptr2); |
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 else |
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 } |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
348 } |
d389adbcc4ab
Added section base and length symbols to lwlink
William Astle <lost@l-w.ca>
parents:
183
diff
changeset
|
349 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
|
350 { |
2c24602be78f
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 // 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
|
352 // 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
|
353 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
|
354 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
|
355 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
|
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 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
|
358 { |
2c24602be78f
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 // 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
|
360 // 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
|
361 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
|
362 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
|
363 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
|
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 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
|
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 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
|
368 |
2c24602be78f
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 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
|
370 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
|
371 { |
2c24602be78f
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 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
|
373 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
|
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 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
|
376 { |
2c24602be78f
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 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
|
378 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
|
379 } |
2c24602be78f
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 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
|
382 { |
2c24602be78f
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 // 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
|
384 // 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
|
385 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
|
386 /* 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
|
387 |
2c24602be78f
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 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
|
389 *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
|
390 |
2c24602be78f
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 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
|
392 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 |
2c24602be78f
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 // 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
|
395 // 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
|
396 |
2c24602be78f
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 // 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
|
398 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
|
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 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
|
401 { |
2c24602be78f
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 += 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
|
403 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
|
404 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
|
405 |
2c24602be78f
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 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
|
408 { |
2c24602be78f
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 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
|
410 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
|
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 } |
2c24602be78f
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 |
2c24602be78f
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 // 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
|
415 // 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
|
416 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
|
417 |
2c24602be78f
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 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
|
419 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
|
420 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
|
421 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
|
422 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
|
423 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
|
424 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
|
425 /* 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
|
426 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
|
427 { |
2c24602be78f
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 *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
|
429 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
|
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 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
|
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 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
|
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 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
|
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 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
|
438 { |
2c24602be78f
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 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
|
440 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
|
441 } |
2c24602be78f
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 } |
2c24602be78f
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 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
|
444 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
|
445 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
|
446 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
|
447 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
|
448 } |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
449 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
|
450 { |
67
554831f03338
Make lwlink more verbose about unrecognized linkscript lines
lost@l-w.ca
parents:
8
diff
changeset
|
451 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
|
452 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
|
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 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
|
455 } |
2c24602be78f
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 |
2c24602be78f
Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff
changeset
|
457 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
|
458 lw_free(oscript); |
183 | 459 |
460 if (entrysym) | |
461 { | |
462 int eaddr; | |
463 char *ptr2; | |
464 | |
465 lw_free(linkscript.execsym); | |
466 | |
467 eaddr = strtol(entrysym, &ptr2, 0); | |
468 if (*ptr2) | |
469 { | |
470 linkscript.execaddr = -1; | |
471 linkscript.execsym = lw_strdup(entrysym); | |
472 } | |
473 else | |
474 { | |
475 linkscript.execaddr = eaddr; | |
476 linkscript.execsym = NULL; | |
477 } | |
478 | |
479 } | |
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
|
480 } |