]> git.sur5r.net Git - cc65/blob - src/ld65/objdata.h
Just comment and formatting changes.
[cc65] / src / ld65 / objdata.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 objdata.h                                 */
4 /*                                                                           */
5 /*               Handling object file data for the ld65 linker               */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998-2003 Ullrich von Bassewitz                                       */
10 /*               Römerstraße 52                                              */
11 /*               D-70794 Filderstadt                                         */
12 /* EMail:        uz@cc65.org                                                 */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef OBJDATA_H
37 #define OBJDATA_H
38
39
40
41 /* common */
42 #include "coll.h"
43 #include "inline.h"
44 #include "objdefs.h"
45
46
47
48 /*****************************************************************************/
49 /*                                   Data                                    */
50 /*****************************************************************************/
51
52
53
54 /* Values for the Flags field */
55 #define OBJ_REF         0x0001          /* We have a reference to this file */
56
57 /* Internal structure holding object file data */
58 typedef struct ObjData ObjData;
59 struct ObjData {
60     ObjData*            Next;           /* Linked list of all objects */
61     unsigned            Name;           /* Module name */
62     unsigned            LibName;        /* Name of library */
63     unsigned long       MTime;          /* Time of last modification */
64     ObjHeader           Header;         /* Header of file */
65     unsigned long       Start;          /* Start offset of data in library */
66     unsigned            Flags;
67     unsigned            FileCount;      /* Input file count */
68     struct FileInfo**   Files;          /* List of input files */
69     unsigned            SectionCount;   /* Count of sections in this object */
70     struct Section**    Sections;       /* List of all sections */
71     unsigned            ExportCount;    /* Count of exports */
72     struct Export**     Exports;        /* List of all exports */
73     unsigned            ImportCount;    /* Count of imports */
74     struct Import**     Imports;        /* List of all imports */
75     unsigned            DbgSymCount;    /* Count of debug symbols */
76     struct DbgSym**     DbgSyms;        /* List of debug symbols */
77     unsigned            LineInfoCount;  /* Count of additional line infos */
78     struct LineInfo**   LineInfos;      /* List of additional line infos */
79     unsigned            StringCount;    /* Count of strings */
80     unsigned*           Strings;        /* List of global string indices */
81     unsigned            AssertionCount; /* Count of module assertions */
82     struct Assertion**  Assertions;     /* List of module assertions */
83     unsigned            ScopeCount;     /* Count of scopes */
84     struct Scope**      Scopes;         /* List of scopes */
85 };
86
87
88
89 /* Collection containing used ObjData objects */
90 extern Collection       ObjDataList;
91
92
93
94 /*****************************************************************************/
95 /*                                   Code                                    */
96 /*****************************************************************************/
97
98
99
100 ObjData* NewObjData (void);
101 /* Allocate a new structure on the heap, insert it into the list, return it */
102
103 void FreeObjData (ObjData* O);
104 /* Free an ObjData object. NOTE: This function works only for unused object
105  * data, that is, ObjData objects that aren't used because they aren't
106  * referenced.
107  */
108
109 void FreeObjStrings (ObjData* O);
110 /* Free the module string data. Used once the object file is loaded completely
111  * when all strings are converted to global strings.
112  */
113
114 void InsertObjData (ObjData* O);
115 /* Insert the ObjData object into the collection of used ObjData objects. */
116
117 void InsertObjGlobals (ObjData* O);
118 /* Insert imports and exports from the object file into the global import and
119  * export lists.
120  */
121
122 unsigned MakeGlobalStringId (const ObjData* O, unsigned Index);
123 /* Convert a local string id into a global one and return it. */
124
125 const char* GetObjFileName (const ObjData* O);
126 /* Get the name of the object file. Return "[linker generated]" if the object
127  * file is NULL.
128  */
129
130 #if defined(HAVE_INLINE)
131 INLINE int ObjHasFiles (const ObjData* O)
132 /* Return true if the files list does exist */
133 {
134     return (O != 0 && O->Files != 0);
135 }
136 #else
137 #  define ObjHasFiles(O)       ((O) != 0 && (O)->Files != 0)
138 #endif
139
140 const char* GetSourceFileName (const ObjData* O, unsigned Index);
141 /* Get the name of the source file with the given index. If O is NULL, return
142  * "[linker generated]" as the file name.
143  */
144
145
146
147 /* End of objdata.h */
148
149 #endif
150
151
152
153
154