Changed the object file and library format. There is now an additional
string table in the object file that (currently) holds all identifiers from the import, export and debug info sections. The plan is to put all strings into this table, so we have them in a central place and don't waste memory. Apart from that, the indices are unique, so comparing strings should be a lot easier than before (as soon as the programs take advantage of this fact, which is currently not the case). git-svn-id: svn://svn.cc65.org/cc65/trunk@2169 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2000 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -53,8 +53,8 @@
|
|||||||
|
|
||||||
|
|
||||||
/* A hash table entry */
|
/* A hash table entry */
|
||||||
typedef struct HashEntry_ HashEntry;
|
typedef struct HashEntry HashEntry;
|
||||||
struct HashEntry_ {
|
struct HashEntry {
|
||||||
HashEntry* Next; /* Next in list */
|
HashEntry* Next; /* Next in list */
|
||||||
unsigned Module; /* Module index */
|
unsigned Module; /* Module index */
|
||||||
char Name [1]; /* Name of identifier */
|
char Name [1]; /* Name of identifier */
|
||||||
@@ -149,4 +149,3 @@ int ExpFind (const char* Name)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2000 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -71,7 +71,8 @@ static const char* LibName = 0;
|
|||||||
static LibHeader Header = {
|
static LibHeader Header = {
|
||||||
LIB_MAGIC,
|
LIB_MAGIC,
|
||||||
LIB_VERSION,
|
LIB_VERSION,
|
||||||
0, 0
|
0,
|
||||||
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -106,6 +107,8 @@ static void ReadHeader (void)
|
|||||||
static void ReadIndexEntry (void)
|
static void ReadIndexEntry (void)
|
||||||
/* Read one entry in the index */
|
/* Read one entry in the index */
|
||||||
{
|
{
|
||||||
|
unsigned I;
|
||||||
|
|
||||||
/* Create a new entry and insert it into the list */
|
/* Create a new entry and insert it into the list */
|
||||||
ObjData* O = NewObjData ();
|
ObjData* O = NewObjData ();
|
||||||
|
|
||||||
@@ -116,13 +119,20 @@ static void ReadIndexEntry (void)
|
|||||||
O->Start = Read32 (Lib);
|
O->Start = Read32 (Lib);
|
||||||
O->Size = Read32 (Lib);
|
O->Size = Read32 (Lib);
|
||||||
|
|
||||||
|
/* Strings */
|
||||||
|
O->StringCount = ReadVar (Lib);
|
||||||
|
O->Strings = xmalloc (O->StringCount * sizeof (char*));
|
||||||
|
for (I = 0; I < O->StringCount; ++I) {
|
||||||
|
O->Strings[I] = ReadStr (Lib);
|
||||||
|
}
|
||||||
|
|
||||||
/* Exports */
|
/* Exports */
|
||||||
O->ExportSize = Read16 (Lib);
|
O->ExportSize = ReadVar (Lib);
|
||||||
O->Exports = xmalloc (O->ExportSize);
|
O->Exports = xmalloc (O->ExportSize);
|
||||||
ReadData (Lib, O->Exports, O->ExportSize);
|
ReadData (Lib, O->Exports, O->ExportSize);
|
||||||
|
|
||||||
/* Imports */
|
/* Imports */
|
||||||
O->ImportSize = Read16 (Lib);
|
O->ImportSize = ReadVar (Lib);
|
||||||
O->Imports = xmalloc (O->ImportSize);
|
O->Imports = xmalloc (O->ImportSize);
|
||||||
ReadData (Lib, O->Imports, O->ImportSize);
|
ReadData (Lib, O->Imports, O->ImportSize);
|
||||||
}
|
}
|
||||||
@@ -138,7 +148,7 @@ static void ReadIndex (void)
|
|||||||
fseek (Lib, Header.IndexOffs, SEEK_SET);
|
fseek (Lib, Header.IndexOffs, SEEK_SET);
|
||||||
|
|
||||||
/* Read the object file count and calculate the cross ref size */
|
/* Read the object file count and calculate the cross ref size */
|
||||||
Count = Read16 (Lib);
|
Count = ReadVar (Lib);
|
||||||
|
|
||||||
/* Read all entries in the index */
|
/* Read all entries in the index */
|
||||||
while (Count--) {
|
while (Count--) {
|
||||||
@@ -172,6 +182,8 @@ static void WriteHeader (void)
|
|||||||
static void WriteIndexEntry (ObjData* O)
|
static void WriteIndexEntry (ObjData* O)
|
||||||
/* Write one index entry */
|
/* Write one index entry */
|
||||||
{
|
{
|
||||||
|
unsigned I;
|
||||||
|
|
||||||
/* Module name/flags/MTime/start/size */
|
/* Module name/flags/MTime/start/size */
|
||||||
WriteStr (NewLib, O->Name);
|
WriteStr (NewLib, O->Name);
|
||||||
Write16 (NewLib, O->Flags & ~OBJ_HAVEDATA);
|
Write16 (NewLib, O->Flags & ~OBJ_HAVEDATA);
|
||||||
@@ -179,12 +191,18 @@ static void WriteIndexEntry (ObjData* O)
|
|||||||
Write32 (NewLib, O->Start);
|
Write32 (NewLib, O->Start);
|
||||||
Write32 (NewLib, O->Size);
|
Write32 (NewLib, O->Size);
|
||||||
|
|
||||||
|
/* Strings */
|
||||||
|
WriteVar (NewLib, O->StringCount);
|
||||||
|
for (I = 0; I < O->StringCount; ++I) {
|
||||||
|
WriteStr (NewLib, O->Strings[I]);
|
||||||
|
}
|
||||||
|
|
||||||
/* Exports */
|
/* Exports */
|
||||||
Write16 (NewLib, O->ExportSize);
|
WriteVar (NewLib, O->ExportSize);
|
||||||
WriteData (NewLib, O->Exports, O->ExportSize);
|
WriteData (NewLib, O->Exports, O->ExportSize);
|
||||||
|
|
||||||
/* Imports */
|
/* Imports */
|
||||||
Write16 (NewLib, O->ImportSize);
|
WriteVar (NewLib, O->ImportSize);
|
||||||
WriteData (NewLib, O->Imports, O->ImportSize);
|
WriteData (NewLib, O->Imports, O->ImportSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +220,7 @@ static void WriteIndex (void)
|
|||||||
Header.IndexOffs = ftell (NewLib);
|
Header.IndexOffs = ftell (NewLib);
|
||||||
|
|
||||||
/* Write the object file count */
|
/* Write the object file count */
|
||||||
Write16 (NewLib, ObjCount);
|
WriteVar (NewLib, ObjCount);
|
||||||
|
|
||||||
/* Write the object files */
|
/* Write the object files */
|
||||||
O = ObjRoot;
|
O = ObjRoot;
|
||||||
@@ -348,8 +366,8 @@ static void SkipExpr (unsigned char** Buf)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case EXPR_SYMBOL:
|
case EXPR_SYMBOL:
|
||||||
/* 16 bit symbol index */
|
/* Variable seized symbol index */
|
||||||
*Buf += 2;
|
(void) GetVar (Buf);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case EXPR_SECTION:
|
case EXPR_SECTION:
|
||||||
@@ -391,8 +409,7 @@ static void LibCheckExports (ObjData* O)
|
|||||||
while (Count--) {
|
while (Count--) {
|
||||||
|
|
||||||
unsigned char Tag;
|
unsigned char Tag;
|
||||||
unsigned Len;
|
const char* Name;
|
||||||
char* Name;
|
|
||||||
|
|
||||||
/* Get the export tag */
|
/* Get the export tag */
|
||||||
Tag = *Exports++;
|
Tag = *Exports++;
|
||||||
@@ -400,12 +417,8 @@ static void LibCheckExports (ObjData* O)
|
|||||||
/* condes decls may follow */
|
/* condes decls may follow */
|
||||||
Exports += GET_EXP_CONDES_COUNT (Tag);
|
Exports += GET_EXP_CONDES_COUNT (Tag);
|
||||||
|
|
||||||
/* Next thing is name of symbol */
|
/* Next thing is index of name of symbol */
|
||||||
Len = GetVar (&Exports);
|
Name = GetObjString (O, GetVar (&Exports));
|
||||||
Name = xmalloc (Len + 1);
|
|
||||||
memcpy (Name, Exports, Len);
|
|
||||||
Name [Len] = '\0';
|
|
||||||
Exports += Len;
|
|
||||||
|
|
||||||
/* Skip value of symbol */
|
/* Skip value of symbol */
|
||||||
if (Tag & EXP_EXPR) {
|
if (Tag & EXP_EXPR) {
|
||||||
@@ -422,9 +435,6 @@ static void LibCheckExports (ObjData* O)
|
|||||||
/* Insert the name into the hash table */
|
/* Insert the name into the hash table */
|
||||||
Print (stdout, 1, " %s\n", Name);
|
Print (stdout, 1, " %s\n", Name);
|
||||||
ExpInsert (Name, O->Index);
|
ExpInsert (Name, O->Index);
|
||||||
|
|
||||||
/* Free the name */
|
|
||||||
xfree (Name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2000 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -79,6 +79,8 @@ ObjData* NewObjData (void)
|
|||||||
O->MTime = 0;
|
O->MTime = 0;
|
||||||
O->Start = 0;
|
O->Start = 0;
|
||||||
O->Size = 0;
|
O->Size = 0;
|
||||||
|
O->StringCount = 0;
|
||||||
|
O->Strings = 0;
|
||||||
O->ImportSize = 0;
|
O->ImportSize = 0;
|
||||||
O->Imports = 0;
|
O->Imports = 0;
|
||||||
O->ExportSize = 0;
|
O->ExportSize = 0;
|
||||||
@@ -105,9 +107,15 @@ ObjData* NewObjData (void)
|
|||||||
void FreeObjData (ObjData* O)
|
void FreeObjData (ObjData* O)
|
||||||
/* Free a complete struct */
|
/* Free a complete struct */
|
||||||
{
|
{
|
||||||
|
unsigned I;
|
||||||
|
|
||||||
xfree (O->Name);
|
xfree (O->Name);
|
||||||
xfree (O->Imports);
|
xfree (O->Imports);
|
||||||
xfree (O->Exports);
|
xfree (O->Exports);
|
||||||
|
for (I = 0; I < O->StringCount; ++I) {
|
||||||
|
xfree (O->Strings[I]);
|
||||||
|
}
|
||||||
|
xfree (O->Strings);
|
||||||
xfree (O);
|
xfree (O);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,5 +215,15 @@ const char* GetObjName (unsigned Index)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const char* GetObjString (const ObjData* O, unsigned Index)
|
||||||
|
/* Get a string from the string pool of an object file */
|
||||||
|
{
|
||||||
|
if (Index >= O->StringCount) {
|
||||||
|
Error ("Invalid string index (%u) in module `%s'",
|
||||||
|
Index, GetObjName (O->Index));
|
||||||
|
}
|
||||||
|
return O->Strings[Index];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -50,8 +50,8 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Internal structure holding object file data */
|
/* Internal structure holding object file data */
|
||||||
typedef struct ObjData_ ObjData;
|
typedef struct ObjData ObjData;
|
||||||
struct ObjData_ {
|
struct ObjData {
|
||||||
ObjData* Next; /* Linked list of all objects */
|
ObjData* Next; /* Linked list of all objects */
|
||||||
char* Name; /* Module name */
|
char* Name; /* Module name */
|
||||||
unsigned Index; /* Module index */
|
unsigned Index; /* Module index */
|
||||||
@@ -59,6 +59,8 @@ struct ObjData_ {
|
|||||||
unsigned long MTime; /* Modifiation time of object file */
|
unsigned long MTime; /* Modifiation time of object file */
|
||||||
unsigned long Start; /* Start offset of data in library */
|
unsigned long Start; /* Start offset of data in library */
|
||||||
unsigned long Size; /* Size of data in library */
|
unsigned long Size; /* Size of data in library */
|
||||||
|
unsigned StringCount; /* Number of strings */
|
||||||
|
char** Strings; /* Strings from the object file */
|
||||||
unsigned long ImportSize; /* Size of imports */
|
unsigned long ImportSize; /* Size of imports */
|
||||||
void* Imports; /* Imports as raw data */
|
void* Imports; /* Imports as raw data */
|
||||||
unsigned long ExportSize; /* Size of exports */
|
unsigned long ExportSize; /* Size of exports */
|
||||||
@@ -101,6 +103,9 @@ void MakeObjPool (void);
|
|||||||
const char* GetObjName (unsigned Index);
|
const char* GetObjName (unsigned Index);
|
||||||
/* Get the name of a module by index */
|
/* Get the name of a module by index */
|
||||||
|
|
||||||
|
const char* GetObjString (const ObjData* O, unsigned Index);
|
||||||
|
/* Get a string from the string pool of an object file */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of objdata.h */
|
/* End of objdata.h */
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@@ -109,6 +109,8 @@ void ObjReadHeader (FILE* Obj, ObjHeader* H, const char* Name)
|
|||||||
H->DbgSymSize = Read32 (Obj);
|
H->DbgSymSize = Read32 (Obj);
|
||||||
H->LineInfoOffs = Read32 (Obj);
|
H->LineInfoOffs = Read32 (Obj);
|
||||||
H->LineInfoSize = Read32 (Obj);
|
H->LineInfoSize = Read32 (Obj);
|
||||||
|
H->StrPoolOffs = Read32 (Obj);
|
||||||
|
H->StrPoolSize = Read32 (Obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -133,6 +135,8 @@ void ObjWriteHeader (FILE* Obj, ObjHeader* H)
|
|||||||
Write32 (Obj, H->DbgSymSize);
|
Write32 (Obj, H->DbgSymSize);
|
||||||
Write32 (Obj, H->LineInfoOffs);
|
Write32 (Obj, H->LineInfoOffs);
|
||||||
Write32 (Obj, H->LineInfoSize);
|
Write32 (Obj, H->LineInfoSize);
|
||||||
|
Write32 (Obj, H->StrPoolOffs);
|
||||||
|
Write32 (Obj, H->StrPoolSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -144,6 +148,7 @@ void ObjAdd (const char* Name)
|
|||||||
const char* Module;
|
const char* Module;
|
||||||
ObjHeader H;
|
ObjHeader H;
|
||||||
ObjData* O;
|
ObjData* O;
|
||||||
|
unsigned I;
|
||||||
|
|
||||||
/* Open the object file */
|
/* Open the object file */
|
||||||
FILE* Obj = fopen (Name, "rb");
|
FILE* Obj = fopen (Name, "rb");
|
||||||
@@ -191,6 +196,14 @@ void ObjAdd (const char* Name)
|
|||||||
fseek (Obj, H.ExportOffs, SEEK_SET);
|
fseek (Obj, H.ExportOffs, SEEK_SET);
|
||||||
ReadData (Obj, O->Exports, O->ExportSize);
|
ReadData (Obj, O->Exports, O->ExportSize);
|
||||||
|
|
||||||
|
/* Read the string pool */
|
||||||
|
fseek (Obj, H.StrPoolOffs, SEEK_SET);
|
||||||
|
O->StringCount = ReadVar (Obj);
|
||||||
|
O->Strings = xmalloc (O->StringCount * sizeof (char*));
|
||||||
|
for (I = 0; I < O->StringCount; ++I) {
|
||||||
|
O->Strings[I] = ReadStr (Obj);
|
||||||
|
}
|
||||||
|
|
||||||
/* Skip the object file header */
|
/* Skip the object file header */
|
||||||
O->Start = ftell (NewLib);
|
O->Start = ftell (NewLib);
|
||||||
fseek (NewLib, OBJ_HDR_SIZE, SEEK_CUR);
|
fseek (NewLib, OBJ_HDR_SIZE, SEEK_CUR);
|
||||||
@@ -213,6 +226,7 @@ void ObjAdd (const char* Name)
|
|||||||
/* Clear the remaining header fields */
|
/* Clear the remaining header fields */
|
||||||
H.ImportOffs = H.ImportSize = 0;
|
H.ImportOffs = H.ImportSize = 0;
|
||||||
H.ExportOffs = H.ExportSize = 0;
|
H.ExportOffs = H.ExportSize = 0;
|
||||||
|
H.StrPoolOffs = H.StrPoolSize = 0;
|
||||||
|
|
||||||
/* Seek back and write the updated header */
|
/* Seek back and write the updated header */
|
||||||
fseek (NewLib, O->Start, SEEK_SET);
|
fseek (NewLib, O->Start, SEEK_SET);
|
||||||
@@ -232,10 +246,12 @@ void ObjExtract (const char* Name)
|
|||||||
{
|
{
|
||||||
unsigned long ImportStart;
|
unsigned long ImportStart;
|
||||||
unsigned long ExportStart;
|
unsigned long ExportStart;
|
||||||
|
unsigned long StrPoolStart;
|
||||||
|
unsigned long StrPoolSize;
|
||||||
struct utimbuf U;
|
struct utimbuf U;
|
||||||
ObjHeader H;
|
ObjHeader H;
|
||||||
FILE* Obj;
|
FILE* Obj;
|
||||||
|
unsigned I;
|
||||||
|
|
||||||
/* Make a module name from the file name */
|
/* Make a module name from the file name */
|
||||||
const char* Module = GetModule (Name);
|
const char* Module = GetModule (Name);
|
||||||
@@ -263,6 +279,14 @@ void ObjExtract (const char* Name)
|
|||||||
ExportStart = ftell (Obj);
|
ExportStart = ftell (Obj);
|
||||||
WriteData (Obj, O->Exports, O->ExportSize);
|
WriteData (Obj, O->Exports, O->ExportSize);
|
||||||
|
|
||||||
|
/* Write the string pool */
|
||||||
|
StrPoolStart = ftell (Obj);
|
||||||
|
WriteVar (Obj, O->StringCount);
|
||||||
|
for (I = 0; I < O->StringCount; ++I) {
|
||||||
|
WriteStr (Obj, O->Strings[I]);
|
||||||
|
}
|
||||||
|
StrPoolSize = ftell (Obj) - StrPoolStart;
|
||||||
|
|
||||||
/* Seek back and read the header */
|
/* Seek back and read the header */
|
||||||
fseek (Obj, 0, SEEK_SET);
|
fseek (Obj, 0, SEEK_SET);
|
||||||
ObjReadHeader (Obj, &H, Name);
|
ObjReadHeader (Obj, &H, Name);
|
||||||
@@ -272,6 +296,8 @@ void ObjExtract (const char* Name)
|
|||||||
H.ImportSize = O->ImportSize;
|
H.ImportSize = O->ImportSize;
|
||||||
H.ExportOffs = ExportStart;
|
H.ExportOffs = ExportStart;
|
||||||
H.ExportSize = O->ExportSize;
|
H.ExportSize = O->ExportSize;
|
||||||
|
H.StrPoolOffs = StrPoolStart;
|
||||||
|
H.StrPoolSize = StrPoolSize;
|
||||||
|
|
||||||
/* Write the changed header */
|
/* Write the changed header */
|
||||||
fseek (Obj, 0, SEEK_SET);
|
fseek (Obj, 0, SEEK_SET);
|
||||||
|
|||||||
@@ -1603,7 +1603,7 @@ void WriteExpr (ExprNode* Expr)
|
|||||||
case EXPR_SYMBOL:
|
case EXPR_SYMBOL:
|
||||||
/* Maybe we should use a code here? */
|
/* Maybe we should use a code here? */
|
||||||
CHECK (SymIsImport (Expr->V.Sym)); /* Safety */
|
CHECK (SymIsImport (Expr->V.Sym)); /* Safety */
|
||||||
ObjWrite16 (GetSymIndex (Expr->V.Sym));
|
ObjWriteVar (GetSymIndex (Expr->V.Sym));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EXPR_SECTION:
|
case EXPR_SECTION:
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2002 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -71,5 +71,8 @@ unsigned char DollarInIdents = 0; /* Allow '$' in identifiers */
|
|||||||
unsigned char LeadingDotInIdents = 0; /* Allow '.' to start an identifier */
|
unsigned char LeadingDotInIdents = 0; /* Allow '.' to start an identifier */
|
||||||
unsigned char PCAssignment = 0; /* Allow "* = $XXX" or "$ = $XXX" */
|
unsigned char PCAssignment = 0; /* Allow "* = $XXX" or "$ = $XXX" */
|
||||||
|
|
||||||
|
/* Misc stuff */
|
||||||
|
const char Copyright[] = "(C) Copyright 1998-2003 Ullrich von Bassewitz";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2002 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -72,6 +72,9 @@ extern unsigned char DollarInIdents; /* Allow '$' in identifiers */
|
|||||||
extern unsigned char LeadingDotInIdents; /* Allow '.' to start an identifier */
|
extern unsigned char LeadingDotInIdents; /* Allow '.' to start an identifier */
|
||||||
extern unsigned char PCAssignment; /* Allow "* = $XXX" or "$ = $XXX" */
|
extern unsigned char PCAssignment; /* Allow "* = $XXX" or "$ = $XXX" */
|
||||||
|
|
||||||
|
/* Misc stuff */
|
||||||
|
extern const char Copyright[]; /* Copyright string */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of global.h */
|
/* End of global.h */
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2000 Ullrich von Bassewitz */
|
/* (C) 2000-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -221,11 +221,12 @@ static void PrintPageHeader (FILE* F, const ListLine* L)
|
|||||||
{
|
{
|
||||||
/* Print the header on the new page */
|
/* Print the header on the new page */
|
||||||
fprintf (F,
|
fprintf (F,
|
||||||
"ca65 V%u.%u.%u - (C) Copyright 1998-2000 Ullrich von Bassewitz\n"
|
"ca65 V%u.%u.%u - %s\n"
|
||||||
"Main file : %s\n"
|
"Main file : %s\n"
|
||||||
"Current file: %s\n"
|
"Current file: %s\n"
|
||||||
"\n",
|
"\n",
|
||||||
VER_MAJOR, VER_MINOR, VER_PATCH,
|
VER_MAJOR, VER_MINOR, VER_PATCH,
|
||||||
|
Copyright,
|
||||||
InFile,
|
InFile,
|
||||||
GetFileName (L->File));
|
GetFileName (L->File));
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2002 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -65,6 +65,7 @@
|
|||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "pseudo.h"
|
#include "pseudo.h"
|
||||||
#include "scanner.h"
|
#include "scanner.h"
|
||||||
|
#include "spool.h"
|
||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
#include "ulabel.h"
|
#include "ulabel.h"
|
||||||
|
|
||||||
@@ -320,8 +321,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
|
|||||||
/* Print the assembler version */
|
/* Print the assembler version */
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"ca65 V%u.%u.%u - (C) Copyright 1998-2000 Ullrich von Bassewitz\n",
|
"ca65 V%u.%u.%u - %s\n",
|
||||||
VER_MAJOR, VER_MINOR, VER_PATCH);
|
VER_MAJOR, VER_MINOR, VER_PATCH, Copyright);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -480,6 +481,9 @@ static void CreateObjFile (void)
|
|||||||
/* Write line infos if requested */
|
/* Write line infos if requested */
|
||||||
WriteLineInfo ();
|
WriteLineInfo ();
|
||||||
|
|
||||||
|
/* Write the string pool */
|
||||||
|
WriteStrPool ();
|
||||||
|
|
||||||
/* Write an updated header and close the file */
|
/* Write an updated header and close the file */
|
||||||
ObjClose ();
|
ObjClose ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ OBJS = condasm.o \
|
|||||||
pseudo.o \
|
pseudo.o \
|
||||||
repeat.o \
|
repeat.o \
|
||||||
scanner.o \
|
scanner.o \
|
||||||
|
spool.o \
|
||||||
symtab.o \
|
symtab.o \
|
||||||
toklist.o \
|
toklist.o \
|
||||||
ulabel.o
|
ulabel.o
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ OBJS = condasm.obj \
|
|||||||
pseudo.obj \
|
pseudo.obj \
|
||||||
repeat.obj \
|
repeat.obj \
|
||||||
scanner.obj \
|
scanner.obj \
|
||||||
|
spool.obj \
|
||||||
symtab.obj \
|
symtab.obj \
|
||||||
toklist.obj \
|
toklist.obj \
|
||||||
ulabel.obj
|
ulabel.obj
|
||||||
|
|||||||
@@ -578,7 +578,6 @@ static Fragment* NewFragment (unsigned char Type, unsigned short Len)
|
|||||||
void Emit0 (unsigned char OPC)
|
void Emit0 (unsigned char OPC)
|
||||||
/* Emit an instruction with a zero sized operand */
|
/* Emit an instruction with a zero sized operand */
|
||||||
{
|
{
|
||||||
/* First fragment, wrong type or out of space, create new one */
|
|
||||||
Fragment* F = NewFragment (FRAG_LITERAL, 1);
|
Fragment* F = NewFragment (FRAG_LITERAL, 1);
|
||||||
F->V.Data [0] = OPC;
|
F->V.Data [0] = OPC;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@@ -63,9 +63,25 @@ static FILE* F = 0;
|
|||||||
|
|
||||||
/* Header structure */
|
/* Header structure */
|
||||||
static ObjHeader Header = {
|
static ObjHeader Header = {
|
||||||
OBJ_MAGIC,
|
OBJ_MAGIC, /* 32: Magic number */
|
||||||
OBJ_VERSION,
|
OBJ_VERSION, /* 16: Version number */
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
0, /* 16: flags */
|
||||||
|
0, /* 32: Offset to option table */
|
||||||
|
0, /* 32: Size of options */
|
||||||
|
0, /* 32: Offset to file table */
|
||||||
|
0, /* 32: Size of files */
|
||||||
|
0, /* 32: Offset to segment table */
|
||||||
|
0, /* 32: Size of segment table */
|
||||||
|
0, /* 32: Offset to import list */
|
||||||
|
0, /* 32: Size of import list */
|
||||||
|
0, /* 32: Offset to export list */
|
||||||
|
0, /* 32: Size of export list */
|
||||||
|
0, /* 32: Offset to list of debug symbols */
|
||||||
|
0, /* 32: Size of debug symbols */
|
||||||
|
0, /* 32: Offset to list of line infos */
|
||||||
|
0, /* 32: Size of line infos */
|
||||||
|
0, /* 32: Offset to string pool */
|
||||||
|
0 /* 32: Size of string pool */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -116,6 +132,8 @@ static void ObjWriteHeader (void)
|
|||||||
ObjWrite32 (Header.DbgSymSize);
|
ObjWrite32 (Header.DbgSymSize);
|
||||||
ObjWrite32 (Header.LineInfoOffs);
|
ObjWrite32 (Header.LineInfoOffs);
|
||||||
ObjWrite32 (Header.LineInfoSize);
|
ObjWrite32 (Header.LineInfoSize);
|
||||||
|
ObjWrite32 (Header.StrPoolOffs);
|
||||||
|
ObjWrite32 (Header.StrPoolSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -386,3 +404,19 @@ void ObjEndLineInfos (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ObjStartStrPool (void)
|
||||||
|
/* Mark the start of the string pool section */
|
||||||
|
{
|
||||||
|
Header.StrPoolOffs = ftell (F);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ObjEndStrPool (void)
|
||||||
|
/* Mark the end of the string pool section */
|
||||||
|
{
|
||||||
|
Header.StrPoolSize = ftell (F) - Header.StrPoolOffs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@@ -121,6 +121,12 @@ void ObjStartLineInfos (void);
|
|||||||
void ObjEndLineInfos (void);
|
void ObjEndLineInfos (void);
|
||||||
/* Mark the end of the line info section */
|
/* Mark the end of the line info section */
|
||||||
|
|
||||||
|
void ObjStartStrPool (void);
|
||||||
|
/* Mark the start of the string pool section */
|
||||||
|
|
||||||
|
void ObjEndStrPool (void);
|
||||||
|
/* Mark the end of the string pool section */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of objfile.h */
|
/* End of objfile.h */
|
||||||
|
|||||||
82
src/ca65/spool.c
Normal file
82
src/ca65/spool.c
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* spool.c */
|
||||||
|
/* */
|
||||||
|
/* Id and message pool for the ca65 macroassembler */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* (C) 2003 Ullrich von Bassewitz */
|
||||||
|
/* R<>merstrasse 52 */
|
||||||
|
/* D-70794 Filderstadt */
|
||||||
|
/* EMail: uz@cc65.org */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
|
/* warranty. In no event will the authors be held liable for any damages */
|
||||||
|
/* arising from the use of this software. */
|
||||||
|
/* */
|
||||||
|
/* Permission is granted to anyone to use this software for any purpose, */
|
||||||
|
/* including commercial applications, and to alter it and redistribute it */
|
||||||
|
/* freely, subject to the following restrictions: */
|
||||||
|
/* */
|
||||||
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||||
|
/* claim that you wrote the original software. If you use this software */
|
||||||
|
/* in a product, an acknowledgment in the product documentation would be */
|
||||||
|
/* appreciated but is not required. */
|
||||||
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||||
|
/* be misrepresented as being the original software. */
|
||||||
|
/* 3. This notice may not be removed or altered from any source */
|
||||||
|
/* distribution. */
|
||||||
|
/* */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ca65 */
|
||||||
|
#include "objfile.h"
|
||||||
|
#include "spool.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Data */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
StringPool StrPool = STATIC_STRINGPOOL_INITIALIZER;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Code */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void WriteStrPool (void)
|
||||||
|
/* Write the string pool to the object file */
|
||||||
|
{
|
||||||
|
unsigned I;
|
||||||
|
|
||||||
|
/* Get the number of strings in the string pool */
|
||||||
|
unsigned Count = SP_GetCount (&StrPool);
|
||||||
|
|
||||||
|
/* Tell the object file module that we're about to start the string pool */
|
||||||
|
ObjStartStrPool ();
|
||||||
|
|
||||||
|
/* Write the string count to the list */
|
||||||
|
ObjWriteVar (Count);
|
||||||
|
|
||||||
|
/* Write the strings in id order */
|
||||||
|
for (I = 0; I < Count; ++I) {
|
||||||
|
ObjWriteStr (SP_Get (&StrPool, I));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Done writing the string pool */
|
||||||
|
ObjEndStrPool ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
83
src/ca65/spool.h
Normal file
83
src/ca65/spool.h
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* spool.h */
|
||||||
|
/* */
|
||||||
|
/* Id and message pool for the ca65 macroassembler */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* (C) 2003 Ullrich von Bassewitz */
|
||||||
|
/* R<>merstrasse 52 */
|
||||||
|
/* D-70794 Filderstadt */
|
||||||
|
/* EMail: uz@cc65.org */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
|
/* warranty. In no event will the authors be held liable for any damages */
|
||||||
|
/* arising from the use of this software. */
|
||||||
|
/* */
|
||||||
|
/* Permission is granted to anyone to use this software for any purpose, */
|
||||||
|
/* including commercial applications, and to alter it and redistribute it */
|
||||||
|
/* freely, subject to the following restrictions: */
|
||||||
|
/* */
|
||||||
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||||
|
/* claim that you wrote the original software. If you use this software */
|
||||||
|
/* in a product, an acknowledgment in the product documentation would be */
|
||||||
|
/* appreciated but is not required. */
|
||||||
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||||
|
/* be misrepresented as being the original software. */
|
||||||
|
/* 3. This notice may not be removed or altered from any source */
|
||||||
|
/* distribution. */
|
||||||
|
/* */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef SPOOL_H
|
||||||
|
#define SPOOL_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* common */
|
||||||
|
#include "strpool.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Data */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern StringPool StrPool;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Code */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(HAVE_INLINE)
|
||||||
|
INLINE unsigned GetStringId (const char* S)
|
||||||
|
/* Return the id of the given string */
|
||||||
|
{
|
||||||
|
return SP_Add (&StrPool, S);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
# define GetStringId(S) SP_Add (&StrPool, (S))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void WriteStrPool (void);
|
||||||
|
/* Write the string pool to the object file */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* End of spool.h */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -48,6 +48,7 @@
|
|||||||
#include "expr.h"
|
#include "expr.h"
|
||||||
#include "objfile.h"
|
#include "objfile.h"
|
||||||
#include "scanner.h"
|
#include "scanner.h"
|
||||||
|
#include "spool.h"
|
||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -1137,7 +1138,7 @@ void WriteImports (void)
|
|||||||
} else {
|
} else {
|
||||||
ObjWrite8 (IMP_ABS);
|
ObjWrite8 (IMP_ABS);
|
||||||
}
|
}
|
||||||
ObjWriteStr (S->Name);
|
ObjWriteVar (GetStringId (S->Name));
|
||||||
ObjWritePos (&S->Pos);
|
ObjWritePos (&S->Pos);
|
||||||
}
|
}
|
||||||
S = S->List;
|
S = S->List;
|
||||||
@@ -1214,7 +1215,7 @@ void WriteExports (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Write the name */
|
/* Write the name */
|
||||||
ObjWriteStr (S->Name);
|
ObjWriteVar (GetStringId (S->Name));
|
||||||
|
|
||||||
/* Write the value */
|
/* Write the value */
|
||||||
if ((ExprMask & EXP_MASK_VAL) == EXP_CONST) {
|
if ((ExprMask & EXP_MASK_VAL) == EXP_CONST) {
|
||||||
@@ -1278,7 +1279,7 @@ void WriteDbgSyms (void)
|
|||||||
ObjWrite8 (ExprMask);
|
ObjWrite8 (ExprMask);
|
||||||
|
|
||||||
/* Write the name */
|
/* Write the name */
|
||||||
ObjWriteStr (S->Name);
|
ObjWriteVar (GetStringId (S->Name));
|
||||||
|
|
||||||
/* Write the value */
|
/* Write the value */
|
||||||
if ((ExprMask & EXP_MASK_VAL) == EXP_CONST) {
|
if ((ExprMask & EXP_MASK_VAL) == EXP_CONST) {
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ extern const Collection EmptyCollection;
|
|||||||
#define STATIC_COLLECTION_INITIALIZER { 0, 0, 0 }
|
#define STATIC_COLLECTION_INITIALIZER { 0, 0, 0 }
|
||||||
|
|
||||||
/* Initializer for auto collections */
|
/* Initializer for auto collections */
|
||||||
#define AUTO_COLLECTION_INITIALIZER EmptyCollection;
|
#define AUTO_COLLECTION_INITIALIZER EmptyCollection
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
/* Defines for magic and version */
|
/* Defines for magic and version */
|
||||||
#define LIB_MAGIC 0x7A55616E
|
#define LIB_MAGIC 0x7A55616E
|
||||||
#define LIB_VERSION 0x0009
|
#define LIB_VERSION 0x000A
|
||||||
|
|
||||||
/* Size of an library file header */
|
/* Size of an library file header */
|
||||||
#define LIB_HDR_SIZE 12
|
#define LIB_HDR_SIZE 12
|
||||||
@@ -54,8 +54,8 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Header structure for the library */
|
/* Header structure for the library */
|
||||||
typedef struct LibHeader_ LibHeader;
|
typedef struct LibHeader LibHeader;
|
||||||
struct LibHeader_ {
|
struct LibHeader {
|
||||||
unsigned long Magic; /* 32: Magic number */
|
unsigned long Magic; /* 32: Magic number */
|
||||||
unsigned Version; /* 16: Version number */
|
unsigned Version; /* 16: Version number */
|
||||||
unsigned Flags; /* 16: flags */
|
unsigned Flags; /* 16: flags */
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ OBJS = abend.o \
|
|||||||
segdefs.o \
|
segdefs.o \
|
||||||
segnames.o \
|
segnames.o \
|
||||||
strbuf.o \
|
strbuf.o \
|
||||||
|
strpool.o \
|
||||||
strutil.o \
|
strutil.o \
|
||||||
target.o \
|
target.o \
|
||||||
tgttrans.o \
|
tgttrans.o \
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -46,10 +46,10 @@
|
|||||||
|
|
||||||
/* Defines for magic and version */
|
/* Defines for magic and version */
|
||||||
#define OBJ_MAGIC 0x616E7A55
|
#define OBJ_MAGIC 0x616E7A55
|
||||||
#define OBJ_VERSION 0x0009
|
#define OBJ_VERSION 0x000A
|
||||||
|
|
||||||
/* Size of an object file header */
|
/* Size of an object file header */
|
||||||
#define OBJ_HDR_SIZE 64
|
#define OBJ_HDR_SIZE 72
|
||||||
|
|
||||||
/* Flag bits */
|
/* Flag bits */
|
||||||
#define OBJ_FLAGS_DBGINFO 0x0001 /* File has debug info */
|
#define OBJ_FLAGS_DBGINFO 0x0001 /* File has debug info */
|
||||||
@@ -57,8 +57,8 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Header structure */
|
/* Header structure */
|
||||||
typedef struct ObjHeader_ ObjHeader;
|
typedef struct ObjHeader ObjHeader;
|
||||||
struct ObjHeader_ {
|
struct ObjHeader {
|
||||||
unsigned long Magic; /* 32: Magic number */
|
unsigned long Magic; /* 32: Magic number */
|
||||||
unsigned Version; /* 16: Version number */
|
unsigned Version; /* 16: Version number */
|
||||||
unsigned Flags; /* 16: flags */
|
unsigned Flags; /* 16: flags */
|
||||||
@@ -76,6 +76,8 @@ struct ObjHeader_ {
|
|||||||
unsigned long DbgSymSize; /* 32: Size of debug symbols */
|
unsigned long DbgSymSize; /* 32: Size of debug symbols */
|
||||||
unsigned long LineInfoOffs; /* 32: Offset to list of line infos */
|
unsigned long LineInfoOffs; /* 32: Offset to list of line infos */
|
||||||
unsigned long LineInfoSize; /* 32: Size of line infos */
|
unsigned long LineInfoSize; /* 32: Size of line infos */
|
||||||
|
unsigned long StrPoolOffs; /* 32: Offset to string pool */
|
||||||
|
unsigned long StrPoolSize; /* 32: Size of string pool */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2002 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* R<>merstrasse 52 */
|
/* R<>merstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
@@ -53,7 +53,9 @@
|
|||||||
/* Fragment types in the object file */
|
/* Fragment types in the object file */
|
||||||
#define FRAG_TYPEMASK 0x38 /* Mask the type of the fragment */
|
#define FRAG_TYPEMASK 0x38 /* Mask the type of the fragment */
|
||||||
#define FRAG_BYTEMASK 0x07 /* Mask for byte count */
|
#define FRAG_BYTEMASK 0x07 /* Mask for byte count */
|
||||||
|
#define FRAG_CHECKMASK 0xC0 /* Mask for check type */
|
||||||
|
|
||||||
|
/* Fragment types */
|
||||||
#define FRAG_LITERAL 0x00 /* Literal data */
|
#define FRAG_LITERAL 0x00 /* Literal data */
|
||||||
|
|
||||||
#define FRAG_EXPR 0x08 /* Expression */
|
#define FRAG_EXPR 0x08 /* Expression */
|
||||||
@@ -70,6 +72,11 @@
|
|||||||
|
|
||||||
#define FRAG_FILL 0x20 /* Fill bytes */
|
#define FRAG_FILL 0x20 /* Fill bytes */
|
||||||
|
|
||||||
|
/* Fragment checks */
|
||||||
|
#define FRAG_CHECK_NONE 0x00 /* No checks applied */
|
||||||
|
#define FRAG_CHECK_WARN 0x40 /* Check and warn */
|
||||||
|
#define FRAG_CHECK_ERROR 0x80 /* Check and abort */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Segment definition */
|
/* Segment definition */
|
||||||
|
|||||||
@@ -60,8 +60,8 @@
|
|||||||
|
|
||||||
|
|
||||||
/* A string pool entry */
|
/* A string pool entry */
|
||||||
struct StrPoolEntry {
|
struct StringPoolEntry {
|
||||||
StrPoolEntry* Next; /* Pointer to next entry in hash chain */
|
StringPoolEntry* Next; /* Pointer to next entry in hash chain */
|
||||||
unsigned Hash; /* Full hash value */
|
unsigned Hash; /* Full hash value */
|
||||||
unsigned Id; /* The numeric string id */
|
unsigned Id; /* The numeric string id */
|
||||||
unsigned Len; /* Length of the string (excluding terminator) */
|
unsigned Len; /* Length of the string (excluding terminator) */
|
||||||
@@ -71,19 +71,19 @@ struct StrPoolEntry {
|
|||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* struct StrPoolEntry */
|
/* struct StringPoolEntry */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static StrPoolEntry* NewStrPoolEntry (const char* S, unsigned Hash, unsigned Id)
|
static StringPoolEntry* NewStringPoolEntry (const char* S, unsigned Hash, unsigned Id)
|
||||||
/* Create a new string pool entry and return it. */
|
/* Create a new string pool entry and return it. */
|
||||||
{
|
{
|
||||||
/* Get the length of the string */
|
/* Get the length of the string */
|
||||||
unsigned Len = strlen (S);
|
unsigned Len = strlen (S);
|
||||||
|
|
||||||
/* Allocate memory */
|
/* Allocate memory */
|
||||||
StrPoolEntry* E = xmalloc (sizeof (StrPoolEntry) + Len);
|
StringPoolEntry* E = xmalloc (sizeof (StringPoolEntry) + Len);
|
||||||
|
|
||||||
/* Initialize the fields */
|
/* Initialize the fields */
|
||||||
E->Next = 0;
|
E->Next = 0;
|
||||||
@@ -104,7 +104,7 @@ static StrPoolEntry* NewStrPoolEntry (const char* S, unsigned Hash, unsigned Id)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
StrPool* InitStrPool (StrPool* P)
|
StringPool* InitStringPool (StringPool* P)
|
||||||
/* Initialize a string pool */
|
/* Initialize a string pool */
|
||||||
{
|
{
|
||||||
unsigned I;
|
unsigned I;
|
||||||
@@ -122,7 +122,7 @@ StrPool* InitStrPool (StrPool* P)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DoneStrPool (StrPool* P)
|
void DoneStringPool (StringPool* P)
|
||||||
/* Free the data of a string pool (but not the data itself) */
|
/* Free the data of a string pool (but not the data itself) */
|
||||||
{
|
{
|
||||||
unsigned I;
|
unsigned I;
|
||||||
@@ -144,20 +144,20 @@ void DoneStrPool (StrPool* P)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
StrPool* NewStrPool (void)
|
StringPool* NewStringPool (void)
|
||||||
/* Allocate, initialize and return a new string pool */
|
/* Allocate, initialize and return a new string pool */
|
||||||
{
|
{
|
||||||
/* Allocate memory, initialize and return it */
|
/* Allocate memory, initialize and return it */
|
||||||
return InitStrPool (xmalloc (sizeof (StrPool)));
|
return InitStringPool (xmalloc (sizeof (StringPool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void FreeStrPool (StrPool* P)
|
void FreeStringPool (StringPool* P)
|
||||||
/* Free a string pool */
|
/* Free a string pool */
|
||||||
{
|
{
|
||||||
/* Free all entries */
|
/* Free all entries */
|
||||||
DoneStrPool (P);
|
DoneStringPool (P);
|
||||||
|
|
||||||
/* Free the string pool itself */
|
/* Free the string pool itself */
|
||||||
xfree (P);
|
xfree (P);
|
||||||
@@ -165,11 +165,11 @@ void FreeStrPool (StrPool* P)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char* SP_Get (const StrPool* P, unsigned Index)
|
const char* SP_Get (const StringPool* P, unsigned Index)
|
||||||
/* Return a string from the pool. Index must exist, otherwise FAIL is called. */
|
/* Return a string from the pool. Index must exist, otherwise FAIL is called. */
|
||||||
{
|
{
|
||||||
/* Get the collection entry */
|
/* Get the collection entry */
|
||||||
const StrPoolEntry* E = CollConstAt (&P->Entries, Index);
|
const StringPoolEntry* E = CollConstAt (&P->Entries, Index);
|
||||||
|
|
||||||
/* Return the string from the entry */
|
/* Return the string from the entry */
|
||||||
return E->S;
|
return E->S;
|
||||||
@@ -177,7 +177,7 @@ const char* SP_Get (const StrPool* P, unsigned Index)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned SP_Add (StrPool* P, const char* S)
|
unsigned SP_Add (StringPool* P, const char* S)
|
||||||
/* Add a string to the buffer and return the index. If the string does already
|
/* Add a string to the buffer and return the index. If the string does already
|
||||||
* exist in the pool, SP_Add will just return the index of the existing string.
|
* exist in the pool, SP_Add will just return the index of the existing string.
|
||||||
*/
|
*/
|
||||||
@@ -189,7 +189,7 @@ unsigned SP_Add (StrPool* P, const char* S)
|
|||||||
unsigned RHash = Hash % (sizeof (P->Tab)/sizeof (P->Tab[0]));
|
unsigned RHash = Hash % (sizeof (P->Tab)/sizeof (P->Tab[0]));
|
||||||
|
|
||||||
/* Search for an existing entry */
|
/* Search for an existing entry */
|
||||||
StrPoolEntry* E = P->Tab[RHash];
|
StringPoolEntry* E = P->Tab[RHash];
|
||||||
while (E) {
|
while (E) {
|
||||||
if (E->Hash == Hash && strcmp (E->S, S) == 0) {
|
if (E->Hash == Hash && strcmp (E->S, S) == 0) {
|
||||||
/* Found, return the id of the existing string */
|
/* Found, return the id of the existing string */
|
||||||
@@ -199,7 +199,7 @@ unsigned SP_Add (StrPool* P, const char* S)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* We didn't find the entry, so create a new one */
|
/* We didn't find the entry, so create a new one */
|
||||||
E = NewStrPoolEntry (S, Hash, CollCount (&P->Entries));
|
E = NewStringPoolEntry (S, Hash, CollCount (&P->Entries));
|
||||||
|
|
||||||
/* Insert the new entry into the entry collection */
|
/* Insert the new entry into the entry collection */
|
||||||
CollAppend (&P->Entries, E);
|
CollAppend (&P->Entries, E);
|
||||||
@@ -217,50 +217,3 @@ unsigned SP_Add (StrPool* P, const char* S)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned SP_AddBuf (StrPool* P, const void* Buffer, unsigned Size)
|
|
||||||
/* Add strings from a string buffer. Buffer must contain a list of zero
|
|
||||||
* terminated strings. These strings are added to the pool, starting with
|
|
||||||
* the current index. The number of strings added is returned.
|
|
||||||
* Beware: The function will do only loose range checking for the buffer
|
|
||||||
* limits, so a SEGV may occur if the last string in the buffer is not
|
|
||||||
* correctly terminated.
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
/* Cast the buffer pointer to something useful */
|
|
||||||
const char* Buf = Buffer;
|
|
||||||
|
|
||||||
/* Remember the current number of strings in the buffer. */
|
|
||||||
unsigned OldCount = SB_GetCount (P);
|
|
||||||
|
|
||||||
/* Add all strings from the buffer */
|
|
||||||
while (Size) {
|
|
||||||
|
|
||||||
/* Add the next entry */
|
|
||||||
unsigned Id = SP_Add (P, Buf);
|
|
||||||
|
|
||||||
/* Get the entry from the id */
|
|
||||||
const StrPoolEntry* E = CollConstAt (&P->Entries, Id);
|
|
||||||
|
|
||||||
/* Skip this string */
|
|
||||||
Buf += E->Len + 1;
|
|
||||||
Size -= E->Len + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the number of strings added */
|
|
||||||
return SB_GetCount (P) - OldCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SP_Build (StrPool* P, const void* Buffer, unsigned Size)
|
|
||||||
/* Delete existing data and use the data from Buffer instead. */
|
|
||||||
{
|
|
||||||
/* Delete old data */
|
|
||||||
DoneStrPool (P);
|
|
||||||
|
|
||||||
/* Add the buffer data */
|
|
||||||
SP_AddBuf (P, Buffer, Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -60,16 +60,26 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Opaque entry */
|
/* Opaque string pool entry */
|
||||||
typedef struct StrPoolEntry StrPoolEntry;
|
typedef struct StringPoolEntry StringPoolEntry;
|
||||||
|
|
||||||
typedef struct StrPool StrPool;
|
/* A string pool */
|
||||||
struct StrPool {
|
typedef struct StringPool StringPool;
|
||||||
StrPoolEntry* Tab[211]; /* Entry hash table */
|
struct StringPool {
|
||||||
Collection Entries; /* Entries sorted by number */
|
Collection Entries; /* Entries sorted by number */
|
||||||
unsigned TotalSize; /* Total size of all string data */
|
unsigned TotalSize; /* Total size of all string data */
|
||||||
|
StringPoolEntry* Tab[211]; /* Entry hash table */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* A string pool initializer. We do only initialize the first field, all
|
||||||
|
* others will get zeroed out by the compiler.
|
||||||
|
*/
|
||||||
|
#define STATIC_STRINGPOOL_INITIALIZER { \
|
||||||
|
STATIC_COLLECTION_INITIALIZER, \
|
||||||
|
0, \
|
||||||
|
{ 0 } \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -78,39 +88,34 @@ struct StrPool {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
StrPool* InitStrPool (StrPool* P);
|
StringPool* InitStringPool (StringPool* P);
|
||||||
/* Initialize a string pool */
|
/* Initialize a string pool */
|
||||||
|
|
||||||
void DoneStrPool (StrPool* P);
|
void DoneStringPool (StringPool* P);
|
||||||
/* Free the data of a string pool (but not the data itself) */
|
/* Free the data of a string pool (but not the data itself) */
|
||||||
|
|
||||||
StrPool* NewStrPool (void);
|
StringPool* NewStringPool (void);
|
||||||
/* Allocate, initialize and return a new string pool */
|
/* Allocate, initialize and return a new string pool */
|
||||||
|
|
||||||
void FreeStrPool (StrPool* P);
|
void FreeStringPool (StringPool* P);
|
||||||
/* Free a string pool */
|
/* Free a string pool */
|
||||||
|
|
||||||
void SP_Use (char* Buffer, unsigned Size);
|
const char* SP_Get (const StringPool* P, unsigned Index);
|
||||||
/* Delete existing data and use the data from Buffer instead. Buffer must be
|
|
||||||
* allocated on the heap and will be freed using xfree() if necessary.
|
|
||||||
*/
|
|
||||||
|
|
||||||
const char* SP_Get (const StrPool* P, unsigned Index);
|
|
||||||
/* Return a string from the pool. Index must exist, otherwise FAIL is called. */
|
/* Return a string from the pool. Index must exist, otherwise FAIL is called. */
|
||||||
|
|
||||||
unsigned SP_Add (StrPool* P, const char* S);
|
unsigned SP_Add (StringPool* P, const char* S);
|
||||||
/* Add a string to the buffer and return the index. If the string does already
|
/* Add a string to the buffer and return the index. If the string does already
|
||||||
* exist in the pool, SP_Add will just return the index of the existing string.
|
* exist in the pool, SP_Add will just return the index of the existing string.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(HAVE_INLINE)
|
#if defined(HAVE_INLINE)
|
||||||
INLINE unsigned SB_GetCount (const StrPool* P)
|
INLINE unsigned SP_GetCount (const StringPool* P)
|
||||||
/* Return the number of strings in the pool */
|
/* Return the number of strings in the pool */
|
||||||
{
|
{
|
||||||
return CollCount (&P->Entries);
|
return CollCount (&P->Entries);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define SB_GetCount(P) CollCount (&(P)->Entries)
|
# define SP_GetCount(P) CollCount (&(P)->Entries)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2000 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -80,8 +80,8 @@ static DbgSym* NewDbgSym (unsigned char Type, ObjData* O)
|
|||||||
D->Flags = 0;
|
D->Flags = 0;
|
||||||
D->Obj = O;
|
D->Obj = O;
|
||||||
D->Expr = 0;
|
D->Expr = 0;
|
||||||
D->Type = Type;
|
|
||||||
D->Name = 0;
|
D->Name = 0;
|
||||||
|
D->Type = Type;
|
||||||
|
|
||||||
/* Return the new entry */
|
/* Return the new entry */
|
||||||
return D;
|
return D;
|
||||||
@@ -148,7 +148,7 @@ DbgSym* ReadDbgSym (FILE* F, ObjData* O)
|
|||||||
D = NewDbgSym (Type, O);
|
D = NewDbgSym (Type, O);
|
||||||
|
|
||||||
/* Read and assign the name */
|
/* Read and assign the name */
|
||||||
D->Name = ReadStr (F);
|
D->Name = GetObjString (O, ReadVar (F));
|
||||||
|
|
||||||
/* Read the value */
|
/* Read the value */
|
||||||
if (IS_EXP_EXPR (Type)) {
|
if (IS_EXP_EXPR (Type)) {
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -63,8 +63,8 @@ struct DbgSym {
|
|||||||
ObjData* Obj; /* Object file that exports the name */
|
ObjData* Obj; /* Object file that exports the name */
|
||||||
FilePos Pos; /* File position of definition */
|
FilePos Pos; /* File position of definition */
|
||||||
ExprNode* Expr; /* Expression (0 if not def'd) */
|
ExprNode* Expr; /* Expression (0 if not def'd) */
|
||||||
|
const char* Name; /* Name */
|
||||||
unsigned char Type; /* Type of symbol */
|
unsigned char Type; /* Type of symbol */
|
||||||
char* Name; /* Name - dynamically allocated */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -114,7 +114,7 @@ void InsertImport (Import* I)
|
|||||||
unsigned HashVal;
|
unsigned HashVal;
|
||||||
|
|
||||||
/* As long as the import is not inserted, V.Name is valid */
|
/* As long as the import is not inserted, V.Name is valid */
|
||||||
char* Name = I->V.Name;
|
const char* Name = I->V.Name;
|
||||||
|
|
||||||
/* Create a hash value for the given name */
|
/* Create a hash value for the given name */
|
||||||
HashVal = HashStr (Name) % HASHTAB_SIZE;
|
HashVal = HashStr (Name) % HASHTAB_SIZE;
|
||||||
@@ -155,9 +155,6 @@ void InsertImport (Import* I)
|
|||||||
/* This is a dummy export */
|
/* This is a dummy export */
|
||||||
++ImpOpen;
|
++ImpOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now free the name since it's no longer needed */
|
|
||||||
xfree (Name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -178,7 +175,7 @@ Import* ReadImport (FILE* F, ObjData* Obj)
|
|||||||
I = NewImport (Type, Obj);
|
I = NewImport (Type, Obj);
|
||||||
|
|
||||||
/* Read the name */
|
/* Read the name */
|
||||||
I->V.Name = ReadStr (F);
|
I->V.Name = GetObjString (Obj, ReadVar (F));
|
||||||
|
|
||||||
/* Read the file position */
|
/* Read the file position */
|
||||||
ReadFilePos (F, &I->Pos);
|
ReadFilePos (F, &I->Pos);
|
||||||
@@ -328,7 +325,7 @@ Export* ReadExport (FILE* F, ObjData* O)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read the name */
|
/* Read the name */
|
||||||
E->Name = ReadStr (F);
|
E->Name = GetObjString (O, ReadVar (F));
|
||||||
|
|
||||||
/* Read the value */
|
/* Read the value */
|
||||||
if (IS_EXP_EXPR (Type)) {
|
if (IS_EXP_EXPR (Type)) {
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2000 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -65,7 +65,7 @@ struct Import {
|
|||||||
FilePos Pos; /* File position of reference */
|
FilePos Pos; /* File position of reference */
|
||||||
union {
|
union {
|
||||||
struct Export* Exp; /* Matching export for this import */
|
struct Export* Exp; /* Matching export for this import */
|
||||||
char* Name; /* Name if not in table */
|
const char* Name; /* Name if not in table */
|
||||||
} V;
|
} V;
|
||||||
unsigned char Type; /* Type of import */
|
unsigned char Type; /* Type of import */
|
||||||
};
|
};
|
||||||
@@ -84,7 +84,7 @@ struct Export {
|
|||||||
ExprNode* Expr; /* Expression (0 if not def'd) */
|
ExprNode* Expr; /* Expression (0 if not def'd) */
|
||||||
unsigned char Type; /* Type of export */
|
unsigned char Type; /* Type of export */
|
||||||
unsigned char ConDes[CD_TYPE_COUNT]; /* Constructor/destructor decls */
|
unsigned char ConDes[CD_TYPE_COUNT]; /* Constructor/destructor decls */
|
||||||
char* Name; /* Name - dynamically allocated */
|
const char* Name; /* Name */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -468,7 +468,7 @@ ExprNode* ReadExpr (FILE* F, ObjData* O)
|
|||||||
|
|
||||||
case EXPR_SYMBOL:
|
case EXPR_SYMBOL:
|
||||||
/* Read the import number */
|
/* Read the import number */
|
||||||
Expr->V.ImpNum = Read16 (F);
|
Expr->V.ImpNum = ReadVar (F);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EXPR_SECTION:
|
case EXPR_SECTION:
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@@ -52,7 +52,7 @@ Fragment* NewFragment (unsigned char Type, unsigned long Size, Section* S)
|
|||||||
/* Create a new fragment and insert it into the section S */
|
/* Create a new fragment and insert it into the section S */
|
||||||
{
|
{
|
||||||
/* Allocate memory */
|
/* Allocate memory */
|
||||||
Fragment* F = xmalloc (sizeof (Fragment) - 1 + Size); /* Portable? */
|
Fragment* F = xmalloc (sizeof (Fragment) - 1 + Size);
|
||||||
|
|
||||||
/* Initialize the data */
|
/* Initialize the data */
|
||||||
F->Next = 0;
|
F->Next = 0;
|
||||||
@@ -61,6 +61,8 @@ Fragment* NewFragment (unsigned char Type, unsigned long Size, Section* S)
|
|||||||
F->Expr = 0;
|
F->Expr = 0;
|
||||||
InitFilePos (&F->Pos);
|
InitFilePos (&F->Pos);
|
||||||
F->LI = 0;
|
F->LI = 0;
|
||||||
|
F->WarnExpr = 0;
|
||||||
|
F->ErrorExpr = 0;
|
||||||
F->Type = Type;
|
F->Type = Type;
|
||||||
|
|
||||||
/* Insert the code fragment into the section */
|
/* Insert the code fragment into the section */
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@@ -69,6 +69,8 @@ struct Fragment {
|
|||||||
struct ExprNode* Expr; /* Expression if FRAG_EXPR */
|
struct ExprNode* Expr; /* Expression if FRAG_EXPR */
|
||||||
FilePos Pos; /* File position in source */
|
FilePos Pos; /* File position in source */
|
||||||
struct LineInfo* LI; /* Additional line info */
|
struct LineInfo* LI; /* Additional line info */
|
||||||
|
struct ExprNode* WarnExpr; /* Print warning if expr true */
|
||||||
|
struct ExprNode* ErrorExpr; /* Print error if expr true */
|
||||||
unsigned char Type; /* Type of fragment */
|
unsigned char Type; /* Type of fragment */
|
||||||
unsigned char LitBuf [1]; /* Dynamically alloc'ed literal buffer */
|
unsigned char LitBuf [1]; /* Dynamically alloc'ed literal buffer */
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@@ -103,6 +103,8 @@ static void LibReadObjHeader (ObjData* O)
|
|||||||
O->Header.DbgSymSize = Read32 (Lib);
|
O->Header.DbgSymSize = Read32 (Lib);
|
||||||
O->Header.LineInfoOffs = Read32 (Lib);
|
O->Header.LineInfoOffs = Read32 (Lib);
|
||||||
O->Header.LineInfoSize = Read32 (Lib);
|
O->Header.LineInfoSize = Read32 (Lib);
|
||||||
|
O->Header.StrPoolOffs = Read32 (Lib);
|
||||||
|
O->Header.StrPoolSize = Read32 (Lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -122,20 +124,23 @@ static ObjData* ReadIndexEntry (void)
|
|||||||
O->Start = Read32 (Lib);
|
O->Start = Read32 (Lib);
|
||||||
Read32 (Lib); /* Skip Size */
|
Read32 (Lib); /* Skip Size */
|
||||||
|
|
||||||
|
/* Read the string pool */
|
||||||
|
ObjReadStrPool (Lib, O);
|
||||||
|
|
||||||
/* Skip the export size, then read the exports */
|
/* Skip the export size, then read the exports */
|
||||||
Read16 (Lib);
|
(void) ReadVar (Lib);
|
||||||
O->ExportCount = ReadVar (Lib);
|
O->ExportCount = ReadVar (Lib);
|
||||||
O->Exports = xmalloc (O->ExportCount * sizeof (Export*));
|
O->Exports = xmalloc (O->ExportCount * sizeof (Export*));
|
||||||
for (I = 0; I < O->ExportCount; ++I) {
|
for (I = 0; I < O->ExportCount; ++I) {
|
||||||
O->Exports [I] = ReadExport (Lib, O);
|
O->Exports[I] = ReadExport (Lib, O);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Skip the import size, then read the imports */
|
/* Skip the import size, then read the imports */
|
||||||
Read16 (Lib);
|
(void) ReadVar (Lib);
|
||||||
O->ImportCount = ReadVar (Lib);
|
O->ImportCount = ReadVar (Lib);
|
||||||
O->Imports = xmalloc (O->ImportCount * sizeof (Import*));
|
O->Imports = xmalloc (O->ImportCount * sizeof (Import*));
|
||||||
for (I = 0; I < O->ImportCount; ++I) {
|
for (I = 0; I < O->ImportCount; ++I) {
|
||||||
O->Imports [I] = ReadImport (Lib, O);
|
O->Imports[I] = ReadImport (Lib, O);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Done */
|
/* Done */
|
||||||
@@ -150,12 +155,12 @@ static void ReadIndex (void)
|
|||||||
unsigned I;
|
unsigned I;
|
||||||
|
|
||||||
/* Read the object file count and allocate memory */
|
/* Read the object file count and allocate memory */
|
||||||
ModuleCount = Read16 (Lib);
|
ModuleCount = ReadVar (Lib);
|
||||||
Index = xmalloc (ModuleCount * sizeof (ObjData*));
|
Index = xmalloc (ModuleCount * sizeof (ObjData*));
|
||||||
|
|
||||||
/* Read all entries in the index */
|
/* Read all entries in the index */
|
||||||
for (I = 0; I < ModuleCount; ++I) {
|
for (I = 0; I < ModuleCount; ++I) {
|
||||||
Index [I] = ReadIndexEntry ();
|
Index[I] = ReadIndexEntry ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +181,7 @@ static void LibCheckExports (ObjData* O)
|
|||||||
|
|
||||||
/* Check all exports */
|
/* Check all exports */
|
||||||
for (I = 0; I < O->ExportCount; ++I) {
|
for (I = 0; I < O->ExportCount; ++I) {
|
||||||
if (IsUnresolved (O->Exports [I]->Name)) {
|
if (IsUnresolved (O->Exports[I]->Name)) {
|
||||||
/* We need this module */
|
/* We need this module */
|
||||||
O->Flags |= OBJ_REF;
|
O->Flags |= OBJ_REF;
|
||||||
break;
|
break;
|
||||||
@@ -187,11 +192,11 @@ static void LibCheckExports (ObjData* O)
|
|||||||
if (O->Flags & OBJ_REF) {
|
if (O->Flags & OBJ_REF) {
|
||||||
/* Insert the exports */
|
/* Insert the exports */
|
||||||
for (I = 0; I < O->ExportCount; ++I) {
|
for (I = 0; I < O->ExportCount; ++I) {
|
||||||
InsertExport (O->Exports [I]);
|
InsertExport (O->Exports[I]);
|
||||||
}
|
}
|
||||||
/* Insert the imports */
|
/* Insert the imports */
|
||||||
for (I = 0; I < O->ImportCount; ++I) {
|
for (I = 0; I < O->ImportCount; ++I) {
|
||||||
InsertImport (O->Imports [I]);
|
InsertImport (O->Imports[I]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@@ -86,6 +86,8 @@ ObjData* NewObjData (void)
|
|||||||
O->DbgSyms = 0;
|
O->DbgSyms = 0;
|
||||||
O->LineInfoCount = 0;
|
O->LineInfoCount = 0;
|
||||||
O->LineInfos = 0;
|
O->LineInfos = 0;
|
||||||
|
O->StringCount = 0;
|
||||||
|
O->Strings = 0;
|
||||||
|
|
||||||
/* Link it into the list */
|
/* Link it into the list */
|
||||||
if (ObjLast) {
|
if (ObjLast) {
|
||||||
@@ -105,15 +107,16 @@ ObjData* NewObjData (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void FreeObjData (ObjData* O)
|
const char* GetObjString (const ObjData* O, unsigned long Index)
|
||||||
/* Free a complete struct */
|
/* Get a string from the object file string table. Abort if the string index
|
||||||
|
* is invalid.
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
xfree (O->Name);
|
if (Index >= O->StringCount) {
|
||||||
xfree (O->Imports);
|
Error ("Invalid string index (%lu) in module `%s'",
|
||||||
xfree (O->Exports);
|
Index, GetObjFileName (O));
|
||||||
xfree (O->DbgSyms);
|
}
|
||||||
xfree (O->LineInfos);
|
return O->Strings[Index];
|
||||||
xfree (O);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@@ -76,6 +76,8 @@ struct ObjData {
|
|||||||
struct DbgSym** DbgSyms; /* List of debug symbols */
|
struct DbgSym** DbgSyms; /* List of debug symbols */
|
||||||
unsigned LineInfoCount; /* Count of additional line infos */
|
unsigned LineInfoCount; /* Count of additional line infos */
|
||||||
struct LineInfo** LineInfos; /* List of additional line infos */
|
struct LineInfo** LineInfos; /* List of additional line infos */
|
||||||
|
unsigned StringCount; /* Count of strings */
|
||||||
|
char** Strings; /* List of strings used */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -96,8 +98,10 @@ extern ObjData* ObjLast; /* Last entry in list */
|
|||||||
ObjData* NewObjData (void);
|
ObjData* NewObjData (void);
|
||||||
/* Allocate a new structure on the heap, insert it into the list, return it */
|
/* Allocate a new structure on the heap, insert it into the list, return it */
|
||||||
|
|
||||||
void FreeObjData (ObjData* O);
|
const char* GetObjString (const ObjData* O, unsigned long Index);
|
||||||
/* Free a complete struct */
|
/* Get a string from the object file string table. Abort if the string index
|
||||||
|
* is invalid.
|
||||||
|
*/
|
||||||
|
|
||||||
const char* GetObjFileName (const ObjData* O);
|
const char* GetObjFileName (const ObjData* O);
|
||||||
/* Get the name of the object file. Return "[linker generated]" if the object
|
/* Get the name of the object file. Return "[linker generated]" if the object
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@@ -86,7 +86,8 @@ static void ObjReadHeader (FILE* Obj, ObjHeader* H, const char* Name)
|
|||||||
{
|
{
|
||||||
H->Version = Read16 (Obj);
|
H->Version = Read16 (Obj);
|
||||||
if (H->Version != OBJ_VERSION) {
|
if (H->Version != OBJ_VERSION) {
|
||||||
Error ("Object file `%s' has wrong version", Name);
|
Error ("Object file `%s' has wrong version, expected %08X, got %08X",
|
||||||
|
Name, OBJ_VERSION, H->Version);
|
||||||
}
|
}
|
||||||
H->Flags = Read16 (Obj);
|
H->Flags = Read16 (Obj);
|
||||||
H->OptionOffs = Read32 (Obj);
|
H->OptionOffs = Read32 (Obj);
|
||||||
@@ -103,6 +104,8 @@ static void ObjReadHeader (FILE* Obj, ObjHeader* H, const char* Name)
|
|||||||
H->DbgSymSize = Read32 (Obj);
|
H->DbgSymSize = Read32 (Obj);
|
||||||
H->LineInfoOffs = Read32 (Obj);
|
H->LineInfoOffs = Read32 (Obj);
|
||||||
H->LineInfoSize = Read32 (Obj);
|
H->LineInfoSize = Read32 (Obj);
|
||||||
|
H->StrPoolOffs = Read32 (Obj);
|
||||||
|
H->StrPoolSize = Read32 (Obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -179,6 +182,19 @@ void ObjReadLineInfos (FILE* F, ObjData* O)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ObjReadStrPool (FILE* F, ObjData* O)
|
||||||
|
/* Read the string pool from a file at the current position */
|
||||||
|
{
|
||||||
|
unsigned I;
|
||||||
|
O->StringCount = ReadVar (F);
|
||||||
|
O->Strings = xmalloc (O->StringCount * sizeof (char*));
|
||||||
|
for (I = 0; I < O->StringCount; ++I) {
|
||||||
|
O->Strings[I] = ReadStr (F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ObjReadSections (FILE* F, ObjData* O)
|
void ObjReadSections (FILE* F, ObjData* O)
|
||||||
/* Read the section data from a file at the current position */
|
/* Read the section data from a file at the current position */
|
||||||
{
|
{
|
||||||
@@ -209,6 +225,10 @@ void ObjAdd (FILE* Obj, const char* Name)
|
|||||||
O->Name = xstrdup (GetModule (Name));
|
O->Name = xstrdup (GetModule (Name));
|
||||||
O->Flags = OBJ_HAVEDATA;
|
O->Flags = OBJ_HAVEDATA;
|
||||||
|
|
||||||
|
/* Read the string pool from the object file */
|
||||||
|
fseek (Obj, O->Header.StrPoolOffs, SEEK_SET);
|
||||||
|
ObjReadStrPool (Obj, O);
|
||||||
|
|
||||||
/* Read the files list from the object file */
|
/* Read the files list from the object file */
|
||||||
fseek (Obj, O->Header.FileOffs, SEEK_SET);
|
fseek (Obj, O->Header.FileOffs, SEEK_SET);
|
||||||
ObjReadFiles (Obj, O);
|
ObjReadFiles (Obj, O);
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@@ -69,6 +69,9 @@ void ObjReadDbgSyms (FILE* F, ObjData* O);
|
|||||||
void ObjReadLineInfos (FILE* F, ObjData* O);
|
void ObjReadLineInfos (FILE* F, ObjData* O);
|
||||||
/* Read the line infos from a file at the current position */
|
/* Read the line infos from a file at the current position */
|
||||||
|
|
||||||
|
void ObjReadStrPool (FILE* F, ObjData* O);
|
||||||
|
/* Read the string pool from a file at the current position */
|
||||||
|
|
||||||
void ObjReadSections (FILE* F, ObjData* O);
|
void ObjReadSections (FILE* F, ObjData* O);
|
||||||
/* Read the section data from a file at the current position */
|
/* Read the section data from a file at the current position */
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@@ -259,6 +259,10 @@ Section* ReadSection (FILE* F, ObjData* O)
|
|||||||
/* Read the fragment type */
|
/* Read the fragment type */
|
||||||
unsigned char Type = Read8 (F);
|
unsigned char Type = Read8 (F);
|
||||||
|
|
||||||
|
/* Extract the check mask from the type */
|
||||||
|
unsigned char Check = Type & FRAG_CHECKMASK;
|
||||||
|
Type &= ~FRAG_CHECKMASK;
|
||||||
|
|
||||||
/* Handle the different fragment types */
|
/* Handle the different fragment types */
|
||||||
switch (Type) {
|
switch (Type) {
|
||||||
|
|
||||||
@@ -305,6 +309,14 @@ Section* ReadSection (FILE* F, ObjData* O)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* A check expression may follow */
|
||||||
|
if (Check & FRAG_CHECK_WARN) {
|
||||||
|
Frag->WarnExpr = ReadExpr (F, O);
|
||||||
|
}
|
||||||
|
if (Check & FRAG_CHECK_ERROR) {
|
||||||
|
Frag->ErrorExpr = ReadExpr (F, O);
|
||||||
|
}
|
||||||
|
|
||||||
/* Read the file position of the fragment */
|
/* Read the file position of the fragment */
|
||||||
ReadFilePos (F, &Frag->Pos);
|
ReadFilePos (F, &Frag->Pos);
|
||||||
|
|
||||||
@@ -507,6 +519,11 @@ void SegWrite (FILE* Tgt, Segment* S, SegWriteFunc F, void* Data)
|
|||||||
Frag = Sec->FragRoot;
|
Frag = Sec->FragRoot;
|
||||||
while (Frag) {
|
while (Frag) {
|
||||||
|
|
||||||
|
/* Do fragment alignment checks */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Output fragment data */
|
||||||
switch (Frag->Type) {
|
switch (Frag->Type) {
|
||||||
|
|
||||||
case FRAG_LITERAL:
|
case FRAG_LITERAL:
|
||||||
|
|||||||
170
src/od65/dump.c
170
src/od65/dump.c
@@ -6,9 +6,9 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2000-2002 Ullrich von Bassewitz */
|
/* (C) 2002-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
@@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
/* common */
|
/* common */
|
||||||
#include "cddefs.h"
|
#include "cddefs.h"
|
||||||
|
#include "coll.h"
|
||||||
#include "exprdefs.h"
|
#include "exprdefs.h"
|
||||||
#include "filepos.h"
|
#include "filepos.h"
|
||||||
#include "objdefs.h"
|
#include "objdefs.h"
|
||||||
@@ -59,6 +60,34 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void DestroyStrPool (Collection* C)
|
||||||
|
/* Free all strings in the given pool plus the item pointers. Note: The
|
||||||
|
* collection may not be reused later.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
unsigned I;
|
||||||
|
for (I = 0; I < CollCount (C); ++I) {
|
||||||
|
xfree (CollAtUnchecked (C, I));
|
||||||
|
}
|
||||||
|
DoneCollection (C);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static const char* GetString (const Collection* C, unsigned Index)
|
||||||
|
/* Get a string from a collection. In fact, this function calls CollConstAt,
|
||||||
|
* but will print a somewhat more readable error message if the index is out
|
||||||
|
* of bounds.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
if (Index >= CollCount (C)) {
|
||||||
|
Error ("Invalid string index (%u) - file corrupt!", Index);
|
||||||
|
}
|
||||||
|
return CollConstAt (C, Index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void DumpObjHeaderSection (const char* Name,
|
static void DumpObjHeaderSection (const char* Name,
|
||||||
unsigned long Offset,
|
unsigned long Offset,
|
||||||
unsigned long Size)
|
unsigned long Size)
|
||||||
@@ -109,7 +138,7 @@ static void SkipExpr (FILE* F)
|
|||||||
|
|
||||||
case EXPR_SYMBOL:
|
case EXPR_SYMBOL:
|
||||||
/* Read the import number */
|
/* Read the import number */
|
||||||
(void) Read16 (F);
|
(void) ReadVar (F);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EXPR_SECTION:
|
case EXPR_SECTION:
|
||||||
@@ -142,6 +171,10 @@ static unsigned SkipFragment (FILE* F)
|
|||||||
/* Read the fragment type */
|
/* Read the fragment type */
|
||||||
unsigned char Type = Read8 (F);
|
unsigned char Type = Read8 (F);
|
||||||
|
|
||||||
|
/* Extract the check mask */
|
||||||
|
unsigned char Check = Type & FRAG_CHECKMASK;
|
||||||
|
Type &= ~FRAG_CHECKMASK;
|
||||||
|
|
||||||
/* Handle the different fragment types */
|
/* Handle the different fragment types */
|
||||||
switch (Type) {
|
switch (Type) {
|
||||||
|
|
||||||
@@ -188,6 +221,14 @@ static unsigned SkipFragment (FILE* F)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Skip the check expression if we have one */
|
||||||
|
if (Check & FRAG_CHECK_WARN) {
|
||||||
|
SkipExpr (F);
|
||||||
|
}
|
||||||
|
if (Check & FRAG_CHECK_ERROR) {
|
||||||
|
SkipExpr (F);
|
||||||
|
}
|
||||||
|
|
||||||
/* Skip the file position of the fragment */
|
/* Skip the file position of the fragment */
|
||||||
ReadFilePos (F, &Pos);
|
ReadFilePos (F, &Pos);
|
||||||
|
|
||||||
@@ -290,6 +331,12 @@ void DumpObjHeader (FILE* F, unsigned long Offset)
|
|||||||
|
|
||||||
/* Debug symbols */
|
/* Debug symbols */
|
||||||
DumpObjHeaderSection ("Debug symbols", H.DbgSymOffs, H.DbgSymSize);
|
DumpObjHeaderSection ("Debug symbols", H.DbgSymOffs, H.DbgSymSize);
|
||||||
|
|
||||||
|
/* Line infos */
|
||||||
|
DumpObjHeaderSection ("Line infos", H.LineInfoOffs, H.LineInfoSize);
|
||||||
|
|
||||||
|
/* String pool */
|
||||||
|
DumpObjHeaderSection ("String pool", H.StrPoolOffs, H.StrPoolSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -298,15 +345,18 @@ void DumpObjOptions (FILE* F, unsigned long Offset)
|
|||||||
/* Dump the file options */
|
/* Dump the file options */
|
||||||
{
|
{
|
||||||
ObjHeader H;
|
ObjHeader H;
|
||||||
|
Collection StrPool = AUTO_COLLECTION_INITIALIZER;
|
||||||
unsigned Count;
|
unsigned Count;
|
||||||
unsigned I;
|
unsigned I;
|
||||||
|
|
||||||
/* Seek to the header position */
|
/* Seek to the header position and read the header */
|
||||||
FileSeek (F, Offset);
|
FileSeek (F, Offset);
|
||||||
|
|
||||||
/* Read the header */
|
|
||||||
ReadObjHeader (F, &H);
|
ReadObjHeader (F, &H);
|
||||||
|
|
||||||
|
/* Seek to the start of the string pool and read it */
|
||||||
|
FileSeek (F, Offset + H.StrPoolOffs);
|
||||||
|
ReadStrPool (F, &StrPool);
|
||||||
|
|
||||||
/* Seek to the start of the options */
|
/* Seek to the start of the options */
|
||||||
FileSeek (F, Offset + H.OptionOffs);
|
FileSeek (F, Offset + H.OptionOffs);
|
||||||
|
|
||||||
@@ -374,6 +424,9 @@ void DumpObjOptions (FILE* F, unsigned long Offset)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Destroy the string pool */
|
||||||
|
DestroyStrPool (&StrPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -382,15 +435,18 @@ void DumpObjFiles (FILE* F, unsigned long Offset)
|
|||||||
/* Dump the source files */
|
/* Dump the source files */
|
||||||
{
|
{
|
||||||
ObjHeader H;
|
ObjHeader H;
|
||||||
|
Collection StrPool = AUTO_COLLECTION_INITIALIZER;
|
||||||
unsigned Count;
|
unsigned Count;
|
||||||
unsigned I;
|
unsigned I;
|
||||||
|
|
||||||
/* Seek to the header position */
|
/* Seek to the header position and read the header */
|
||||||
FileSeek (F, Offset);
|
FileSeek (F, Offset);
|
||||||
|
|
||||||
/* Read the header */
|
|
||||||
ReadObjHeader (F, &H);
|
ReadObjHeader (F, &H);
|
||||||
|
|
||||||
|
/* Seek to the start of the string pool and read it */
|
||||||
|
FileSeek (F, Offset + H.StrPoolOffs);
|
||||||
|
ReadStrPool (F, &StrPool);
|
||||||
|
|
||||||
/* Seek to the start of the source files */
|
/* Seek to the start of the source files */
|
||||||
FileSeek (F, Offset + H.FileOffs);
|
FileSeek (F, Offset + H.FileOffs);
|
||||||
|
|
||||||
@@ -421,6 +477,9 @@ void DumpObjFiles (FILE* F, unsigned long Offset)
|
|||||||
/* Free the Name */
|
/* Free the Name */
|
||||||
xfree (Name);
|
xfree (Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Destroy the string pool */
|
||||||
|
DestroyStrPool (&StrPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -429,16 +488,19 @@ void DumpObjSegments (FILE* F, unsigned long Offset)
|
|||||||
/* Dump the segments in the object file */
|
/* Dump the segments in the object file */
|
||||||
{
|
{
|
||||||
ObjHeader H;
|
ObjHeader H;
|
||||||
|
Collection StrPool = AUTO_COLLECTION_INITIALIZER;
|
||||||
unsigned Count;
|
unsigned Count;
|
||||||
unsigned I;
|
unsigned I;
|
||||||
unsigned FragCount;
|
unsigned FragCount;
|
||||||
|
|
||||||
/* Seek to the header position */
|
/* Seek to the header position and read the header */
|
||||||
FileSeek (F, Offset);
|
FileSeek (F, Offset);
|
||||||
|
|
||||||
/* Read the header */
|
|
||||||
ReadObjHeader (F, &H);
|
ReadObjHeader (F, &H);
|
||||||
|
|
||||||
|
/* Seek to the start of the string pool and read it */
|
||||||
|
FileSeek (F, Offset + H.StrPoolOffs);
|
||||||
|
ReadStrPool (F, &StrPool);
|
||||||
|
|
||||||
/* Seek to the start of the segments */
|
/* Seek to the start of the segments */
|
||||||
FileSeek (F, Offset + H.SegOffs);
|
FileSeek (F, Offset + H.SegOffs);
|
||||||
|
|
||||||
@@ -496,6 +558,9 @@ void DumpObjSegments (FILE* F, unsigned long Offset)
|
|||||||
/* Print the fragment count */
|
/* Print the fragment count */
|
||||||
printf (" Fragment count:%16u\n", FragCount);
|
printf (" Fragment count:%16u\n", FragCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Destroy the string pool */
|
||||||
|
DestroyStrPool (&StrPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -504,16 +569,19 @@ void DumpObjImports (FILE* F, unsigned long Offset)
|
|||||||
/* Dump the imports in the object file */
|
/* Dump the imports in the object file */
|
||||||
{
|
{
|
||||||
ObjHeader H;
|
ObjHeader H;
|
||||||
|
Collection StrPool = AUTO_COLLECTION_INITIALIZER;
|
||||||
unsigned Count;
|
unsigned Count;
|
||||||
unsigned I;
|
unsigned I;
|
||||||
FilePos Pos;
|
FilePos Pos;
|
||||||
|
|
||||||
/* Seek to the header position */
|
/* Seek to the header position and read the header */
|
||||||
FileSeek (F, Offset);
|
FileSeek (F, Offset);
|
||||||
|
|
||||||
/* Read the header */
|
|
||||||
ReadObjHeader (F, &H);
|
ReadObjHeader (F, &H);
|
||||||
|
|
||||||
|
/* Seek to the start of the string pool and read it */
|
||||||
|
FileSeek (F, Offset + H.StrPoolOffs);
|
||||||
|
ReadStrPool (F, &StrPool);
|
||||||
|
|
||||||
/* Seek to the start of the imports */
|
/* Seek to the start of the imports */
|
||||||
FileSeek (F, Offset + H.ImportOffs);
|
FileSeek (F, Offset + H.ImportOffs);
|
||||||
|
|
||||||
@@ -531,7 +599,7 @@ void DumpObjImports (FILE* F, unsigned long Offset)
|
|||||||
|
|
||||||
/* Read the data for one import */
|
/* Read the data for one import */
|
||||||
unsigned char Type = Read8 (F);
|
unsigned char Type = Read8 (F);
|
||||||
char* Name = ReadStr (F);
|
const char* Name = GetString (&StrPool, ReadVar (F));
|
||||||
unsigned Len = strlen (Name);
|
unsigned Len = strlen (Name);
|
||||||
ReadFilePos (F, &Pos);
|
ReadFilePos (F, &Pos);
|
||||||
|
|
||||||
@@ -548,10 +616,10 @@ void DumpObjImports (FILE* F, unsigned long Offset)
|
|||||||
/* Print the data */
|
/* Print the data */
|
||||||
printf (" Type:%22s0x%02X (%s)\n", "", Type, TypeDesc);
|
printf (" Type:%22s0x%02X (%s)\n", "", Type, TypeDesc);
|
||||||
printf (" Name:%*s\"%s\"\n", 24-Len, "", Name);
|
printf (" Name:%*s\"%s\"\n", 24-Len, "", Name);
|
||||||
|
|
||||||
/* Free the Name */
|
|
||||||
xfree (Name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Destroy the string pool */
|
||||||
|
DestroyStrPool (&StrPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -560,16 +628,19 @@ void DumpObjExports (FILE* F, unsigned long Offset)
|
|||||||
/* Dump the exports in the object file */
|
/* Dump the exports in the object file */
|
||||||
{
|
{
|
||||||
ObjHeader H;
|
ObjHeader H;
|
||||||
|
Collection StrPool = AUTO_COLLECTION_INITIALIZER;
|
||||||
unsigned Count;
|
unsigned Count;
|
||||||
unsigned I;
|
unsigned I;
|
||||||
FilePos Pos;
|
FilePos Pos;
|
||||||
|
|
||||||
/* Seek to the header position */
|
/* Seek to the header position and read the header */
|
||||||
FileSeek (F, Offset);
|
FileSeek (F, Offset);
|
||||||
|
|
||||||
/* Read the header */
|
|
||||||
ReadObjHeader (F, &H);
|
ReadObjHeader (F, &H);
|
||||||
|
|
||||||
|
/* Seek to the start of the string pool and read it */
|
||||||
|
FileSeek (F, Offset + H.StrPoolOffs);
|
||||||
|
ReadStrPool (F, &StrPool);
|
||||||
|
|
||||||
/* Seek to the start of the exports */
|
/* Seek to the start of the exports */
|
||||||
FileSeek (F, Offset + H.ExportOffs);
|
FileSeek (F, Offset + H.ExportOffs);
|
||||||
|
|
||||||
@@ -587,14 +658,14 @@ void DumpObjExports (FILE* F, unsigned long Offset)
|
|||||||
int HaveValue;
|
int HaveValue;
|
||||||
unsigned char Type;
|
unsigned char Type;
|
||||||
unsigned char ConDes [CD_TYPE_COUNT];
|
unsigned char ConDes [CD_TYPE_COUNT];
|
||||||
char* Name;
|
const char* Name;
|
||||||
unsigned Len;
|
unsigned Len;
|
||||||
|
|
||||||
|
|
||||||
/* Read the data for one export */
|
/* Read the data for one export */
|
||||||
Type = Read8 (F);
|
Type = Read8 (F);
|
||||||
ReadData (F, ConDes, GET_EXP_CONDES_COUNT (Type));
|
ReadData (F, ConDes, GET_EXP_CONDES_COUNT (Type));
|
||||||
Name = ReadStr (F);
|
Name = GetString (&StrPool, ReadVar (F));
|
||||||
Len = strlen (Name);
|
Len = strlen (Name);
|
||||||
if (IS_EXP_EXPR (Type)) {
|
if (IS_EXP_EXPR (Type)) {
|
||||||
SkipExpr (F);
|
SkipExpr (F);
|
||||||
@@ -614,10 +685,10 @@ void DumpObjExports (FILE* F, unsigned long Offset)
|
|||||||
if (HaveValue) {
|
if (HaveValue) {
|
||||||
printf (" Value:%15s0x%08lX (%lu)\n", "", Value, Value);
|
printf (" Value:%15s0x%08lX (%lu)\n", "", Value, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the Name */
|
|
||||||
xfree (Name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Destroy the string pool */
|
||||||
|
DestroyStrPool (&StrPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -626,16 +697,19 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset)
|
|||||||
/* Dump the debug symbols from an object file */
|
/* Dump the debug symbols from an object file */
|
||||||
{
|
{
|
||||||
ObjHeader H;
|
ObjHeader H;
|
||||||
|
Collection StrPool = AUTO_COLLECTION_INITIALIZER;
|
||||||
unsigned Count;
|
unsigned Count;
|
||||||
unsigned I;
|
unsigned I;
|
||||||
FilePos Pos;
|
FilePos Pos;
|
||||||
|
|
||||||
/* Seek to the header position */
|
/* Seek to the header position and read the header */
|
||||||
FileSeek (F, Offset);
|
FileSeek (F, Offset);
|
||||||
|
|
||||||
/* Read the header */
|
|
||||||
ReadObjHeader (F, &H);
|
ReadObjHeader (F, &H);
|
||||||
|
|
||||||
|
/* Seek to the start of the string pool and read it */
|
||||||
|
FileSeek (F, Offset + H.StrPoolOffs);
|
||||||
|
ReadStrPool (F, &StrPool);
|
||||||
|
|
||||||
/* Seek to the start of the debug syms */
|
/* Seek to the start of the debug syms */
|
||||||
FileSeek (F, Offset + H.DbgSymOffs);
|
FileSeek (F, Offset + H.DbgSymOffs);
|
||||||
|
|
||||||
@@ -660,13 +734,13 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset)
|
|||||||
int HaveValue;
|
int HaveValue;
|
||||||
unsigned char Type;
|
unsigned char Type;
|
||||||
unsigned char ConDes [CD_TYPE_COUNT];
|
unsigned char ConDes [CD_TYPE_COUNT];
|
||||||
char* Name;
|
const char* Name;
|
||||||
unsigned Len;
|
unsigned Len;
|
||||||
|
|
||||||
/* Read the data for one symbol */
|
/* Read the data for one symbol */
|
||||||
Type = Read8 (F);
|
Type = Read8 (F);
|
||||||
ReadData (F, ConDes, GET_EXP_CONDES_COUNT (Type));
|
ReadData (F, ConDes, GET_EXP_CONDES_COUNT (Type));
|
||||||
Name = ReadStr (F);
|
Name = GetString (&StrPool, ReadVar (F));
|
||||||
Len = strlen (Name);
|
Len = strlen (Name);
|
||||||
if (IS_EXP_EXPR (Type)) {
|
if (IS_EXP_EXPR (Type)) {
|
||||||
SkipExpr (F);
|
SkipExpr (F);
|
||||||
@@ -686,10 +760,10 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset)
|
|||||||
if (HaveValue) {
|
if (HaveValue) {
|
||||||
printf (" Value:%15s0x%08lX (%lu)\n", "", Value, Value);
|
printf (" Value:%15s0x%08lX (%lu)\n", "", Value, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the Name */
|
|
||||||
xfree (Name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Destroy the string pool */
|
||||||
|
DestroyStrPool (&StrPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -698,15 +772,18 @@ void DumpObjLineInfo (FILE* F, unsigned long Offset)
|
|||||||
/* Dump the line info from an object file */
|
/* Dump the line info from an object file */
|
||||||
{
|
{
|
||||||
ObjHeader H;
|
ObjHeader H;
|
||||||
|
Collection StrPool = AUTO_COLLECTION_INITIALIZER;
|
||||||
unsigned Count;
|
unsigned Count;
|
||||||
unsigned I;
|
unsigned I;
|
||||||
|
|
||||||
/* Seek to the header position */
|
/* Seek to the header position and read the header */
|
||||||
FileSeek (F, Offset);
|
FileSeek (F, Offset);
|
||||||
|
|
||||||
/* Read the header */
|
|
||||||
ReadObjHeader (F, &H);
|
ReadObjHeader (F, &H);
|
||||||
|
|
||||||
|
/* Seek to the start of the string pool and read it */
|
||||||
|
FileSeek (F, Offset + H.StrPoolOffs);
|
||||||
|
ReadStrPool (F, &StrPool);
|
||||||
|
|
||||||
/* Seek to the start of line infos */
|
/* Seek to the start of line infos */
|
||||||
FileSeek (F, Offset + H.LineInfoOffs);
|
FileSeek (F, Offset + H.LineInfoOffs);
|
||||||
|
|
||||||
@@ -740,6 +817,9 @@ void DumpObjLineInfo (FILE* F, unsigned long Offset)
|
|||||||
printf (" Col:%27u\n", Pos.Col);
|
printf (" Col:%27u\n", Pos.Col);
|
||||||
printf (" Name:%26u\n", Pos.Name);
|
printf (" Name:%26u\n", Pos.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Destroy the string pool */
|
||||||
|
DestroyStrPool (&StrPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -748,14 +828,17 @@ void DumpObjSegSize (FILE* F, unsigned long Offset)
|
|||||||
/* Dump the sizes of the segment in the object file */
|
/* Dump the sizes of the segment in the object file */
|
||||||
{
|
{
|
||||||
ObjHeader H;
|
ObjHeader H;
|
||||||
|
Collection StrPool = AUTO_COLLECTION_INITIALIZER;
|
||||||
unsigned Count;
|
unsigned Count;
|
||||||
|
|
||||||
/* Seek to the header position */
|
/* Seek to the header position and read the header */
|
||||||
FileSeek (F, Offset);
|
FileSeek (F, Offset);
|
||||||
|
|
||||||
/* Read the header */
|
|
||||||
ReadObjHeader (F, &H);
|
ReadObjHeader (F, &H);
|
||||||
|
|
||||||
|
/* Seek to the start of the string pool and read it */
|
||||||
|
FileSeek (F, Offset + H.StrPoolOffs);
|
||||||
|
ReadStrPool (F, &StrPool);
|
||||||
|
|
||||||
/* Seek to the start of the segments */
|
/* Seek to the start of the segments */
|
||||||
FileSeek (F, Offset + H.SegOffs);
|
FileSeek (F, Offset + H.SegOffs);
|
||||||
|
|
||||||
@@ -793,6 +876,9 @@ void DumpObjSegSize (FILE* F, unsigned long Offset)
|
|||||||
Size -= FragSize;
|
Size -= FragSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Destroy the string pool */
|
||||||
|
DestroyStrPool (&StrPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2000 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -211,6 +211,22 @@ void ReadObjHeader (FILE* F, ObjHeader* H)
|
|||||||
H->DbgSymSize = Read32 (F);
|
H->DbgSymSize = Read32 (F);
|
||||||
H->LineInfoOffs = Read32 (F);
|
H->LineInfoOffs = Read32 (F);
|
||||||
H->LineInfoSize = Read32 (F);
|
H->LineInfoSize = Read32 (F);
|
||||||
|
H->StrPoolOffs = Read32 (F);
|
||||||
|
H->StrPoolSize = Read32 (F);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ReadStrPool (FILE* F, Collection* C)
|
||||||
|
/* Read a string pool from the current position into C. */
|
||||||
|
{
|
||||||
|
/* The number of strings is the first item */
|
||||||
|
unsigned long Count = ReadVar (F);
|
||||||
|
|
||||||
|
/* Read all the strings into C */
|
||||||
|
while (Count--) {
|
||||||
|
CollAppend (C, ReadStr (F));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2000 Ullrich von Bassewitz */
|
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* R<EFBFBD>merstrasse 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/* common */
|
/* common */
|
||||||
|
#include "coll.h"
|
||||||
#include "filepos.h"
|
#include "filepos.h"
|
||||||
#include "objdefs.h"
|
#include "objdefs.h"
|
||||||
|
|
||||||
@@ -85,6 +86,9 @@ void* ReadData (FILE* F, void* Data, unsigned Size);
|
|||||||
void ReadObjHeader (FILE* F, ObjHeader* Header);
|
void ReadObjHeader (FILE* F, ObjHeader* Header);
|
||||||
/* Read an object file header from the file */
|
/* Read an object file header from the file */
|
||||||
|
|
||||||
|
void ReadStrPool (FILE* F, Collection* C);
|
||||||
|
/* Read a string pool from the current position into C. */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of fileio.h */
|
/* End of fileio.h */
|
||||||
|
|||||||
Reference in New Issue
Block a user