]> Git Repo - binutils.git/blame - ld/lexsup.c
* gdb.base/Makefile.in: Add action to .c.o transformation
[binutils.git] / ld / lexsup.c
CommitLineData
d4e5e3c3
DM
1/* Parse options for the GNU linker.
2 Copyright (C) 1991, 92, 93, 94 Free Software Foundation, Inc.
3
4This file is part of GLD, the Gnu Linker.
5
6GLD is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GLD is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GLD; see the file COPYING. If not, write to
943fbd5b 18the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
d4e5e3c3
DM
19
20#include "bfd.h"
21#include "sysdep.h"
22#include <stdio.h>
23#include <string.h>
22d3533c 24#include <ctype.h>
d4e5e3c3
DM
25#include "getopt.h"
26#include "bfdlink.h"
27#include "config.h"
28#include "ld.h"
29#include "ldmain.h"
30#include "ldmisc.h"
31#include "ldexp.h"
32#include "ldlang.h"
33#include "ldgram.h"
34#include "ldlex.h"
35#include "ldfile.h"
4725fb48 36#include "ldver.h"
d4e5e3c3 37
809ee7e0
ILT
38/* Somewhere above, sys/stat.h got included . . . . */
39#if !defined(S_ISDIR) && defined(S_IFDIR)
40#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
41#endif
42
d4e5e3c3
DM
43/* Omit args to avoid the possibility of clashing with a system header
44 that might disagree about consts. */
45unsigned long strtoul ();
46
47static void set_default_dirlist PARAMS ((char *dirlist_ptr));
48static void set_section_start PARAMS ((char *sect, char *valstr));
49
de71eb77
SC
50/* WINDOWS_NT; declare additional functions */
51static void set_subsystem PARAMS ((char *subsystem_type));
52static void set_stack_heap PARAMS ((char *valstr, boolean for_heap));
53
d4e5e3c3
DM
54void
55parse_args (argc, argv)
56 int argc;
57 char **argv;
58{
22d3533c 59 int i;
db770dfa
ILT
60 int ingroup = 0;
61
d4e5e3c3
DM
62 /* Starting the short option string with '-' is for programs that
63 expect options and other ARGV-elements in any order and that care about
64 the ordering of the two. We describe each non-option ARGV-element
65 as if it were the argument of an option with character code 1. */
66
db770dfa 67 const char *shortopts =
22d3533c 68 "-a:A:B::b:c:de:F::G:giL:l:Mm:NnO:o:R:rSsT:tu:VvXxY:y:z:()";
d4e5e3c3 69
d5b79a89
DM
70 /* 150 isn't special; it's just an arbitrary non-ASCII char value. */
71
bec7a138
ILT
72#define OPTION_CALL_SHARED 150
73#define OPTION_DEFSYM (OPTION_CALL_SHARED + 1)
7fb9ca5f
ILT
74#define OPTION_DYNAMIC_LINKER (OPTION_DEFSYM + 1)
75#define OPTION_EB (OPTION_DYNAMIC_LINKER + 1)
bec7a138 76#define OPTION_EL (OPTION_EB + 1)
de71eb77
SC
77#define OPTION_HEAP (OPTION_EL + 1)
78#define OPTION_EMBEDDED_RELOCS (OPTION_HEAP + 1)
79#define OPTION_EXPORT_DYNAMIC (OPTION_EMBEDDED_RELOCS + 1)
80#define OPTION_HELP (OPTION_EXPORT_DYNAMIC + 1)
bec7a138
ILT
81#define OPTION_IGNORE (OPTION_HELP + 1)
82#define OPTION_MAP (OPTION_IGNORE + 1)
83#define OPTION_NO_KEEP_MEMORY (OPTION_MAP + 1)
84#define OPTION_NOINHIBIT_EXEC (OPTION_NO_KEEP_MEMORY + 1)
85#define OPTION_NON_SHARED (OPTION_NOINHIBIT_EXEC + 1)
86#define OPTION_OFORMAT (OPTION_NON_SHARED + 1)
87#define OPTION_RELAX (OPTION_OFORMAT + 1)
88#define OPTION_RETAIN_SYMBOLS_FILE (OPTION_RELAX + 1)
809ee7e0
ILT
89#define OPTION_RPATH (OPTION_RETAIN_SYMBOLS_FILE + 1)
90#define OPTION_SHARED (OPTION_RPATH + 1)
91#define OPTION_SONAME (OPTION_SHARED + 1)
92#define OPTION_SORT_COMMON (OPTION_SONAME + 1)
de71eb77
SC
93#define OPTION_STACK (OPTION_SORT_COMMON + 1) /*WINDOWS_NT*/
94#define OPTION_STATS (OPTION_STACK + 1)
95#define OPTION_SUBSYSTEM (OPTION_STATS + 1) /* WINDOWS_NT */
4551e108
ILT
96#define OPTION_SYMBOLIC (OPTION_SUBSYSTEM + 1)
97#define OPTION_TBSS (OPTION_SYMBOLIC + 1)
bec7a138
ILT
98#define OPTION_TDATA (OPTION_TBSS + 1)
99#define OPTION_TTEXT (OPTION_TDATA + 1)
100#define OPTION_TRADITIONAL_FORMAT (OPTION_TTEXT + 1)
101#define OPTION_UR (OPTION_TRADITIONAL_FORMAT + 1)
de71eb77
SC
102#define OPTION_VERBOSE (OPTION_UR + 1)
103#define OPTION_VERSION (OPTION_VERBOSE + 1)
bec7a138 104#define OPTION_WARN_COMMON (OPTION_VERSION + 1)
809ee7e0 105#define OPTION_WARN_ONCE (OPTION_WARN_COMMON + 1)
de71eb77
SC
106#define OPTION_SPLIT_BY_RELOC (OPTION_WARN_ONCE + 1)
107#define OPTION_SPLIT_BY_FILE (OPTION_SPLIT_BY_RELOC + 1)
108#define OPTION_WHOLE_ARCHIVE (OPTION_SPLIT_BY_FILE + 1)
109#define OPTION_BASE_FILE (OPTION_WHOLE_ARCHIVE + 1)
d5b79a89 110 static struct option longopts[] = {
db770dfa
ILT
111 {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED},
112 {"Bstatic", no_argument, NULL, OPTION_NON_SHARED},
4551e108 113 {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
d5b79a89 114 {"call_shared", no_argument, NULL, OPTION_CALL_SHARED},
d4e5e3c3 115 {"dc", no_argument, NULL, 'd'},
d5b79a89 116 {"defsym", required_argument, NULL, OPTION_DEFSYM},
809ee7e0 117 {"dll-verbose", no_argument, NULL, OPTION_VERSION}, /* Linux. */
2a9fa50c 118 {"dn", no_argument, NULL, OPTION_NON_SHARED},
d4e5e3c3 119 {"dp", no_argument, NULL, 'd'},
2a9fa50c 120 {"dy", no_argument, NULL, OPTION_CALL_SHARED},
7fb9ca5f 121 {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
d5b79a89 122 {"EB", no_argument, NULL, OPTION_EB},
d5b79a89 123 {"EL", no_argument, NULL, OPTION_EL},
de71eb77 124 {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
db770dfa 125 {"end-group", no_argument, NULL, ')'},
de71eb77 126 {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC},
d4e5e3c3 127 {"format", required_argument, NULL, 'b'},
de71eb77 128 {"heap", required_argument, NULL, OPTION_HEAP}, /* WINDOWS_NT */
d5b79a89 129 {"help", no_argument, NULL, OPTION_HELP},
d5b79a89 130 {"Map", required_argument, NULL, OPTION_MAP},
d5b79a89 131 {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY},
d5b79a89
DM
132 {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
133 {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
2a9fa50c 134 {"non_shared", no_argument, NULL, OPTION_NON_SHARED},
d5b79a89 135 {"oformat", required_argument, NULL, OPTION_OFORMAT},
2a9fa50c 136 {"Qy", no_argument, NULL, OPTION_IGNORE},
cbbf9608 137 {"qmagic", no_argument, NULL, OPTION_IGNORE}, /* Linux compatibility. */
d5b79a89 138 {"relax", no_argument, NULL, OPTION_RELAX},
db770dfa 139 {"retain-symbols-file", required_argument, NULL, OPTION_RETAIN_SYMBOLS_FILE},
809ee7e0 140 {"rpath", required_argument, NULL, OPTION_RPATH},
db770dfa 141 {"shared", no_argument, NULL, OPTION_SHARED},
809ee7e0 142 {"soname", required_argument, NULL, OPTION_SONAME},
d5b79a89
DM
143 {"sort-common", no_argument, NULL, OPTION_SORT_COMMON},
144 {"sort_common", no_argument, NULL, OPTION_SORT_COMMON},
de71eb77 145 {"stack", required_argument, NULL, OPTION_STACK}, /* WINDOWS_NT */
db770dfa 146 {"start-group", no_argument, NULL, '('},
d5b79a89 147 {"stats", no_argument, NULL, OPTION_STATS},
42792411 148 {"static", no_argument, NULL, OPTION_NON_SHARED},
de71eb77 149 {"subsystem", required_argument, NULL, OPTION_SUBSYSTEM}, /* WINDOWS_NT */
d5b79a89 150 {"Tbss", required_argument, NULL, OPTION_TBSS},
d5b79a89 151 {"Tdata", required_argument, NULL, OPTION_TDATA},
d5b79a89 152 {"Ttext", required_argument, NULL, OPTION_TTEXT},
c96386c4 153 {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT},
d5b79a89 154 {"Ur", no_argument, NULL, OPTION_UR},
de71eb77 155 {"verbose", no_argument, NULL, OPTION_VERBOSE},
d5b79a89 156 {"version", no_argument, NULL, OPTION_VERSION},
d5b79a89 157 {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
809ee7e0 158 {"warn-once", no_argument, NULL, OPTION_WARN_ONCE},
de71eb77
SC
159 {"split-by-reloc", required_argument, NULL, OPTION_SPLIT_BY_RELOC},
160 {"split-by-file", no_argument, NULL, OPTION_SPLIT_BY_FILE},
161 {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
162 {"base-file", required_argument, NULL, OPTION_BASE_FILE},
d4e5e3c3
DM
163 {NULL, no_argument, NULL, 0}
164 };
165
22d3533c
ILT
166 /* The -G option is ambiguous on different platforms. Sometimes it
167 specifies the largest data size to put into the small data
168 section. Sometimes it is equivalent to --shared. Unfortunately,
169 the first form takes an argument, while the second does not.
170
171 We need to permit the --shared form because on some platforms,
172 such as Solaris, gcc -shared will pass -G to the linker.
173
174 To permit either usage, we look through the argument list. If we
175 find -G not followed by a number, we change it into --shared.
176 This will work for most normal cases. */
177 for (i = 1; i < argc; i++)
178 if (strcmp (argv[i], "-G") == 0
179 && (i + 1 >= argc
180 || ! isdigit (argv[i + 1][0])))
181 argv[i] = (char *) "--shared";
182
d4e5e3c3
DM
183 while (1)
184 {
185 /* getopt_long_only is like getopt_long, but '-' as well as '--' can
186 indicate a long option. */
d5b79a89
DM
187 int longind;
188 int optc = getopt_long_only (argc, argv, shortopts, longopts, &longind);
189
d4e5e3c3
DM
190 if (optc == -1)
191 break;
192
193 switch (optc)
194 {
195 default:
196 xexit (1);
197 case 1: /* File name. */
198 lang_add_input_file (optarg, lang_input_file_is_file_enum,
199 (char *) NULL);
200 break;
201
2a9fa50c
ILT
202 case OPTION_IGNORE:
203 break;
de71eb77
SC
204 case 'a':
205 /* For HP/UX compatibility. Actually -a shared should mean
206 ``use only shared libraries'' but, then, we don't
207 currently support shared libraries on HP/UX anyhow. */
208 if (strcmp (optarg, "archive") == 0)
209 config.dynamic_link = false;
210 else if (strcmp (optarg, "shared") == 0
211 || strcmp (optarg, "default") == 0)
212 config.dynamic_link = true;
213 else
214 einfo ("%P%F: unrecognized -a option `%s'\n", optarg);
215 break;
d4e5e3c3
DM
216 case 'A':
217 ldfile_add_arch (optarg);
218 break;
d4e5e3c3
DM
219 case 'b':
220 lang_add_target (optarg);
221 break;
222 case 'c':
223 ldfile_open_command_file (optarg);
224 parser_input = input_mri_script;
225 yyparse ();
226 break;
d5b79a89 227 case OPTION_CALL_SHARED:
2a9fa50c
ILT
228 config.dynamic_link = true;
229 break;
230 case OPTION_NON_SHARED:
231 config.dynamic_link = false;
d4e5e3c3
DM
232 break;
233 case 'd':
234 command_line.force_common_definition = true;
235 break;
d5b79a89 236 case OPTION_DEFSYM:
d4e5e3c3
DM
237 lex_redirect (optarg);
238 parser_input = input_defsym;
239 yyparse ();
240 break;
7fb9ca5f
ILT
241 case OPTION_DYNAMIC_LINKER:
242 command_line.interpreter = optarg;
243 break;
d5b79a89 244 case OPTION_EB:
86037281 245 command_line.endian = ENDIAN_BIG;
d4e5e3c3 246 break;
d5b79a89 247 case OPTION_EL:
86037281 248 command_line.endian = ENDIAN_LITTLE;
d4e5e3c3 249 break;
de71eb77
SC
250 case OPTION_EMBEDDED_RELOCS:
251 command_line.embedded_relocs = true;
252 break;
253 case OPTION_EXPORT_DYNAMIC:
254 command_line.export_dynamic = true;
255 break;
d4e5e3c3 256 case 'e':
60e8a534 257 lang_add_entry (optarg, 1);
d4e5e3c3
DM
258 break;
259 case 'F':
260 /* Ignore. */
261 break;
262 case 'G':
263 {
264 char *end;
265 g_switch_value = strtoul (optarg, &end, 0);
266 if (*end)
9d3898b2 267 einfo ("%P%F: invalid number `%s'\n", optarg);
d4e5e3c3
DM
268 }
269 break;
270 case 'g':
271 /* Ignore. */
272 break;
de71eb77
SC
273 case OPTION_HEAP: /* WINDOWS_NT */
274 link_info.stack_heap_parameters.heap_defined = true;
275 set_stack_heap (optarg, true);
276 break;
d5b79a89 277 case OPTION_HELP:
d4e5e3c3
DM
278 help ();
279 xexit (0);
280 break;
281 case 'L':
0cd82d00 282 ldfile_add_library_path (optarg, true);
d4e5e3c3
DM
283 break;
284 case 'l':
285 lang_add_input_file (optarg, lang_input_file_is_l_enum,
286 (char *) NULL);
287 break;
288 case 'M':
289 config.map_filename = "-";
290 break;
291 case 'm':
292 /* Ignore. Was handled in a pre-parse. */
293 break;
d5b79a89 294 case OPTION_MAP:
d4e5e3c3
DM
295 config.map_filename = optarg;
296 break;
297 case 'N':
298 config.text_read_only = false;
299 config.magic_demand_paged = false;
300 break;
301 case 'n':
302 config.magic_demand_paged = false;
303 break;
d5b79a89 304 case OPTION_NO_KEEP_MEMORY:
d4e5e3c3
DM
305 link_info.keep_memory = false;
306 break;
d5b79a89 307 case OPTION_NOINHIBIT_EXEC:
d4e5e3c3
DM
308 force_make_executable = true;
309 break;
310 case 'O':
311 /* FIXME "-O<non-digits> <value>" used to set the address of
312 section <non-digits>. Was this for compatibility with
313 something, or can we create a new option to do that
314 (with a syntax similar to -defsym)?
315 getopt can't handle two args to an option without kludges. */
316 set_default_dirlist (optarg);
317 break;
318 case 'o':
319 lang_add_output (optarg, 0);
320 break;
d5b79a89 321 case OPTION_OFORMAT:
86037281 322 lang_add_output_format (optarg, (char *) NULL, (char *) NULL, 0);
d4e5e3c3 323 break;
3e1fd33d 324 case 'i':
d4e5e3c3
DM
325 case 'r':
326 link_info.relocateable = true;
327 config.build_constructors = false;
328 config.magic_demand_paged = false;
329 config.text_read_only = false;
2a9fa50c 330 config.dynamic_link = false;
d4e5e3c3
DM
331 break;
332 case 'R':
809ee7e0
ILT
333 /* The GNU linker traditionally uses -R to mean to include
334 only the symbols from a file. The Solaris linker uses -R
335 to set the path used by the runtime linker to find
336 libraries. This is the GNU linker -rpath argument. We
337 try to support both simultaneously by checking the file
338 named. If it is a directory, rather than a regular file,
339 we assume -rpath was meant. */
340 {
341 struct stat s;
342
343 if (stat (optarg, &s) >= 0
344 && ! S_ISDIR (s.st_mode))
345 {
346 lang_add_input_file (optarg,
347 lang_input_file_is_symbols_only_enum,
348 (char *) NULL);
349 break;
350 }
351 }
352 /* Fall through. */
353 case OPTION_RPATH:
354 if (command_line.rpath == NULL)
355 command_line.rpath = buystring (optarg);
356 else
357 {
358 char *buf;
359
360 buf = xmalloc (strlen (command_line.rpath)
361 + strlen (optarg)
362 + 2);
363 sprintf (buf, "%s:%s", command_line.rpath, optarg);
364 free (command_line.rpath);
365 command_line.rpath = buf;
366 }
d4e5e3c3 367 break;
d5b79a89 368 case OPTION_RELAX:
d4e5e3c3
DM
369 command_line.relax = true;
370 break;
d5b79a89 371 case OPTION_RETAIN_SYMBOLS_FILE:
d4e5e3c3
DM
372 add_keepsyms_file (optarg);
373 break;
374 case 'S':
375 link_info.strip = strip_debugger;
376 break;
377 case 's':
378 link_info.strip = strip_all;
379 break;
db770dfa
ILT
380 case OPTION_SHARED:
381 link_info.shared = true;
382 break;
809ee7e0
ILT
383 case OPTION_SONAME:
384 command_line.soname = optarg;
385 break;
d5b79a89 386 case OPTION_SORT_COMMON:
d4e5e3c3
DM
387 config.sort_common = true;
388 break;
de71eb77
SC
389 case OPTION_STACK: /* WINDOWS_NT */
390 link_info.stack_heap_parameters.stack_defined = true;
391 set_stack_heap (optarg, false);
392 break;
d5b79a89 393 case OPTION_STATS:
d4e5e3c3
DM
394 config.stats = true;
395 break;
de71eb77
SC
396 case OPTION_SUBSYSTEM: /* WINDOWS_NT */
397 set_subsystem (optarg);
398 break;
4551e108
ILT
399 case OPTION_SYMBOLIC:
400 link_info.symbolic = true;
401 break;
d4e5e3c3
DM
402 case 't':
403 trace_files = true;
404 break;
405 case 'T':
406 ldfile_open_command_file (optarg);
407 parser_input = input_script;
408 yyparse ();
409 break;
d5b79a89 410 case OPTION_TBSS:
d4e5e3c3
DM
411 set_section_start (".bss", optarg);
412 break;
d5b79a89 413 case OPTION_TDATA:
d4e5e3c3
DM
414 set_section_start (".data", optarg);
415 break;
d5b79a89 416 case OPTION_TTEXT:
d4e5e3c3
DM
417 set_section_start (".text", optarg);
418 break;
c96386c4
ILT
419 case OPTION_TRADITIONAL_FORMAT:
420 config.traditional_format = true;
421 break;
d5b79a89 422 case OPTION_UR:
d4e5e3c3
DM
423 link_info.relocateable = true;
424 config.build_constructors = true;
425 config.magic_demand_paged = false;
426 config.text_read_only = false;
2a9fa50c 427 config.dynamic_link = false;
d4e5e3c3
DM
428 break;
429 case 'u':
430 ldlang_add_undef (optarg);
431 break;
de71eb77 432 case OPTION_VERBOSE:
d4e5e3c3
DM
433 ldversion (1);
434 version_printed = true;
435 trace_file_tries = true;
436 break;
437 case 'v':
438 ldversion (0);
439 version_printed = true;
440 break;
de71eb77
SC
441 case 'V':
442 ldversion (1);
443 version_printed = true;
444 break;
d5b79a89 445 case OPTION_VERSION:
d4e5e3c3
DM
446 ldversion (0);
447 version_printed = true;
448 break;
d5b79a89 449 case OPTION_WARN_COMMON:
d4e5e3c3
DM
450 config.warn_common = true;
451 break;
809ee7e0
ILT
452 case OPTION_WARN_ONCE:
453 config.warn_once = true;
454 break;
de71eb77
SC
455 case OPTION_WHOLE_ARCHIVE:
456 whole_archive = true;
457 break;
458 case OPTION_BASE_FILE:
243e7698
ILT
459 link_info.base_file = (PTR) fopen (optarg,"w");
460 if (link_info.base_file == NULL)
461 {
462 fprintf (stderr, "%s: Can't open base file %s\n",
463 program_name, optarg);
464 xexit (1);
465 }
de71eb77 466 break;
d4e5e3c3
DM
467 case 'X':
468 link_info.discard = discard_l;
469 break;
470 case 'x':
471 link_info.discard = discard_all;
472 break;
d5b79a89
DM
473 case 'Y':
474 set_default_dirlist (optarg);
475 break;
d4e5e3c3
DM
476 case 'y':
477 add_ysym (optarg);
478 break;
22d3533c
ILT
479 case 'z':
480 /* We accept and ignore this option for Solaris
481 compatibility. Actually, on Solaris, optarg is not
482 ignored. Someday we should handle it correctly. FIXME. */
483 break;
de71eb77
SC
484 case OPTION_SPLIT_BY_RELOC:
485 config.split_by_reloc = atoi (optarg);
486 break;
487 case OPTION_SPLIT_BY_FILE:
488 config.split_by_file = true;
489 break;
db770dfa
ILT
490 case '(':
491 if (ingroup)
492 {
493 fprintf (stderr,
494 "%s: may not nest groups (--help for usage)\n",
495 program_name);
496 xexit (1);
497 }
498 lang_enter_group ();
499 ingroup = 1;
500 break;
501 case ')':
502 if (! ingroup)
503 {
504 fprintf (stderr,
505 "%s: group ended before it began (--help for usage)\n",
506 program_name);
507 xexit (1);
508 }
509 lang_leave_group ();
510 ingroup = 0;
511 break;
d4e5e3c3
DM
512 }
513 }
db770dfa
ILT
514
515 if (ingroup)
516 lang_leave_group ();
d4e5e3c3
DM
517}
518
519/* Add the (colon-separated) elements of DIRLIST_PTR to the
520 library search path. */
521
522static void
523set_default_dirlist (dirlist_ptr)
524 char *dirlist_ptr;
525{
526 char *p;
527
528 while (1)
529 {
530 p = strchr (dirlist_ptr, ':');
531 if (p != NULL)
532 *p = 0;
533 if (*dirlist_ptr)
0cd82d00 534 ldfile_add_library_path (dirlist_ptr, true);
d4e5e3c3
DM
535 if (p == NULL)
536 break;
537 *p = ':';
538 dirlist_ptr = p + 1;
539 }
540}
541
542static void
543set_section_start (sect, valstr)
544 char *sect, *valstr;
545{
546 char *end;
547 unsigned long val = strtoul (valstr, &end, 16);
548 if (*end)
d5b79a89 549 einfo ("%P%F: invalid hex number `%s'\n", valstr);
d4e5e3c3
DM
550 lang_section_start (sect, exp_intop (val));
551}
de71eb77
SC
552
553/* WINDOWS_NT; added routines to get the subsystem type, heap and/or stack
554 parameters which may be input from the command line */
555static void
556set_subsystem (subsystem_type)
557 char *subsystem_type;
558{
559 if (strcmp (subsystem_type, "native") == 0)
560 {
561 link_info.subsystem = native;
562 }
563 else if (strcmp (subsystem_type, "windows") == 0)
564 {
565 link_info.subsystem = windows;
566 }
567 else if (strcmp (subsystem_type, "console") == 0)
568 {
569 link_info.subsystem = console;
570 }
571 else if (strcmp (subsystem_type, "os2") == 0)
572 {
573 link_info.subsystem = os2;
574 }
575 else if (strcmp (subsystem_type, "posix") == 0)
576 {
577 link_info.subsystem = posix;
578 }
579 else
580 einfo ("%P%F: invalid subsystem type `%s'\n", subsystem_type);
581
582}
583
584static void
585set_stack_heap (valstr, for_heap)
586 char *valstr;
587 boolean for_heap;
588{
589 char *begin_commit, *end;
590 bfd_vma reserve = 0;
591 bfd_vma commit = 0;
592
593 /* There may be two values passed in to the -stack or -heap switches like
594 this:
595 -stack 0x10000,0x100
596 where the first parameter is the stack (or heap) reserve and the second
597 is commit. The second parameter is optional. */
598
599 /* get the reserve value */
600 reserve = strtoul (valstr, &begin_commit, 16);
601
602 if (strcmp (valstr, begin_commit) == 0)
603 /* the reserve value couldn't be read */
604 einfo ("%P%F: invalid hex number for reserve[,commit] '%s'\n", valstr);
605 else if (strcmp (begin_commit, "\0") != 0) /* check for a commit value */
606 {
607 begin_commit += 1; /* increment begin_commit to point past ',' */
608 commit = strtoul (begin_commit, &end, 16);
609 if (strcmp (end, begin_commit) == 0)
610 einfo ("%P%F: invalid hex number for commit '%s'\n", begin_commit);
611 }
612
613 if (for_heap)
614 {
615 link_info.stack_heap_parameters.heap_reserve = reserve;
616 link_info.stack_heap_parameters.heap_commit = commit;
617 }
618 else
619 {
620 link_info.stack_heap_parameters.stack_reserve = reserve;
621 link_info.stack_heap_parameters.stack_commit = commit;
622 }
623
624#if DUMP_INFO
625 printf ("reserve = %8x commit = %8x\n", reserve, commit);
626#endif
627}
This page took 0.244645 seconds and 4 git commands to generate.