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:
@@ -1603,7 +1603,7 @@ void WriteExpr (ExprNode* Expr)
|
||||
case EXPR_SYMBOL:
|
||||
/* Maybe we should use a code here? */
|
||||
CHECK (SymIsImport (Expr->V.Sym)); /* Safety */
|
||||
ObjWrite16 (GetSymIndex (Expr->V.Sym));
|
||||
ObjWriteVar (GetSymIndex (Expr->V.Sym));
|
||||
break;
|
||||
|
||||
case EXPR_SECTION:
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2002 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* R<EFBFBD>merstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* 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 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 */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* R<EFBFBD>merstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* 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 PCAssignment; /* Allow "* = $XXX" or "$ = $XXX" */
|
||||
|
||||
/* Misc stuff */
|
||||
extern const char Copyright[]; /* Copyright string */
|
||||
|
||||
|
||||
|
||||
/* End of global.h */
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* (C) 2000-2003 Ullrich von Bassewitz */
|
||||
/* R<EFBFBD>merstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* 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 */
|
||||
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"
|
||||
"Current file: %s\n"
|
||||
"\n",
|
||||
VER_MAJOR, VER_MINOR, VER_PATCH,
|
||||
Copyright,
|
||||
InFile,
|
||||
GetFileName (L->File));
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2002 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* R<EFBFBD>merstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
@@ -65,6 +65,7 @@
|
||||
#include "options.h"
|
||||
#include "pseudo.h"
|
||||
#include "scanner.h"
|
||||
#include "spool.h"
|
||||
#include "symtab.h"
|
||||
#include "ulabel.h"
|
||||
|
||||
@@ -320,8 +321,8 @@ static void OptVersion (const char* Opt attribute ((unused)),
|
||||
/* Print the assembler version */
|
||||
{
|
||||
fprintf (stderr,
|
||||
"ca65 V%u.%u.%u - (C) Copyright 1998-2000 Ullrich von Bassewitz\n",
|
||||
VER_MAJOR, VER_MINOR, VER_PATCH);
|
||||
"ca65 V%u.%u.%u - %s\n",
|
||||
VER_MAJOR, VER_MINOR, VER_PATCH, Copyright);
|
||||
}
|
||||
|
||||
|
||||
@@ -480,6 +481,9 @@ static void CreateObjFile (void)
|
||||
/* Write line infos if requested */
|
||||
WriteLineInfo ();
|
||||
|
||||
/* Write the string pool */
|
||||
WriteStrPool ();
|
||||
|
||||
/* Write an updated header and close the file */
|
||||
ObjClose ();
|
||||
}
|
||||
@@ -610,7 +614,7 @@ int main (int argc, char* argv [])
|
||||
}
|
||||
|
||||
/* If no CPU given, use the default CPU for the target */
|
||||
if (GetCPU () == CPU_UNKNOWN) {
|
||||
if (GetCPU () == CPU_UNKNOWN) {
|
||||
if (Target != TGT_UNKNOWN) {
|
||||
SetCPU (DefaultCPU[Target]);
|
||||
} else {
|
||||
|
||||
@@ -34,6 +34,7 @@ OBJS = condasm.o \
|
||||
pseudo.o \
|
||||
repeat.o \
|
||||
scanner.o \
|
||||
spool.o \
|
||||
symtab.o \
|
||||
toklist.o \
|
||||
ulabel.o
|
||||
|
||||
@@ -67,6 +67,7 @@ OBJS = condasm.obj \
|
||||
pseudo.obj \
|
||||
repeat.obj \
|
||||
scanner.obj \
|
||||
spool.obj \
|
||||
symtab.obj \
|
||||
toklist.obj \
|
||||
ulabel.obj
|
||||
|
||||
@@ -578,7 +578,6 @@ static Fragment* NewFragment (unsigned char Type, unsigned short Len)
|
||||
void Emit0 (unsigned char OPC)
|
||||
/* 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);
|
||||
F->V.Data [0] = OPC;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2001 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* R<EFBFBD>merstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
@@ -63,9 +63,25 @@ static FILE* F = 0;
|
||||
|
||||
/* Header structure */
|
||||
static ObjHeader Header = {
|
||||
OBJ_MAGIC,
|
||||
OBJ_VERSION,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
OBJ_MAGIC, /* 32: Magic number */
|
||||
OBJ_VERSION, /* 16: Version number */
|
||||
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.LineInfoOffs);
|
||||
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 */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* (C) 1998-2003 Ullrich von Bassewitz */
|
||||
/* R<EFBFBD>merstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
@@ -121,10 +121,16 @@ void ObjStartLineInfos (void);
|
||||
void ObjEndLineInfos (void);
|
||||
/* 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 */
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
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 "objfile.h"
|
||||
#include "scanner.h"
|
||||
#include "spool.h"
|
||||
#include "symtab.h"
|
||||
|
||||
|
||||
@@ -1137,7 +1138,7 @@ void WriteImports (void)
|
||||
} else {
|
||||
ObjWrite8 (IMP_ABS);
|
||||
}
|
||||
ObjWriteStr (S->Name);
|
||||
ObjWriteVar (GetStringId (S->Name));
|
||||
ObjWritePos (&S->Pos);
|
||||
}
|
||||
S = S->List;
|
||||
@@ -1214,7 +1215,7 @@ void WriteExports (void)
|
||||
}
|
||||
|
||||
/* Write the name */
|
||||
ObjWriteStr (S->Name);
|
||||
ObjWriteVar (GetStringId (S->Name));
|
||||
|
||||
/* Write the value */
|
||||
if ((ExprMask & EXP_MASK_VAL) == EXP_CONST) {
|
||||
@@ -1278,7 +1279,7 @@ void WriteDbgSyms (void)
|
||||
ObjWrite8 (ExprMask);
|
||||
|
||||
/* Write the name */
|
||||
ObjWriteStr (S->Name);
|
||||
ObjWriteVar (GetStringId (S->Name));
|
||||
|
||||
/* Write the value */
|
||||
if ((ExprMask & EXP_MASK_VAL) == EXP_CONST) {
|
||||
|
||||
Reference in New Issue
Block a user