/* */
/* */
/* */
-/* (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 */
#include "global.h"
#include "error.h"
#include "fileio.h"
+#include "lineinfo.h"
#include "segments.h"
#include "exports.h"
#include "config.h"
* 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);
/* */
/* */
/* */
-/* (C) 1999 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 1999-2001 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* */
/* dbgsyms.c */
/* */
-/* Debug symbol handing for the ld65 linker */
+/* Debug symbol handling for the ld65 linker */
/* */
/* */
/* */
/* */
/* dbgsyms.h */
/* */
-/* Debug symbol handing for the ld65 linker */
+/* Debug symbol handling for the ld65 linker */
/* */
/* */
/* */
-
+
+/*****************************************************************************/
+/* Forwards */
+/*****************************************************************************/
+
+
+
+struct LineInfo;
+struct Section;
+
+
+
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* */
/* */
/* */
-/* (C) 1998 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 1998-2001 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
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 */
/*****************************************************************************/
/* */
-/* global.h */
+/* global.h */
/* */
-/* Global variables for the ld65 linker */
+/* Global variables for the ld65 linker */
/* */
/* */
/* */
-/* (C) 1998 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 1998-2001 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
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 */
/* */
/* */
/* */
-/* (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 */
static void LibReadObjHeader (ObjData* O)
/* Read the header of the object file checking the signature */
{
- O->Header.Magic = Read32 (Lib);
+ O->Header.Magic = Read32 (Lib);
if (O->Header.Magic != OBJ_MAGIC) {
- Error ("Object file `%s' in library `%s' is invalid",
+ Error ("Object file `%s' in library `%s' is invalid",
GetObjFileName (O), LibName);
}
- O->Header.Version = Read16 (Lib);
+ O->Header.Version = Read16 (Lib);
if (O->Header.Version != OBJ_VERSION) {
Error ("Object file `%s' in library `%s' has wrong version",
GetObjFileName (O), LibName);
}
- O->Header.Flags = Read16 (Lib);
- O->Header.OptionOffs = Read32 (Lib);
- O->Header.OptionSize = Read32 (Lib);
- O->Header.FileOffs = Read32 (Lib);
- O->Header.FileSize = Read32 (Lib);
- O->Header.SegOffs = Read32 (Lib);
- O->Header.SegSize = Read32 (Lib);
- O->Header.ImportOffs = Read32 (Lib);
- O->Header.ImportSize = Read32 (Lib);
- O->Header.ExportOffs = Read32 (Lib);
- O->Header.ExportSize = Read32 (Lib);
- O->Header.DbgSymOffs = Read32 (Lib);
- O->Header.DbgSymSize = Read32 (Lib);
+ O->Header.Flags = Read16 (Lib);
+ O->Header.OptionOffs = Read32 (Lib);
+ O->Header.OptionSize = Read32 (Lib);
+ O->Header.FileOffs = Read32 (Lib);
+ O->Header.FileSize = Read32 (Lib);
+ O->Header.SegOffs = Read32 (Lib);
+ O->Header.SegSize = Read32 (Lib);
+ O->Header.ImportOffs = Read32 (Lib);
+ O->Header.ImportSize = Read32 (Lib);
+ O->Header.ExportOffs = Read32 (Lib);
+ 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);
}
for (I = 0; I < O->ExportCount; ++I) {
InsertExport (O->Exports [I]);
}
- /* Insert the imports */
+ /* Insert the imports */
for (I = 0; I < O->ImportCount; ++I) {
InsertImport (O->Imports [I]);
}
do {
Add = 0;
for (I = 0; I < ModuleCount; ++I) {
- ObjData* O = Index [I];
- if ((O->Flags & OBJ_REF) == 0) {
- LibCheckExports (O);
- if (O->Flags & OBJ_REF) {
- /* The routine added the file */
- Add = 1;
- }
- }
- }
+ ObjData* O = Index [I];
+ if ((O->Flags & OBJ_REF) == 0) {
+ LibCheckExports (O);
+ if (O->Flags & OBJ_REF) {
+ /* The routine added the file */
+ Add = 1;
+ }
+ }
+ }
} while (Add);
/* Add the files list and sections for all requested modules */
for (I = 0; I < ModuleCount; ++I) {
- ObjData* O = Index [I];
- if (O->Flags & OBJ_REF) {
+ ObjData* O = Index [I];
+ if (O->Flags & OBJ_REF) {
+
+ /* Seek to the start of the object file and read the header */
+ fseek (Lib, O->Start, SEEK_SET);
+ LibReadObjHeader (O);
- /* Seek to the start of the object file and read the header */
- fseek (Lib, O->Start, SEEK_SET);
- LibReadObjHeader (O);
+ /* Seek to the start of the files list and read the files list */
+ fseek (Lib, O->Start + O->Header.FileOffs, SEEK_SET);
+ ObjReadFiles (Lib, O);
- /* Seek to the start of the files list and read the files list */
- fseek (Lib, O->Start + O->Header.FileOffs, SEEK_SET);
- ObjReadFiles (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 segment list and read the segments */
- fseek (Lib, O->Start + O->Header.SegOffs, SEEK_SET);
- ObjReadSections (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 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 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;
+ O->Flags |= OBJ_HAVEDATA;
- }
+ }
- /* Add a pointer to the library name */
- O->LibName = LibName;
+ /* Add a pointer to the library name */
+ O->LibName = LibName;
}
/* Done. Close the file, release allocated memory */
/* ld65 */
#include "fileio.h"
+#include "fragment.h"
+#include "segments.h"
#include "lineinfo.h"
+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 */
{
LI->File = 0;
InitFilePos (&LI->Pos);
InitCollection (&LI->Fragments);
+ InitCollection (&LI->CodeRanges);
/* Return the new struct */
return LI;
+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;
+ }
+}
+
+
+
/*****************************************************************************/
-/* Data */
+/* 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 */
};
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 */
+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 */
{
/* Program long options */
static const LongOpt OptTab[] = {
{ "--config", 1, OptConfig },
- { "--help", 0, OptHelp },
+ { "--dbgfile", 1, OptDbgFile },
+ { "--help", 0, OptHelp },
{ "--mapfile", 1, OptMapFile },
{ "--start-addr", 1, OptStartAddr },
{ "--target", 1, OptTarget },
}
if (LabelFileName) {
CreateLabelFile ();
+ }
+ if (DbgFileName) {
+ CreateDbgFile ();
}
/* Dump the data for debugging */
binfmt.o \
condes.o \
config.o \
+ dbginfo.o \
dbgsyms.o \
error.o \
exports.o \
scanner.o \
segments.o \
tgtcfg.o
-
+
# -----------------------------------------------------------------------------
# List of all config includes
binfmt.obj \
condes.obj \
config.obj \
+ dbginfo.obj \
dbgsyms.obj \
error.obj \
exports.obj \
FILE binfmt.obj
FILE condes.obj
FILE config.obj
+FILE dbginfo.obj
FILE dbgsyms.obj
FILE error.obj
FILE exports.obj
FILE fileio.obj
FILE fragment.obj
FILE global.obj
-FILE library.obj
+FILE library.obj
FILE lineinfo.obj
FILE main.obj
FILE mapfile.obj
/* */
/* */
/* */
-/* (C) 1998 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 1998-2001 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
#include "error.h"
#include "objdata.h"
#include "segments.h"
+#include "dbginfo.h"
#include "dbgsyms.h"
#include "exports.h"
#include "config.h"
for (I = 0; I < O->SectionCount; ++I) {
const Section* S = O->Sections [I];
/* Don't include zero sized sections if not explicitly
- * requested
+ * requested
*/
if (VerboseMap || S->Size > 0) {
fprintf (F, " %-15s Offs = %06lX Size = %06lX\n",
{
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));
+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));
+ }
+}
+
+
+
/* */
/* */
/* */
-/* (C) 1998 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 1998-2001 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
void CreateLabelFile (void);
/* Create a label file */
+void CreateDbgFile (void);
+/* Create a debug info file */
+
/* End of mapfile.h */
/* */
/* */
/* */
-/* (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 */
#include "expr.h"
#include "fileio.h"
#include "global.h"
+#include "lineinfo.h"
#include "o65.h"
#define O65SEG_TEXT 0x02
#define O65SEG_DATA 0x03
#define O65SEG_BSS 0x04
-#define O65SEG_ZP 0x05
+#define O65SEG_ZP 0x05
/* Relocation type codes for the o65 format */
#define O65RELOC_WORD 0x80
#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 */
};
/* 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 */
/* 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_ {
- O65Header Header; /* File header */
+struct O65Desc {
+ O65Header Header; /* File header */
O65Option* Options; /* List of file options */
ExtSymTab* Exports; /* Table with exported symbols */
ExtSymTab* Imports; /* Table with imported symbols */
- unsigned Undef; /* Count of undefined symbols */
- FILE* F; /* The file we're writing to */
- char* Filename; /* Name of the output file */
+ unsigned Undef; /* Count of undefined symbols */
+ FILE* F; /* The file we're writing to */
+ char* Filename; /* Name of the output file */
O65RelocTab* TextReloc; /* Relocation table for text segment */
O65RelocTab* DataReloc; /* Relocation table for data segment */
- unsigned TextCount; /* Number of segments assigned to .text */
- SegDesc** TextSeg; /* Array of text segments */
- unsigned DataCount; /* Number of segments assigned to .data */
- SegDesc** DataSeg; /* Array of data segments */
- unsigned BssCount; /* Number of segments assigned to .bss */
- SegDesc** BssSeg; /* Array of bss segments */
- unsigned ZPCount; /* Number of segments assigned to .zp */
- SegDesc** ZPSeg; /* Array of zp segments */
+ unsigned TextCount; /* Number of segments assigned to .text */
+ SegDesc** TextSeg; /* Array of text segments */
+ unsigned DataCount; /* Number of segments assigned to .data */
+ SegDesc** DataSeg; /* Array of data segments */
+ unsigned BssCount; /* Number of segments assigned to .bss */
+ SegDesc** BssSeg; /* Array of bss segments */
+ unsigned ZPCount; /* Number of segments assigned to .zp */
+ SegDesc** ZPSeg; /* Array of zp segments */
/* Temporary data for writing segments */
unsigned long SegSize;
O65RelocTab* CurReloc;
- long LastOffs;
+ long LastOffs;
};
/* Structure for parsing expression trees */
-typedef struct ExprDesc_ ExprDesc;
-struct ExprDesc_ {
- O65Desc* D; /* File format descriptor */
- long Val; /* The offset value */
+typedef struct ExprDesc ExprDesc;
+struct ExprDesc {
+ O65Desc* D; /* File format descriptor */
+ long Val; /* The offset value */
int TooComplex; /* Expression too complex */
- Section* SegRef; /* Section referenced if any */
- ExtSym* ExtRef; /* External reference if any */
+ Section* SegRef; /* Section referenced if any */
+ ExtSym* ExtRef; /* External reference if any */
};
/*****************************************************************************/
-/* Helper functions */
+/* Helper functions */
/*****************************************************************************/
/*****************************************************************************/
-/* Option handling */
+/* Option handling */
/*****************************************************************************/
/*****************************************************************************/
-/* Subroutines to write o65 sections */
+/* Subroutines to write o65 sections */
/*****************************************************************************/
static unsigned O65WriteExpr (ExprNode* E, int Signed, unsigned Size,
- unsigned long Offs, void* Data)
+ unsigned long Offs, void* Data)
/* Called from SegWrite for an expression. Evaluate the expression, check the
* range and write the expression value to the file, update the relocation
* table.
break;
case 2:
- RelocType = O65RELOC_WORD;
+ RelocType = O65RELOC_WORD;
break;
case 3:
/* Write this segment */
if (DoWrite) {
+ RelocLineInfo (S->Seg);
SegWrite (D->F, S->Seg, O65WriteExpr, D);
}
-
/* */
/* */
/* */
-/* (C) 1999 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 1999-2001 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* Structure describing the format */
-typedef struct O65Desc_ O65Desc;
+typedef struct O65Desc O65Desc;
/* Option tags */
#define O65OPT_FILENAME 0
/* */
/* */
/* */
-/* (C) 1998 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 1998-2001 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
ObjReadHeader (Obj, &O->Header, Name);
/* Initialize the object module data structure */
- O->Name = xstrdup (GetModule (Name));
- O->Flags = OBJ_HAVEDATA;
+ O->Name = xstrdup (GetModule (Name));
+ O->Flags = OBJ_HAVEDATA;
/* Read the files list from the object file */
fseek (Obj, O->Header.FileOffs, SEEK_SET);
/* */
/* */
/* */
-/* (C) 1998 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 1998-2001 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
#include <stdio.h>
-#include "../common/objdefs.h"
-
+/* common */
+#include "objdefs.h"
+
+/* ld65 */
#include "objdata.h"
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 */
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 */
/* 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;