X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fld65%2Fsegments.c;h=0ae19b6d6398e8db36dd3ca5bf96f884cbf96656;hb=3e887bd9dd06b89177bff864b50fc58c8dadc8bf;hp=aa0251c389a2329e8065c2942246fb0366fba04b;hpb=4ea94a9302b8946f452fe14667fa1deaba52bbe7;p=cc65 diff --git a/src/ld65/segments.c b/src/ld65/segments.c index aa0251c38..0ae19b6d6 100644 --- a/src/ld65/segments.c +++ b/src/ld65/segments.c @@ -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 */ @@ -40,6 +40,7 @@ #include "check.h" #include "exprdefs.h" #include "hashstr.h" +#include "print.h" #include "segdefs.h" #include "symdefs.h" #include "xmalloc.h" @@ -50,6 +51,7 @@ #include "fileio.h" #include "fragment.h" #include "global.h" +#include "lineinfo.h" #include "segments.h" @@ -229,10 +231,8 @@ Section* ReadSection (FILE* F, ObjData* O) Type = Read8 (F); /* Print some data */ - if (Verbose > 1) { - printf ("Module `%s': Found segment `%s', size = %lu, align = %u, type = %u\n", - GetObjFileName (O), Name, Size, Align, Type); - } + Print (stdout, 2, "Module `%s': Found segment `%s', size = %lu, align = %u, type = %u\n", + GetObjFileName (O), Name, Size, Align, Type); /* Get the segment for this section */ S = GetSegment (Name, Type, GetObjFileName (O)); @@ -254,6 +254,7 @@ Section* ReadSection (FILE* F, ObjData* O) while (Size) { Fragment* Frag; + unsigned LineInfoIndex; /* Read the fragment type */ unsigned char Type = Read8 (F); @@ -300,13 +301,30 @@ Section* ReadSection (FILE* F, ObjData* O) case FRAG_SEXPR: /* An expression */ Frag->Expr = ReadExpr (F, O); - break; + break; } /* Read the file position of the fragment */ ReadFilePos (F, &Frag->Pos); + /* Read the additional line info and resolve it */ + LineInfoIndex = ReadVar (F); + if (LineInfoIndex) { + --LineInfoIndex; + 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 */ + CollAppend (&Frag->LI->Fragments, Frag); + } + /* Remember the module we had this fragment from */ Frag->Obj = O; @@ -483,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;