4 * Copyright 1993 Robert J. Amstadt
5 * Copyright 1995 Martin von Loewis
6 * Copyright 1995, 1996, 1997, 2004 Alexandre Julliard
7 * Copyright 1997 Eric Youngdale
8 * Copyright 1999 Ulrich Weigand
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/port.h"
39 static char ParseBuffer[512];
40 static char TokenBuffer[512];
41 static char *ParseNext = ParseBuffer;
42 static FILE *input_file;
44 static const char *separator_chars;
45 static const char *comment_chars;
47 /* valid characters in ordinal names */
48 static const char valid_ordname_chars[] = "/$:-_@?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
50 static const char * const TypeNames[TYPE_NBTYPES] =
52 "variable", /* TYPE_VARIABLE */
53 "pascal", /* TYPE_PASCAL */
54 "equate", /* TYPE_ABS */
55 "stub", /* TYPE_STUB */
56 "stdcall", /* TYPE_STDCALL */
57 "cdecl", /* TYPE_CDECL */
58 "varargs", /* TYPE_VARARGS */
59 "extern" /* TYPE_EXTERN */
62 static const char * const FlagNames[] =
64 "norelay", /* FLAG_NORELAY */
65 "noname", /* FLAG_NONAME */
66 "ret16", /* FLAG_RET16 */
67 "ret64", /* FLAG_RET64 */
68 "register", /* FLAG_REGISTER */
69 "private", /* FLAG_PRIVATE */
70 "ordinal", /* FLAG_ORDINAL */
74 static int IsNumberString(const char *s)
76 while (*s) if (!isdigit(*s++)) return 0;
80 static inline int is_token_separator( char ch )
82 return strchr( separator_chars, ch ) != NULL;
85 static inline int is_token_comment( char ch )
87 return strchr( comment_chars, ch ) != NULL;
90 /* get the next line from the input file, or return 0 if at eof */
91 static int get_next_line(void)
93 ParseNext = ParseBuffer;
95 return (fgets(ParseBuffer, sizeof(ParseBuffer), input_file) != NULL);
98 static const char * GetToken( int allow_eol )
101 char *token = TokenBuffer;
105 /* remove initial white space */
107 while (isspace(*p)) p++;
109 if (*p == '\\' && p[1] == '\n') /* line continuation */
111 if (!get_next_line())
113 if (!allow_eol) error( "Unexpected end of file\n" );
120 if ((*p == '\0') || is_token_comment(*p))
122 if (!allow_eol) error( "Declaration not terminated properly\n" );
129 if (is_token_separator(*p))
131 /* a separator is always a complete token */
134 else while (*p != '\0' && !is_token_separator(*p) && !isspace(*p))
137 if (*p) *token++ = *p++;
145 static ORDDEF *add_entry_point( DLLSPEC *spec )
149 if (spec->nb_entry_points == spec->alloc_entry_points)
151 spec->alloc_entry_points += 128;
152 spec->entry_points = xrealloc( spec->entry_points,
153 spec->alloc_entry_points * sizeof(*spec->entry_points) );
155 ret = &spec->entry_points[spec->nb_entry_points++];
156 memset( ret, 0, sizeof(*ret) );
160 /*******************************************************************
161 * parse_spec_variable
163 * Parse a variable definition in a .spec file.
165 static int parse_spec_variable( ORDDEF *odp, DLLSPEC *spec )
170 int value_array_size;
173 if (spec->type == SPEC_WIN32)
175 error( "'variable' not supported in Win32, use 'extern' instead\n" );
179 if (!(token = GetToken(0))) return 0;
182 error( "Expected '(' got '%s'\n", token );
187 value_array_size = 25;
188 value_array = xmalloc(sizeof(*value_array) * value_array_size);
192 if (!(token = GetToken(0)))
200 value_array[n_values++] = strtol(token, &endptr, 0);
201 if (n_values == value_array_size)
203 value_array_size += 25;
204 value_array = xrealloc(value_array,
205 sizeof(*value_array) * value_array_size);
208 if (endptr == NULL || *endptr != '\0')
210 error( "Expected number value, got '%s'\n", token );
216 odp->u.var.n_values = n_values;
217 odp->u.var.values = xrealloc(value_array, sizeof(*value_array) * n_values);
222 /*******************************************************************
225 * Parse an exported function definition in a .spec file.
227 static int parse_spec_export( ORDDEF *odp, DLLSPEC *spec )
231 int is_win32 = (spec->type == SPEC_WIN32) || (odp->flags & FLAG_EXPORT32);
233 if (!is_win32 && odp->type == TYPE_STDCALL)
235 error( "'stdcall' not supported for Win16\n" );
238 if (is_win32 && odp->type == TYPE_PASCAL)
240 error( "'pascal' not supported for Win32\n" );
244 if (!(token = GetToken(0))) return 0;
247 error( "Expected '(' got '%s'\n", token );
251 for (i = 0; i < sizeof(odp->u.func.arg_types); i++)
253 if (!(token = GetToken(0))) return 0;
257 if (!strcmp(token, "word"))
258 odp->u.func.arg_types[i] = 'w';
259 else if (!strcmp(token, "s_word"))
260 odp->u.func.arg_types[i] = 's';
261 else if (!strcmp(token, "long") || !strcmp(token, "segptr"))
262 odp->u.func.arg_types[i] = 'l';
263 else if (!strcmp(token, "ptr"))
264 odp->u.func.arg_types[i] = 'p';
265 else if (!strcmp(token, "str"))
266 odp->u.func.arg_types[i] = 't';
267 else if (!strcmp(token, "wstr"))
268 odp->u.func.arg_types[i] = 'W';
269 else if (!strcmp(token, "segstr"))
270 odp->u.func.arg_types[i] = 'T';
271 else if (!strcmp(token, "double"))
273 odp->u.func.arg_types[i++] = 'l';
274 if (get_ptr_size() == 4 && i < sizeof(odp->u.func.arg_types))
275 odp->u.func.arg_types[i] = 'l';
279 error( "Unknown argument type '%s'\n", token );
285 if (strcmp(token, "long") &&
286 strcmp(token, "ptr") &&
287 strcmp(token, "str") &&
288 strcmp(token, "wstr") &&
289 strcmp(token, "double"))
291 error( "Type '%s' not supported for Win32 function\n", token );
296 if ((*token != ')') || (i >= sizeof(odp->u.func.arg_types)))
298 error( "Too many arguments\n" );
302 odp->u.func.arg_types[i] = '\0';
303 if (odp->type == TYPE_VARARGS)
304 odp->flags |= FLAG_NORELAY; /* no relay debug possible for varags entry point */
306 if (!(token = GetToken(1)))
308 if (!strcmp( odp->name, "@" ))
310 error( "Missing handler name for anonymous function\n" );
313 odp->link_name = xstrdup( odp->name );
317 odp->link_name = xstrdup( token );
318 if (strchr( odp->link_name, '.' ))
322 error( "Forwarded functions not supported for Win16\n" );
325 odp->flags |= FLAG_FORWARD;
332 /*******************************************************************
335 * Parse an 'equate' definition in a .spec file.
337 static int parse_spec_equate( ORDDEF *odp, DLLSPEC *spec )
343 if (spec->type == SPEC_WIN32)
345 error( "'equate' not supported for Win32\n" );
348 if (!(token = GetToken(0))) return 0;
349 value = strtol(token, &endptr, 0);
350 if (endptr == NULL || *endptr != '\0')
352 error( "Expected number value, got '%s'\n", token );
355 if (value < -0x8000 || value > 0xffff)
357 error( "Value %d for absolute symbol doesn't fit in 16 bits\n", value );
360 odp->u.abs.value = value;
365 /*******************************************************************
368 * Parse a 'stub' definition in a .spec file
370 static int parse_spec_stub( ORDDEF *odp, DLLSPEC *spec )
372 odp->u.func.arg_types[0] = '\0';
373 odp->link_name = xstrdup("");
374 odp->flags |= FLAG_CPU(CPU_x86) | FLAG_CPU(CPU_x86_64); /* don't bother generating stubs for Winelib */
379 /*******************************************************************
382 * Parse an 'extern' definition in a .spec file.
384 static int parse_spec_extern( ORDDEF *odp, DLLSPEC *spec )
388 if (spec->type == SPEC_WIN16)
390 error( "'extern' not supported for Win16, use 'variable' instead\n" );
393 if (!(token = GetToken(1)))
395 if (!strcmp( odp->name, "@" ))
397 error( "Missing handler name for anonymous extern\n" );
400 odp->link_name = xstrdup( odp->name );
404 odp->link_name = xstrdup( token );
405 if (strchr( odp->link_name, '.' )) odp->flags |= FLAG_FORWARD;
411 /*******************************************************************
414 * Parse the optional flags for an entry point in a .spec file.
416 static const char *parse_spec_flags( DLLSPEC *spec, ORDDEF *odp )
423 if (!(token = GetToken(0))) break;
424 if (!strncmp( token, "arch=", 5))
426 char *args = xstrdup( token + 5 );
427 char *cpu_name = strtok( args, "," );
430 if (!strcmp( cpu_name, "win32" ))
432 if (spec->type == SPEC_WIN32)
433 odp->flags |= FLAG_CPU_WIN32;
435 odp->flags |= FLAG_EXPORT32;
437 else if (!strcmp( cpu_name, "win64" ))
438 odp->flags |= FLAG_CPU_WIN64;
441 enum target_cpu cpu = get_cpu_from_name( cpu_name );
444 error( "Unknown architecture '%s'\n", cpu_name );
447 odp->flags |= FLAG_CPU( cpu );
449 cpu_name = strtok( NULL, "," );
453 else if (!strcmp( token, "i386" )) /* backwards compatibility */
455 odp->flags |= FLAG_CPU(CPU_x86);
459 for (i = 0; FlagNames[i]; i++)
460 if (!strcmp( FlagNames[i], token )) break;
463 error( "Unknown flag '%s'\n", token );
466 odp->flags |= 1 << i;
469 } while (token && *token == '-');
475 /*******************************************************************
478 * Parse an ordinal definition in a .spec file.
480 static int parse_spec_ordinal( int ordinal, DLLSPEC *spec )
484 ORDDEF *odp = add_entry_point( spec );
486 if (!(token = GetToken(0))) goto error;
488 for (odp->type = 0; odp->type < TYPE_NBTYPES; odp->type++)
489 if (TypeNames[odp->type] && !strcmp( token, TypeNames[odp->type] ))
492 if (odp->type >= TYPE_NBTYPES)
494 error( "Expected type after ordinal, found '%s' instead\n", token );
498 if (!(token = GetToken(0))) goto error;
499 if (*token == '-' && !(token = parse_spec_flags( spec, odp ))) goto error;
501 if (ordinal == -1 && spec->type != SPEC_WIN32 && !(odp->flags & FLAG_EXPORT32))
503 error( "'@' ordinals not supported for Win16\n" );
507 odp->name = xstrdup( token );
508 odp->lineno = current_line;
509 odp->ordinal = ordinal;
511 len = strspn( odp->name, valid_ordname_chars );
512 if (len < strlen( odp->name ))
514 error( "Character '%c' is not allowed in exported name '%s'\n", odp->name[len], odp->name );
521 if (!parse_spec_variable( odp, spec )) goto error;
527 if (!parse_spec_export( odp, spec )) goto error;
530 if (!parse_spec_equate( odp, spec )) goto error;
533 if (!parse_spec_stub( odp, spec )) goto error;
536 if (!parse_spec_extern( odp, spec )) goto error;
542 if ((odp->flags & FLAG_CPU_MASK) && !(odp->flags & FLAG_CPU(target_cpu)))
544 /* ignore this entry point */
545 spec->nb_entry_points--;
553 error( "Ordinal 0 is not valid\n" );
556 if (ordinal >= MAX_ORDINALS)
558 error( "Ordinal number %d too large\n", ordinal );
561 if (ordinal > spec->limit) spec->limit = ordinal;
562 if (ordinal < spec->base) spec->base = ordinal;
563 odp->ordinal = ordinal;
566 if (odp->type == TYPE_STDCALL && !(odp->flags & FLAG_PRIVATE))
568 if (!strcmp( odp->name, "DllRegisterServer" ) ||
569 !strcmp( odp->name, "DllUnregisterServer" ) ||
570 !strcmp( odp->name, "DllGetClassObject" ) ||
571 !strcmp( odp->name, "DllGetVersion" ) ||
572 !strcmp( odp->name, "DllInstall" ) ||
573 !strcmp( odp->name, "DllCanUnloadNow" ))
575 warning( "Function %s should be marked private\n", odp->name );
576 if (strcmp( odp->name, odp->link_name ))
577 warning( "Function %s should not use a different internal name (%s)\n",
578 odp->name, odp->link_name );
582 if (!strcmp( odp->name, "@" ) || odp->flags & (FLAG_NONAME | FLAG_ORDINAL))
586 if (!strcmp( odp->name, "@" ))
587 error( "Nameless function needs an explicit ordinal number\n" );
589 error( "Function imported by ordinal needs an explicit ordinal number\n" );
592 if (spec->type != SPEC_WIN32)
594 error( "Nameless functions not supported for Win16\n" );
597 if (!strcmp( odp->name, "@" ))
602 else if (!(odp->flags & FLAG_ORDINAL)) /* -ordinal only affects the import library */
604 odp->export_name = odp->name;
611 spec->nb_entry_points--;
617 static int name_compare( const void *ptr1, const void *ptr2 )
619 const ORDDEF *odp1 = *(const ORDDEF * const *)ptr1;
620 const ORDDEF *odp2 = *(const ORDDEF * const *)ptr2;
621 const char *name1 = odp1->name ? odp1->name : odp1->export_name;
622 const char *name2 = odp2->name ? odp2->name : odp2->export_name;
623 return strcmp( name1, name2 );
626 /*******************************************************************
629 * Build the name array and catch duplicates.
631 static void assign_names( DLLSPEC *spec )
633 int i, j, nb_exp_names = 0;
637 for (i = 0; i < spec->nb_entry_points; i++)
638 if (spec->entry_points[i].name) spec->nb_names++;
639 else if (spec->entry_points[i].export_name) nb_exp_names++;
641 if (!spec->nb_names && !nb_exp_names) return;
643 /* check for duplicates */
645 all_names = xmalloc( (spec->nb_names + nb_exp_names) * sizeof(all_names[0]) );
646 for (i = j = 0; i < spec->nb_entry_points; i++)
647 if (spec->entry_points[i].name || spec->entry_points[i].export_name)
648 all_names[j++] = &spec->entry_points[i];
650 qsort( all_names, j, sizeof(all_names[0]), name_compare );
652 for (i = 0; i < j - 1; i++)
654 const char *name1 = all_names[i]->name ? all_names[i]->name : all_names[i]->export_name;
655 const char *name2 = all_names[i+1]->name ? all_names[i+1]->name : all_names[i+1]->export_name;
656 if (!strcmp( name1, name2 ) &&
657 !((all_names[i]->flags ^ all_names[i+1]->flags) & FLAG_EXPORT32))
659 current_line = max( all_names[i]->lineno, all_names[i+1]->lineno );
660 error( "'%s' redefined\n%s:%d: First defined here\n",
661 name1, input_file_name,
662 min( all_names[i]->lineno, all_names[i+1]->lineno ) );
669 spec->names = xmalloc( spec->nb_names * sizeof(spec->names[0]) );
670 for (i = j = 0; i < spec->nb_entry_points; i++)
671 if (spec->entry_points[i].name) spec->names[j++] = &spec->entry_points[i];
673 /* sort the list of names */
674 qsort( spec->names, spec->nb_names, sizeof(spec->names[0]), name_compare );
678 /*******************************************************************
681 * Build the ordinal array.
683 static void assign_ordinals( DLLSPEC *spec )
685 int i, count, ordinal;
687 /* start assigning from base, or from 1 if no ordinal defined yet */
689 spec->base = MAX_ORDINALS;
691 for (i = 0; i < spec->nb_entry_points; i++)
693 ordinal = spec->entry_points[i].ordinal;
694 if (ordinal == -1) continue;
695 if (ordinal > spec->limit) spec->limit = ordinal;
696 if (ordinal < spec->base) spec->base = ordinal;
698 if (spec->base == MAX_ORDINALS) spec->base = 1;
699 if (spec->limit < spec->base) spec->limit = spec->base;
701 count = max( spec->limit + 1, spec->base + spec->nb_entry_points );
702 spec->ordinals = xmalloc( count * sizeof(spec->ordinals[0]) );
703 memset( spec->ordinals, 0, count * sizeof(spec->ordinals[0]) );
705 /* fill in all explicitly specified ordinals */
706 for (i = 0; i < spec->nb_entry_points; i++)
708 ordinal = spec->entry_points[i].ordinal;
709 if (ordinal == -1) continue;
710 if (spec->ordinals[ordinal])
712 current_line = max( spec->entry_points[i].lineno, spec->ordinals[ordinal]->lineno );
713 error( "ordinal %d redefined\n%s:%d: First defined here\n",
714 ordinal, input_file_name,
715 min( spec->entry_points[i].lineno, spec->ordinals[ordinal]->lineno ) );
717 else spec->ordinals[ordinal] = &spec->entry_points[i];
720 /* now assign ordinals to the rest */
721 for (i = 0, ordinal = spec->base; i < spec->nb_entry_points; i++)
723 if (spec->entry_points[i].ordinal != -1) continue;
724 while (spec->ordinals[ordinal]) ordinal++;
725 if (ordinal >= MAX_ORDINALS)
727 current_line = spec->entry_points[i].lineno;
728 fatal_error( "Too many functions defined (max %d)\n", MAX_ORDINALS );
730 spec->entry_points[i].ordinal = ordinal;
731 spec->ordinals[ordinal] = &spec->entry_points[i];
733 if (ordinal > spec->limit) spec->limit = ordinal;
737 /*******************************************************************
740 * Add the necessary exports to the 32-bit counterpart of a 16-bit module.
742 void add_16bit_exports( DLLSPEC *spec32, DLLSPEC *spec16 )
747 spec32->file_name = xstrdup( spec16->file_name );
748 if (spec16->characteristics & IMAGE_FILE_DLL)
750 spec32->characteristics = IMAGE_FILE_DLL;
751 spec32->init_func = xstrdup( "__wine_spec_dll_entry" );
754 /* add an export for the NE module */
756 odp = add_entry_point( spec32 );
757 odp->type = TYPE_EXTERN;
758 odp->flags = FLAG_PRIVATE;
759 odp->name = xstrdup( "__wine_spec_dos_header" );
762 odp->link_name = xstrdup( ".L__wine_spec_dos_header" );
764 if (spec16->main_module)
766 odp = add_entry_point( spec32 );
767 odp->type = TYPE_EXTERN;
768 odp->flags = FLAG_PRIVATE;
769 odp->name = xstrdup( "__wine_spec_main_module" );
772 odp->link_name = xstrdup( ".L__wine_spec_main_module" );
775 /* add the explicit win32 exports */
777 for (i = 1; i <= spec16->limit; i++)
779 ORDDEF *odp16 = spec16->ordinals[i];
781 if (!odp16 || !odp16->name) continue;
782 if (!(odp16->flags & FLAG_EXPORT32)) continue;
784 odp = add_entry_point( spec32 );
785 odp->flags = odp16->flags & ~FLAG_EXPORT32;
786 odp->type = odp16->type;
787 odp->name = xstrdup( odp16->name );
788 odp->lineno = odp16->lineno;
790 odp->link_name = xstrdup( odp16->link_name );
791 strcpy( odp->u.func.arg_types, odp16->u.func.arg_types );
794 assign_names( spec32 );
795 assign_ordinals( spec32 );
799 /*******************************************************************
802 * Parse a .spec file.
804 int parse_spec_file( FILE *file, DLLSPEC *spec )
811 comment_chars = "#;";
812 separator_chars = "()-";
814 while (get_next_line())
816 if (!(token = GetToken(1))) continue;
817 if (strcmp(token, "@") == 0)
819 if (!parse_spec_ordinal( -1, spec )) continue;
821 else if (IsNumberString(token))
823 if (!parse_spec_ordinal( atoi(token), spec )) continue;
827 error( "Expected ordinal declaration, got '%s'\n", token );
830 if ((token = GetToken(1))) error( "Syntax error near '%s'\n", token );
833 current_line = 0; /* no longer parsing the input file */
834 assign_names( spec );
835 assign_ordinals( spec );
840 /*******************************************************************
843 * Parse a LIBRARY declaration in a .def file.
845 static int parse_def_library( DLLSPEC *spec )
847 const char *token = GetToken(1);
849 if (!token) return 1;
850 if (strcmp( token, "BASE" ))
852 free( spec->file_name );
853 spec->file_name = xstrdup( token );
854 if (!(token = GetToken(1))) return 1;
856 if (strcmp( token, "BASE" ))
858 error( "Expected library name or BASE= declaration, got '%s'\n", token );
861 if (!(token = GetToken(0))) return 0;
862 if (strcmp( token, "=" ))
864 error( "Expected '=' after BASE, got '%s'\n", token );
867 if (!(token = GetToken(0))) return 0;
868 /* FIXME: do something with base address */
874 /*******************************************************************
875 * parse_def_stack_heap_size
877 * Parse a STACKSIZE or HEAPSIZE declaration in a .def file.
879 static int parse_def_stack_heap_size( int is_stack, DLLSPEC *spec )
881 const char *token = GetToken(0);
885 if (!token) return 0;
886 size = strtoul( token, &end, 0 );
889 error( "Invalid number '%s'\n", token );
892 if (is_stack) spec->stack_size = size / 1024;
893 else spec->heap_size = size / 1024;
894 if (!(token = GetToken(1))) return 1;
895 if (strcmp( token, "," ))
897 error( "Expected ',' after size, got '%s'\n", token );
900 if (!(token = GetToken(0))) return 0;
901 /* FIXME: do something with reserve size */
906 /*******************************************************************
909 * Parse an export declaration in a .def file.
911 static int parse_def_export( char *name, DLLSPEC *spec )
914 const char *token = GetToken(1);
915 ORDDEF *odp = add_entry_point( spec );
917 odp->lineno = current_line;
920 args = remove_stdcall_decoration( odp->name );
921 if (args == -1) odp->type = TYPE_CDECL;
924 odp->type = TYPE_STDCALL;
925 args /= get_ptr_size();
926 if (args >= sizeof(odp->u.func.arg_types))
928 error( "Too many arguments in stdcall function '%s'\n", odp->name );
931 for (i = 0; i < args; i++) odp->u.func.arg_types[i] = 'l';
934 /* check for optional internal name */
936 if (token && !strcmp( token, "=" ))
938 if (!(token = GetToken(0))) goto error;
939 odp->link_name = xstrdup( token );
940 remove_stdcall_decoration( odp->link_name );
945 odp->link_name = xstrdup( name );
948 /* check for optional ordinal */
950 if (token && token[0] == '@')
954 if (!IsNumberString( token+1 ))
956 error( "Expected number after '@', got '%s'\n", token+1 );
959 ordinal = atoi( token+1 );
962 error( "Ordinal 0 is not valid\n" );
965 if (ordinal >= MAX_ORDINALS)
967 error( "Ordinal number %d too large\n", ordinal );
970 odp->ordinal = ordinal;
974 /* check for other optional keywords */
978 if (!strcmp( token, "NONAME" ))
980 if (odp->ordinal == -1)
982 error( "NONAME requires an ordinal\n" );
985 odp->export_name = odp->name;
987 odp->flags |= FLAG_NONAME;
989 else if (!strcmp( token, "PRIVATE" ))
991 odp->flags |= FLAG_PRIVATE;
993 else if (!strcmp( token, "DATA" ))
995 odp->type = TYPE_EXTERN;
999 error( "Garbage text '%s' found at end of export declaration\n", token );
1002 token = GetToken(1);
1007 spec->nb_entry_points--;
1013 /*******************************************************************
1016 * Parse a .def file.
1018 int parse_def_file( FILE *file, DLLSPEC *spec )
1026 comment_chars = ";";
1027 separator_chars = ",=";
1029 while (get_next_line())
1031 if (!(token = GetToken(1))) continue;
1033 if (!strcmp( token, "LIBRARY" ) || !strcmp( token, "NAME" ))
1035 if (!parse_def_library( spec )) continue;
1038 else if (!strcmp( token, "STACKSIZE" ))
1040 if (!parse_def_stack_heap_size( 1, spec )) continue;
1043 else if (!strcmp( token, "HEAPSIZE" ))
1045 if (!parse_def_stack_heap_size( 0, spec )) continue;
1048 else if (!strcmp( token, "EXPORTS" ))
1051 if (!(token = GetToken(1))) continue;
1053 else if (!strcmp( token, "IMPORTS" ))
1056 if (!(token = GetToken(1))) continue;
1058 else if (!strcmp( token, "SECTIONS" ))
1061 if (!(token = GetToken(1))) continue;
1064 if (!in_exports) continue; /* ignore this line */
1065 if (!parse_def_export( xstrdup(token), spec )) continue;
1068 if ((token = GetToken(1))) error( "Syntax error near '%s'\n", token );
1071 current_line = 0; /* no longer parsing the input file */
1072 assign_names( spec );
1073 assign_ordinals( spec );