040fc17bb28eeaca3570f9ccdab3c3dc747b7f5b
[fw/sdcc] / as / link / lklibr.h
1 /* lklibr.h
2
3    Copyright (C) 1989-1995 Alan R. Baldwin
4    721 Berkeley St., Kent, Ohio 44240
5    Copyright (C) 2008 Borut Razem, borut dot razem at siol dot net
6
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
10 later version.
11
12 This program 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 this program; if not, write to the Free Software
19 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21 /*
22  * With contributions for the
23  * object libraries from
24  * Ken Hornstein
25  * kenh@cmf.nrl.navy.mil
26  *
27  */
28
29 /*
30  * Extensions: P. Felber
31  */
32
33 #ifndef __LKLIBR_H
34 #define __LKLIBR_H
35
36 #include <stdio.h>
37
38 #ifdef INDEXLIB
39 typedef struct slibrarysymbol mlibrarysymbol;
40 typedef struct slibrarysymbol *pmlibrarysymbol;
41
42 struct slibrarysymbol
43 {
44   char *name;                   /* Warning: allocate memory before using */
45   pmlibrarysymbol next;
46 };
47
48 typedef struct slibraryfile mlibraryfile;
49 typedef struct slibraryfile *pmlibraryfile;
50
51 struct slibraryfile
52 {
53   int loaded;
54   char *libspc;
55   char *relfil;                 /* Warning: allocate memory before using */
56   char *filspc;                 /* Warning: allocate memory before using */
57   long offset;                  /* The embedded file offset in the library file libspc */
58   unsigned int type;
59   pmlibrarysymbol symbols;
60   pmlibraryfile next;
61 };
62
63 extern pmlibraryfile libr;
64
65 pmlibrarysymbol add_rel_index (FILE * fp, long size, pmlibraryfile This);
66 #else
67 int is_module_loaded (const char *filspc);
68 int add_rel_file (const char *name, struct lbname *lbnh, const char *relfil,
69                   const char *filspc, int offset, FILE * fp, long size, int type);
70 #endif
71
72 struct aslib_target
73 {
74   int (*is_lib) (FILE * libfp);
75 #ifdef INDEXLIB
76     pmlibraryfile (*buildlibraryindex) (struct lbname * lbnh, FILE * libfp, pmlibraryfile This, int type);
77 #else
78   int (*fndsym) (const char *name, struct lbname * lbnh, FILE * libfp, int type);
79 #endif
80   void (*loadfile) (struct lbfile * lbfh);
81 };
82
83 extern struct aslib_target aslib_target_sdcclib;
84 extern struct aslib_target aslib_target_ar;
85 extern struct aslib_target aslib_target_lib;
86
87 ////
88 //#define DEBUG_PRINT
89
90 #ifdef DEBUG_PRINT
91 # define D  printf
92 #else
93 # define D  1 ? (void)0 : (*(void (*)(const char *, ...))0)
94 #endif
95
96 #endif /* __LKLIBR_H */