]> git.sur5r.net Git - cc65/blobdiff - src/ld65/objdata.c
Merge remote-tracking branch 'upstream/master' into a5200
[cc65] / src / ld65 / objdata.c
index b0a17d0e98192c1a8ffd32d1c51da4cd52c3b9fd..222615c4c1d239882f280e40e5ba4cc51b61da39 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                                objdata.c                                 */
+/*                                 objdata.c                                 */
 /*                                                                           */
-/*              Handling object file data for the ld65 linker               */
+/*               Handling object file data for the ld65 linker               */
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
@@ -50,7 +50,7 @@
 
 
 /*****************************************************************************/
-/*                                          Data                                    */
+/*                                   Data                                    */
 /*****************************************************************************/
 
 
@@ -61,7 +61,7 @@ Collection       ObjDataList = STATIC_COLLECTION_INITIALIZER;
 
 
 /*****************************************************************************/
-/*                                          Code                                    */
+/*                                   Code                                    */
 /*****************************************************************************/
 
 
@@ -73,20 +73,22 @@ ObjData* NewObjData (void)
     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;
@@ -122,6 +124,7 @@ void FreeObjData (ObjData* O)
     }
     DoneCollection (&O->Imports);
     DoneCollection (&O->DbgSyms);
+    DoneCollection (&O->HLLDbgSyms);
 
     for (I = 0; I < CollCount (&O->LineInfos); ++I) {
         FreeLineInfo (CollAtUnchecked (&O->LineInfos, I));
@@ -181,8 +184,8 @@ unsigned MakeGlobalStringId (const ObjData* O, unsigned Index)
 /* 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];
 }
@@ -199,7 +202,15 @@ const char* GetObjFileName (const ObjData* O)
 
 
 
-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)) {
@@ -211,7 +222,7 @@ struct Section* GetObjSection (ObjData* O, unsigned Id)
 
 
 
-struct Import* GetObjImport (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)) {
@@ -223,7 +234,7 @@ struct Import* GetObjImport (ObjData* O, unsigned Id)
 
 
 
-struct Export* GetObjExport (ObjData* O, unsigned 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)) {
@@ -235,7 +246,19 @@ struct Export* GetObjExport (ObjData* O, unsigned Id)
 
 
 
-struct Scope* GetObjScope (ObjData* O, unsigned 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)) {
@@ -286,6 +309,3 @@ void PrintDbgModules (FILE* F)
     }
 
 }
-
-
-