efd7834887201eb81791be8615101c69804f5d87
[external/binutils.git] / ld / deffile.h
1 /* deffile.h - header for .DEF file parser
2    Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
3    Written by DJ Delorie dj@cygnus.com
4
5    This file is part of GLD, the Gnu Linker.
6
7    GLD is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2, or (at your option)
10    any later version.
11
12    GLD is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GLD; see the file COPYING.  If not, write to the Free
19    Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20    02111-1307, USA.  */
21
22 #ifndef DEFFILE_H
23 #define DEFFILE_H
24
25 #include "ansidecl.h"
26
27 /* DEF storage definitions.  Note that any ordinal may be zero, and
28    any pointer may be NULL, if not defined by the DEF file.  */
29
30 typedef struct def_file_section {
31   char *name;                   /* always set */
32   char *class;                  /* may be NULL */
33   char flag_read, flag_write, flag_execute, flag_shared;
34 } def_file_section;
35
36 typedef struct def_file_export {
37   char *name;                   /* always set */
38   char *internal_name;          /* always set, may == name */
39   int ordinal;                  /* -1 if not specified */
40   int hint;
41   char flag_private, flag_constant, flag_noname, flag_data;
42 } def_file_export;
43
44 typedef struct def_file_module {
45   struct def_file_module *next;
46   void *user_data;
47   char name[1];                 /* extended via malloc */
48 } def_file_module;
49
50 typedef struct def_file_import {
51   char *internal_name;          /* always set */
52   def_file_module *module;      /* always set */
53   char *name;                   /* may be NULL; either this or ordinal will be set */
54   int ordinal;                  /* may be -1 */
55 } def_file_import;
56
57 typedef struct def_file {
58   /* from the NAME or LIBRARY command */
59   char *name;
60   int is_dll;                   /* -1 if NAME/LIBRARY not given */
61   bfd_vma base_address;         /* (bfd_vma)(-1) if unspecified */
62
63   /* from the DESCRIPTION command */
64   char *description;
65
66   /* from the STACK/HEAP command, -1 if unspecified */
67   int stack_reserve, stack_commit;
68   int heap_reserve, heap_commit;
69
70   /* from the SECTION/SEGMENT commands */
71   int num_section_defs;
72   def_file_section *section_defs;
73
74   /* from the EXPORTS commands */
75   int num_exports;
76   def_file_export *exports;
77
78   /* used by imports for module names */
79   def_file_module *modules;
80
81   /* from the IMPORTS commands */
82   int num_imports;
83   def_file_import *imports;
84
85   /* from the VERSION command, -1 if not specified */
86   int version_major, version_minor;
87 } def_file;
88
89 extern def_file *def_file_empty PARAMS ((void));
90
91 /* add_to may be NULL.  If not, this .def is appended to it */
92 extern def_file *def_file_parse PARAMS ((const char *_filename,
93                                          def_file * _add_to));
94
95 extern void def_file_free PARAMS ((def_file * _def));
96
97 extern def_file_export *def_file_add_export PARAMS ((def_file * _def,
98                                                      const char *_name,
99                                                  const char *_internal_name,
100                                                      int _ordinal));
101
102 extern def_file_import *def_file_add_import PARAMS ((def_file * _def,
103                                                      const char *_name,
104                                                      const char *_from,
105                                                      int _ordinal,
106                                                const char *_imported_name));
107
108 extern void def_file_add_directive PARAMS ((def_file * _def,
109                                             const char *param,
110                                             int len));
111
112 #ifdef DEF_FILE_PRINT
113 extern void def_file_print PARAMS ((FILE * _file, def_file * _def));
114 #endif
115
116 #endif /* DEFFILE_H */