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