Added line infos

git-svn-id: svn://svn.cc65.org/cc65/trunk@748 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2001-05-23 19:03:40 +00:00
parent ea2cf602b0
commit bfbedfa54b
26 changed files with 451 additions and 77 deletions

View File

@@ -47,6 +47,7 @@
#include "error.h"
#include "exports.h"
#include "fileio.h"
#include "lineinfo.h"
#include "objdata.h"
#include "segments.h"
#include "objfile.h"
@@ -86,19 +87,21 @@ static void ObjReadHeader (FILE* Obj, ObjHeader* H, const char* Name)
if (H->Version != OBJ_VERSION) {
Error ("Object file `%s' has wrong version", Name);
}
H->Flags = Read16 (Obj);
H->OptionOffs = Read32 (Obj);
H->OptionSize = Read32 (Obj);
H->FileOffs = Read32 (Obj);
H->FileSize = Read32 (Obj);
H->SegOffs = Read32 (Obj);
H->SegSize = Read32 (Obj);
H->ImportOffs = Read32 (Obj);
H->ImportSize = Read32 (Obj);
H->ExportOffs = Read32 (Obj);
H->ExportSize = Read32 (Obj);
H->DbgSymOffs = Read32 (Obj);
H->DbgSymSize = Read32 (Obj);
H->Flags = Read16 (Obj);
H->OptionOffs = Read32 (Obj);
H->OptionSize = Read32 (Obj);
H->FileOffs = Read32 (Obj);
H->FileSize = Read32 (Obj);
H->SegOffs = Read32 (Obj);
H->SegSize = Read32 (Obj);
H->ImportOffs = Read32 (Obj);
H->ImportSize = Read32 (Obj);
H->ExportOffs = Read32 (Obj);
H->ExportSize = Read32 (Obj);
H->DbgSymOffs = Read32 (Obj);
H->DbgSymSize = Read32 (Obj);
H->LineInfoOffs = Read32 (Obj);
H->LineInfoSize = Read32 (Obj);
}
@@ -155,7 +158,7 @@ void ObjReadDbgSyms (FILE* F, ObjData* O)
/* Read the debug symbols from a file at the current position */
{
unsigned I;
O->DbgSymCount = ReadVar (F);
O->DbgSyms = xmalloc (O->DbgSymCount * sizeof (DbgSym*));
for (I = 0; I < O->DbgSymCount; ++I) {
@@ -165,6 +168,20 @@ void ObjReadDbgSyms (FILE* F, ObjData* O)
void ObjReadLineInfos (FILE* F, ObjData* O)
/* Read the line infos from a file at the current position */
{
unsigned I;
O->LineInfoCount = ReadVar (F);
O->LineInfos = xmalloc (O->LineInfoCount * sizeof (LineInfo*));
for (I = 0; I < O->LineInfoCount; ++I) {
O->LineInfos[I] = ReadLineInfo (F, O);
}
}
void ObjReadSections (FILE* F, ObjData* O)
/* Read the section data from a file at the current position */
{
@@ -211,6 +228,10 @@ void ObjAdd (FILE* Obj, const char* Name)
fseek (Obj, O->Header.DbgSymOffs, SEEK_SET);
ObjReadDbgSyms (Obj, O);
/* Read the line infos from the object file */
fseek (Obj, O->Header.LineInfoOffs, SEEK_SET);
ObjReadLineInfos (Obj, O);
/* Read the segment list from the object file. This must be last, since
* the expressions stored in the code may reference segments or imported
* symbols.