mirror of
https://github.com/cc65/cc65.git
synced 2024-07-07 19:29:18 +00:00
Added dbg file generation
git-svn-id: svn://svn.cc65.org/cc65/trunk@764 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
45242a8e02
commit
3889a2bec9
@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1999-2000 Ullrich von Bassewitz */
|
||||
/* (C) 1999-2001 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
@ -45,6 +45,7 @@
|
||||
#include "global.h"
|
||||
#include "error.h"
|
||||
#include "fileio.h"
|
||||
#include "lineinfo.h"
|
||||
#include "segments.h"
|
||||
#include "exports.h"
|
||||
#include "config.h"
|
||||
@ -186,6 +187,7 @@ static void BinWriteMem (BinDesc* D, Memory* M)
|
||||
* if the memory area is the load area.
|
||||
*/
|
||||
if (DoWrite) {
|
||||
RelocLineInfo (S->Seg);
|
||||
SegWrite (D->F, S->Seg, BinWriteExpr, D);
|
||||
} else if (M->Flags & MF_FILL) {
|
||||
WriteMult (D->F, M->FillVal, S->Seg->Size);
|
||||
|
@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1999 Ullrich von Bassewitz */
|
||||
/* (C) 1999-2001 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* */
|
||||
/* dbgsyms.c */
|
||||
/* */
|
||||
/* Debug symbol handing for the ld65 linker */
|
||||
/* Debug symbol handling for the ld65 linker */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* */
|
||||
/* dbgsyms.h */
|
||||
/* */
|
||||
/* Debug symbol handing for the ld65 linker */
|
||||
/* Debug symbol handling for the ld65 linker */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
|
@ -43,6 +43,17 @@
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Forwards */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
struct LineInfo;
|
||||
struct Section;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998 Ullrich von Bassewitz */
|
||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
@ -50,6 +50,7 @@ unsigned long StartAddr = 0x200; /* Start address */
|
||||
unsigned char VerboseMap = 0; /* Verbose map file */
|
||||
const char* MapFileName = 0; /* Name of the map file */
|
||||
const char* LabelFileName = 0; /* Name of the label file */
|
||||
const char* DbgFileName = 0; /* Name of the debug file */
|
||||
unsigned char WProtSegs = 0; /* Mark write protected segments */
|
||||
|
||||
|
||||
|
@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998 Ullrich von Bassewitz */
|
||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
@ -51,6 +51,7 @@ extern unsigned long StartAddr; /* Start address */
|
||||
extern unsigned char VerboseMap; /* Verbose map file */
|
||||
extern const char* MapFileName; /* Name of the map file */
|
||||
extern const char* LabelFileName; /* Name of the label file */
|
||||
extern const char* DbgFileName; /* Name of the debug file */
|
||||
extern unsigned char WProtSegs; /* Mark write protected segments */
|
||||
|
||||
|
||||
|
@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2000 Ullrich von Bassewitz */
|
||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
@ -101,6 +101,8 @@ static void LibReadObjHeader (ObjData* O)
|
||||
O->Header.ExportSize = Read32 (Lib);
|
||||
O->Header.DbgSymOffs = Read32 (Lib);
|
||||
O->Header.DbgSymSize = Read32 (Lib);
|
||||
O->Header.LineInfoOffs = Read32 (Lib);
|
||||
O->Header.LineInfoSize = Read32 (Lib);
|
||||
}
|
||||
|
||||
|
||||
@ -254,14 +256,21 @@ void LibAdd (FILE* F, const char* Name)
|
||||
fseek (Lib, O->Start + O->Header.FileOffs, SEEK_SET);
|
||||
ObjReadFiles (Lib, O);
|
||||
|
||||
/* Seek to the start of the segment list and read the segments */
|
||||
fseek (Lib, O->Start + O->Header.SegOffs, SEEK_SET);
|
||||
ObjReadSections (Lib, O);
|
||||
|
||||
/* Seek to the start of the debug info and read the debug info */
|
||||
fseek (Lib, O->Start + O->Header.DbgSymOffs, SEEK_SET);
|
||||
ObjReadDbgSyms (Lib, O);
|
||||
|
||||
/* Seek to the start of the line infos and read them */
|
||||
fseek (Lib, O->Start + O->Header.LineInfoOffs, SEEK_SET);
|
||||
ObjReadLineInfos (Lib, O);
|
||||
|
||||
/* Seek to the start of the segment list and read the segments.
|
||||
* This must be last, since the data here may reference other
|
||||
* stuff.
|
||||
*/
|
||||
fseek (Lib, O->Start + O->Header.SegOffs, SEEK_SET);
|
||||
ObjReadSections (Lib, O);
|
||||
|
||||
/* We have the data now */
|
||||
O->Flags |= OBJ_HAVEDATA;
|
||||
|
||||
|
@ -39,6 +39,8 @@
|
||||
|
||||
/* ld65 */
|
||||
#include "fileio.h"
|
||||
#include "fragment.h"
|
||||
#include "segments.h"
|
||||
#include "lineinfo.h"
|
||||
|
||||
|
||||
@ -49,6 +51,22 @@
|
||||
|
||||
|
||||
|
||||
static CodeRange* NewCodeRange (unsigned long Offs, unsigned long Size)
|
||||
/* Create and return a new CodeRange struct */
|
||||
{
|
||||
/* Allocate memory */
|
||||
CodeRange* R = xmalloc (sizeof (CodeRange));
|
||||
|
||||
/* Initialize the fields */
|
||||
R->Offs = Offs;
|
||||
R->Size = Size;
|
||||
|
||||
/* Return the new struct */
|
||||
return R;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static LineInfo* NewLineInfo (void)
|
||||
/* Create and return a new LineInfo struct */
|
||||
{
|
||||
@ -59,6 +77,7 @@ static LineInfo* NewLineInfo (void)
|
||||
LI->File = 0;
|
||||
InitFilePos (&LI->Pos);
|
||||
InitCollection (&LI->Fragments);
|
||||
InitCollection (&LI->CodeRanges);
|
||||
|
||||
/* Return the new struct */
|
||||
return LI;
|
||||
@ -85,3 +104,88 @@ LineInfo* ReadLineInfo (FILE* F, ObjData* O)
|
||||
|
||||
|
||||
|
||||
static void AddCodeRange (LineInfo* LI, unsigned long Offs, unsigned long Size)
|
||||
/* Add a range of code to this line */
|
||||
{
|
||||
unsigned I;
|
||||
|
||||
/* Get a pointer to the collection */
|
||||
Collection* CodeRanges = &LI->CodeRanges;
|
||||
|
||||
/* We will keep the CodeRanges collection sorted by starting offset,
|
||||
* so we have to search for the correct insert position. Since in most
|
||||
* cases, the fragments have increasing order, and there is usually not
|
||||
* more than one or two ranges, we do a linear search.
|
||||
*/
|
||||
for (I = 0; I < CollCount (CodeRanges); ++I) {
|
||||
CodeRange* R = CollAtUnchecked (CodeRanges, I);
|
||||
if (Offs < R->Offs) {
|
||||
|
||||
/* Got the insert position */
|
||||
if (Offs + Size == R->Offs) {
|
||||
/* Merge the two */
|
||||
R->Offs = Offs;
|
||||
R->Size += Size;
|
||||
} else {
|
||||
/* Insert a new entry */
|
||||
CollInsert (CodeRanges, NewCodeRange (Offs, Size), I);
|
||||
}
|
||||
|
||||
/* Done */
|
||||
return;
|
||||
|
||||
} else if (R->Offs + R->Size == Offs) {
|
||||
|
||||
/* This is the regular case. Merge the two. */
|
||||
R->Size += Size;
|
||||
|
||||
/* Done */
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* We must append an entry */
|
||||
CollAppend (CodeRanges, NewCodeRange (Offs, Size));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void RelocLineInfo (struct Segment* S)
|
||||
/* Relocate the line info for a segment. */
|
||||
{
|
||||
unsigned long Offs = 0;
|
||||
|
||||
/* Loop over all sections in this segment */
|
||||
Section* Sec = S->SecRoot;
|
||||
while (Sec) {
|
||||
Fragment* Frag;
|
||||
|
||||
/* Adjust for fill bytes */
|
||||
Offs += Sec->Fill;
|
||||
|
||||
/* Loop over all fragments in this section */
|
||||
Frag = Sec->FragRoot;
|
||||
while (Frag) {
|
||||
|
||||
/* Add the range for this fragment to the line info if there
|
||||
* is any
|
||||
*/
|
||||
if (Frag->LI) {
|
||||
AddCodeRange (Frag->LI, Offs, Frag->Size);
|
||||
}
|
||||
|
||||
/* Update the offset */
|
||||
Offs += Frag->Size;
|
||||
|
||||
/* Next fragment */
|
||||
Frag = Frag->Next;
|
||||
}
|
||||
|
||||
/* Next section */
|
||||
Sec = Sec->Next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -47,17 +47,36 @@
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Forwards */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
struct Segment;
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
typedef struct CodeRange CodeRange;
|
||||
struct CodeRange {
|
||||
unsigned long Offs;
|
||||
unsigned long Size;
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef struct LineInfo LineInfo;
|
||||
struct LineInfo {
|
||||
struct FileInfo* File; /* File struct for this line */
|
||||
FilePos Pos; /* File position */
|
||||
Collection Fragments; /* Fragments for this line */
|
||||
Collection CodeRanges; /* Code ranges for this line */
|
||||
};
|
||||
|
||||
|
||||
@ -71,6 +90,9 @@ struct LineInfo {
|
||||
LineInfo* ReadLineInfo (FILE* F, ObjData* O);
|
||||
/* Read a line info from a file and return it */
|
||||
|
||||
void RelocLineInfo (struct Segment* S);
|
||||
/* Relocate the line info for a segment. */
|
||||
|
||||
|
||||
|
||||
/* End of lineinfo.h */
|
||||
|
@ -226,6 +226,14 @@ static void OptConfig (const char* Opt, const char* Arg)
|
||||
|
||||
|
||||
|
||||
static void OptDbgFile (const char* Opt, const char* Arg)
|
||||
/* Give the name of the debug file */
|
||||
{
|
||||
DbgFileName = Arg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void OptHelp (const char* Opt, const char* Arg)
|
||||
/* Print usage information and exit */
|
||||
{
|
||||
@ -288,6 +296,7 @@ int main (int argc, char* argv [])
|
||||
/* Program long options */
|
||||
static const LongOpt OptTab[] = {
|
||||
{ "--config", 1, OptConfig },
|
||||
{ "--dbgfile", 1, OptDbgFile },
|
||||
{ "--help", 0, OptHelp },
|
||||
{ "--mapfile", 1, OptMapFile },
|
||||
{ "--start-addr", 1, OptStartAddr },
|
||||
@ -425,6 +434,9 @@ int main (int argc, char* argv [])
|
||||
if (LabelFileName) {
|
||||
CreateLabelFile ();
|
||||
}
|
||||
if (DbgFileName) {
|
||||
CreateDbgFile ();
|
||||
}
|
||||
|
||||
/* Dump the data for debugging */
|
||||
if (Verbosity > 1) {
|
||||
|
@ -22,6 +22,7 @@ OBJS = bin.o \
|
||||
binfmt.o \
|
||||
condes.o \
|
||||
config.o \
|
||||
dbginfo.o \
|
||||
dbgsyms.o \
|
||||
error.o \
|
||||
exports.o \
|
||||
|
@ -71,6 +71,7 @@ OBJS = bin.obj \
|
||||
binfmt.obj \
|
||||
condes.obj \
|
||||
config.obj \
|
||||
dbginfo.obj \
|
||||
dbgsyms.obj \
|
||||
error.obj \
|
||||
exports.obj \
|
||||
@ -115,6 +116,7 @@ FILE bin.obj
|
||||
FILE binfmt.obj
|
||||
FILE condes.obj
|
||||
FILE config.obj
|
||||
FILE dbginfo.obj
|
||||
FILE dbgsyms.obj
|
||||
FILE error.obj
|
||||
FILE exports.obj
|
||||
|
@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998 Ullrich von Bassewitz */
|
||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
@ -41,6 +41,7 @@
|
||||
#include "error.h"
|
||||
#include "objdata.h"
|
||||
#include "segments.h"
|
||||
#include "dbginfo.h"
|
||||
#include "dbgsyms.h"
|
||||
#include "exports.h"
|
||||
#include "config.h"
|
||||
@ -124,7 +125,7 @@ void CreateLabelFile (void)
|
||||
{
|
||||
ObjData* O;
|
||||
|
||||
/* Open the map file */
|
||||
/* Open the label file */
|
||||
FILE* F = fopen (LabelFileName, "w");
|
||||
if (F == 0) {
|
||||
Error ("Cannot create label file `%s': %s", LabelFileName, strerror (errno));
|
||||
@ -168,3 +169,33 @@ void CreateLabelFile (void)
|
||||
|
||||
|
||||
|
||||
void CreateDbgFile (void)
|
||||
/* Create a debug info file */
|
||||
{
|
||||
ObjData* O;
|
||||
|
||||
/* Open the debug info file */
|
||||
FILE* F = fopen (DbgFileName, "w");
|
||||
if (F == 0) {
|
||||
Error ("Cannot create label file `%s': %s", DbgFileName, strerror (errno));
|
||||
}
|
||||
|
||||
/* Print line infos from all modules we have linked into the output file */
|
||||
O = ObjRoot;
|
||||
while (O) {
|
||||
if (O->Flags & OBJ_HAVEDATA) {
|
||||
/* We've linked this module */
|
||||
PrintDbgInfo (O, F);
|
||||
|
||||
}
|
||||
O = O->Next;
|
||||
}
|
||||
|
||||
/* Close the file */
|
||||
if (fclose (F) != 0) {
|
||||
Error ("Error closing map file `%s': %s", DbgFileName, strerror (errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998 Ullrich von Bassewitz */
|
||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
@ -54,6 +54,9 @@ void CreateMapFile (void);
|
||||
void CreateLabelFile (void);
|
||||
/* Create a label file */
|
||||
|
||||
void CreateDbgFile (void);
|
||||
/* Create a debug info file */
|
||||
|
||||
|
||||
|
||||
/* End of mapfile.h */
|
||||
|
@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1999-2000 Ullrich von Bassewitz */
|
||||
/* (C) 1999-2001 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
@ -50,6 +50,7 @@
|
||||
#include "expr.h"
|
||||
#include "fileio.h"
|
||||
#include "global.h"
|
||||
#include "lineinfo.h"
|
||||
#include "o65.h"
|
||||
|
||||
|
||||
@ -82,8 +83,8 @@
|
||||
#define O65RELOC_SEG 0xa0
|
||||
|
||||
/* O65 executable file header */
|
||||
typedef struct O65Header_ O65Header;
|
||||
struct O65Header_ {
|
||||
typedef struct O65Header O65Header;
|
||||
struct O65Header {
|
||||
unsigned Version; /* Version number for o65 format */
|
||||
unsigned Mode; /* Mode word */
|
||||
unsigned long TextBase; /* Base address of text segment */
|
||||
@ -98,8 +99,8 @@ struct O65Header_ {
|
||||
};
|
||||
|
||||
/* An o65 option */
|
||||
typedef struct O65Option_ O65Option;
|
||||
struct O65Option_ {
|
||||
typedef struct O65Option O65Option;
|
||||
struct O65Option {
|
||||
O65Option* Next; /* Next in option list */
|
||||
unsigned char Type; /* Type of option */
|
||||
unsigned char Len; /* Data length */
|
||||
@ -108,15 +109,15 @@ struct O65Option_ {
|
||||
|
||||
/* A o65 relocation table */
|
||||
#define RELOC_BLOCKSIZE 4096
|
||||
typedef struct O65RelocTab_ O65RelocTab;
|
||||
struct O65RelocTab_ {
|
||||
typedef struct O65RelocTab O65RelocTab;
|
||||
struct O65RelocTab {
|
||||
unsigned Size; /* Size of the table */
|
||||
unsigned Fill; /* Amount used */
|
||||
unsigned char* Buf; /* Buffer, dynamically allocated */
|
||||
};
|
||||
|
||||
/* Structure describing the format */
|
||||
struct O65Desc_ {
|
||||
struct O65Desc {
|
||||
O65Header Header; /* File header */
|
||||
O65Option* Options; /* List of file options */
|
||||
ExtSymTab* Exports; /* Table with exported symbols */
|
||||
@ -143,8 +144,8 @@ struct O65Desc_ {
|
||||
};
|
||||
|
||||
/* Structure for parsing expression trees */
|
||||
typedef struct ExprDesc_ ExprDesc;
|
||||
struct ExprDesc_ {
|
||||
typedef struct ExprDesc ExprDesc;
|
||||
struct ExprDesc {
|
||||
O65Desc* D; /* File format descriptor */
|
||||
long Val; /* The offset value */
|
||||
int TooComplex; /* Expression too complex */
|
||||
@ -580,6 +581,7 @@ static void O65WriteSeg (O65Desc* D, SegDesc** Seg, unsigned Count, int DoWrite)
|
||||
|
||||
/* Write this segment */
|
||||
if (DoWrite) {
|
||||
RelocLineInfo (S->Seg);
|
||||
SegWrite (D->F, S->Seg, O65WriteExpr, D);
|
||||
}
|
||||
|
||||
@ -1069,4 +1071,3 @@ void O65WriteTarget (O65Desc* D, File* F)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1999 Ullrich von Bassewitz */
|
||||
/* (C) 1999-2001 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
@ -52,7 +52,7 @@
|
||||
|
||||
|
||||
/* Structure describing the format */
|
||||
typedef struct O65Desc_ O65Desc;
|
||||
typedef struct O65Desc O65Desc;
|
||||
|
||||
/* Option tags */
|
||||
#define O65OPT_FILENAME 0
|
||||
|
@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998 Ullrich von Bassewitz */
|
||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
|
@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998 Ullrich von Bassewitz */
|
||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
@ -40,8 +40,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../common/objdefs.h"
|
||||
/* common */
|
||||
#include "objdefs.h"
|
||||
|
||||
/* ld65 */
|
||||
#include "objdata.h"
|
||||
|
||||
|
||||
@ -64,6 +66,9 @@ void ObjReadExports (FILE* F, ObjData* O);
|
||||
void ObjReadDbgSyms (FILE* F, ObjData* O);
|
||||
/* Read the debug symbols from a file at the current position */
|
||||
|
||||
void ObjReadLineInfos (FILE* F, ObjData* O);
|
||||
/* Read the line infos from a file at the current position */
|
||||
|
||||
void ObjReadSections (FILE* F, ObjData* O);
|
||||
/* Read the section data from a file at the current position */
|
||||
|
||||
|
@ -312,7 +312,13 @@ Section* ReadSection (FILE* F, ObjData* O)
|
||||
LineInfoIndex = ReadVar (F);
|
||||
if (LineInfoIndex) {
|
||||
--LineInfoIndex;
|
||||
CHECK (LineInfoIndex < O->LineInfoCount);
|
||||
if (LineInfoIndex >= O->LineInfoCount) {
|
||||
Internal ("In module `%s', file `%s', line %lu: Invalid line "
|
||||
"info with index %u (max count %u)",
|
||||
GetObjFileName (O),
|
||||
GetSourceFileName (O, Frag->Pos.Name),
|
||||
Frag->Pos.Line, LineInfoIndex, O->LineInfoCount);
|
||||
}
|
||||
/* Point from the fragment to the line info... */
|
||||
Frag->LI = O->LineInfos[LineInfoIndex];
|
||||
/* ...and back from the line info to the fragment */
|
||||
@ -495,6 +501,7 @@ void SegWrite (FILE* Tgt, Segment* S, SegWriteFunc F, void* Data)
|
||||
|
||||
/* If we have fill bytes, write them now */
|
||||
WriteMult (Tgt, S->FillVal, Sec->Fill);
|
||||
Offs += Sec->Fill;
|
||||
|
||||
/* Loop over all fragments in this section */
|
||||
Frag = Sec->FragRoot;
|
||||
|
Loading…
Reference in New Issue
Block a user