/*****************************************************************************/
/* */
-/* objdata.c */
+/* objdata.c */
/* */
-/* Handling object file data for the ld65 linker */
+/* Handling object file data for the ld65 linker */
/* */
/* */
/* */
/*****************************************************************************/
-/* Data */
+/* Data */
/*****************************************************************************/
/*****************************************************************************/
-/* Code */
+/* Code */
/*****************************************************************************/
ObjData* O = xmalloc (sizeof (ObjData));
/* Initialize the data */
- O->Next = 0;
- O->Name = INVALID_STRING_ID;
+ O->Next = 0;
+ O->Name = INVALID_STRING_ID;
O->Lib = 0;
O->MTime = 0;
- O->Start = 0;
- O->Flags = 0;
+ O->Start = 0;
+ O->Flags = 0;
+ O->HLLSymBaseId = 0;
O->SymBaseId = 0;
O->ScopeBaseId = 0;
+ O->SpanBaseId = 0;
O->Files = EmptyCollection;
O->Sections = EmptyCollection;
- O->Exports = EmptyCollection;
- O->Imports = EmptyCollection;
- O->DbgSyms = EmptyCollection;
+ O->Exports = EmptyCollection;
+ O->Imports = EmptyCollection;
+ O->DbgSyms = EmptyCollection;
+ O->HLLDbgSyms = EmptyCollection;
O->LineInfos = EmptyCollection;
O->StringCount = 0;
O->Strings = 0;
O->Assertions = EmptyCollection;
O->Scopes = EmptyCollection;
+ O->Spans = EmptyCollection;
/* Return the new entry */
return O;
}
DoneCollection (&O->Imports);
DoneCollection (&O->DbgSyms);
+ DoneCollection (&O->HLLDbgSyms);
for (I = 0; I < CollCount (&O->LineInfos); ++I) {
FreeLineInfo (CollAtUnchecked (&O->LineInfos, I));
xfree (O->Strings);
DoneCollection (&O->Assertions);
DoneCollection (&O->Scopes);
+ for (I = 0; I < CollCount (&O->Spans); ++I) {
+ FreeSpan (CollAtUnchecked (&O->Spans, I));
+ }
+ DoneCollection (&O->Spans);
+
xfree (O);
}
/* Convert a local string id into a global one and return it. */
{
if (Index >= O->StringCount) {
- Error ("Invalid string index (%u) in module `%s'",
- Index, GetObjFileName (O));
+ Error ("Invalid string index (%u) in module `%s'",
+ Index, GetObjFileName (O));
}
return O->Strings[Index];
}
-struct Section* GetObjSection (ObjData* O, unsigned Id)
+const struct StrBuf* GetObjString (const ObjData* Obj, unsigned Id)
+/* Get a string from an object file checking for an invalid index */
+{
+ return GetStrBuf (MakeGlobalStringId (Obj, Id));
+}
+
+
+
+struct Section* GetObjSection (const ObjData* O, unsigned Id)
/* Get a section from an object file checking for a valid index */
{
if (Id >= CollCount (&O->Sections)) {
-struct Scope* GetObjScope (ObjData* O, unsigned Id)
+struct Import* GetObjImport (const ObjData* O, unsigned Id)
+/* Get an import from an object file checking for a valid index */
+{
+ if (Id >= CollCount (&O->Imports)) {
+ Error ("Invalid import index (%u) in module `%s'",
+ Id, GetObjFileName (O));
+ }
+ return CollAtUnchecked (&O->Imports, Id);
+}
+
+
+
+struct Export* GetObjExport (const ObjData* O, unsigned Id)
+/* Get an export from an object file checking for a valid index */
+{
+ if (Id >= CollCount (&O->Exports)) {
+ Error ("Invalid export index (%u) in module `%s'",
+ Id, GetObjFileName (O));
+ }
+ return CollAtUnchecked (&O->Exports, Id);
+}
+
+
+
+struct DbgSym* GetObjDbgSym (const ObjData* O, unsigned Id)
+/* Get a debug symbol from an object file checking for a valid index */
+{
+ if (Id >= CollCount (&O->DbgSyms)) {
+ Error ("Invalid debug symbol index (%u) in module `%s'",
+ Id, GetObjFileName (O));
+ }
+ return CollAtUnchecked (&O->DbgSyms, Id);
+}
+
+
+
+struct Scope* GetObjScope (const ObjData* O, unsigned Id)
/* Get a scope from an object file checking for a valid index */
{
if (Id >= CollCount (&O->Scopes)) {
}
}
-
-
-