1 /*****************************************************************************/
5 /* Handling object file data for the ld65 linker */
9 /* (C) 1998-2011, Ullrich von Bassewitz */
10 /* Roemerstrasse 52 */
11 /* D-70794 Filderstadt */
12 /* EMail: uz@cc65.org */
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. */
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: */
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 */
32 /*****************************************************************************/
48 /*****************************************************************************/
50 /*****************************************************************************/
54 /* Values for the Flags field */
55 #define OBJ_REF 0x0001 /* We have a reference to this file */
57 /* Internal structure holding object file data */
58 typedef struct ObjData 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 */
67 Collection Files; /* List of input files */
68 Collection Sections; /* List of all sections */
69 Collection Exports; /* List of all exports */
70 Collection Imports; /* List of all imports */
71 Collection DbgSyms; /* List of debug symbols */
72 Collection LineInfos; /* List of line infos */
73 unsigned StringCount; /* Count of strings */
74 unsigned* Strings; /* List of global string indices */
75 Collection Assertions; /* List of module assertions */
76 Collection Scopes; /* List of scopes */
81 /* Collection containing used ObjData objects */
82 extern Collection ObjDataList;
86 /*****************************************************************************/
88 /*****************************************************************************/
92 ObjData* NewObjData (void);
93 /* Allocate a new structure on the heap, insert it into the list, return it */
95 void FreeObjData (ObjData* O);
96 /* Free an ObjData object. NOTE: This function works only for unused object
97 * data, that is, ObjData objects that aren't used because they aren't
101 void FreeObjStrings (ObjData* O);
102 /* Free the module string data. Used once the object file is loaded completely
103 * when all strings are converted to global strings.
106 void InsertObjData (ObjData* O);
107 /* Insert the ObjData object into the collection of used ObjData objects. */
109 void InsertObjGlobals (ObjData* O);
110 /* Insert imports and exports from the object file into the global import and
114 unsigned MakeGlobalStringId (const ObjData* O, unsigned Index);
115 /* Convert a local string id into a global one and return it. */
117 const char* GetObjFileName (const ObjData* O);
118 /* Get the name of the object file. Return "[linker generated]" if the object
122 #if defined(HAVE_INLINE)
123 INLINE int ObjHasFiles (const ObjData* O)
124 /* Return true if the files list does exist */
126 return (O != 0 && CollCount (&O->Files) != 0);
129 # define ObjHasFiles(O) ((O) != 0 && CollCount (&(O)->Files) != 0)
134 /* End of objdata.h */