Removed underlines from structure names.
Moved the fragment type into its own module. git-svn-id: svn://svn.cc65.org/cc65/trunk@430 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -37,8 +37,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "../common/xmalloc.h"
|
/* common */
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
|
/* ld65 */
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
@@ -206,7 +208,7 @@ static int BinUnresolved (const char* Name, void* D)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void BinWriteTarget (BinDesc* D, struct File_* F)
|
void BinWriteTarget (BinDesc* D, struct File* F)
|
||||||
/* Write a binary output file */
|
/* Write a binary output file */
|
||||||
{
|
{
|
||||||
Memory* M;
|
Memory* M;
|
||||||
|
|||||||
@@ -49,52 +49,52 @@
|
|||||||
|
|
||||||
|
|
||||||
/* File list entry */
|
/* File list entry */
|
||||||
typedef struct File_ File;
|
typedef struct File File;
|
||||||
struct File_ {
|
struct File {
|
||||||
File* Next; /* Pointer to next entry in list */
|
File* Next; /* Pointer to next entry in list */
|
||||||
unsigned Flags;
|
unsigned Flags;
|
||||||
unsigned Format; /* Output format */
|
unsigned Format; /* Output format */
|
||||||
struct Memory_* MemList; /* List of memory areas in this file */
|
struct Memory* MemList; /* List of memory areas in this file */
|
||||||
struct Memory_* MemLast; /* Last memory area in this file */
|
struct Memory* MemLast; /* Last memory area in this file */
|
||||||
char Name [1]; /* Name of file */
|
char Name [1]; /* Name of file */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Segment list node. Needed because there are two lists (RUN & LOAD) */
|
/* Segment list node. Needed because there are two lists (RUN & LOAD) */
|
||||||
typedef struct MemListNode_ MemListNode;
|
typedef struct MemListNode MemListNode;
|
||||||
struct MemListNode_ {
|
struct MemListNode {
|
||||||
MemListNode* Next; /* Next entry */
|
MemListNode* Next; /* Next entry */
|
||||||
struct SegDesc_* Seg; /* Segment */
|
struct SegDesc* Seg; /* Segment */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Memory list entry */
|
/* Memory list entry */
|
||||||
typedef struct Memory_ Memory;
|
typedef struct Memory Memory;
|
||||||
struct Memory_ {
|
struct Memory {
|
||||||
Memory* Next; /* Pointer to next entry in list */
|
Memory* Next; /* Pointer to next entry in list */
|
||||||
Memory* FNext; /* Next in file list */
|
Memory* FNext; /* Next in file list */
|
||||||
unsigned Attr; /* Which values are valid? */
|
unsigned Attr; /* Which values are valid? */
|
||||||
unsigned Flags; /* Set of bitmapped flags */
|
unsigned Flags; /* Set of bitmapped flags */
|
||||||
unsigned long Start; /* Start address */
|
unsigned long Start; /* Start address */
|
||||||
unsigned long Size; /* Length of memory section */
|
unsigned long Size; /* Length of memory section */
|
||||||
unsigned long FillLevel; /* Actual fill level of segment */
|
unsigned long FillLevel; /* Actual fill level of segment */
|
||||||
unsigned char FillVal; /* Value used to fill rest of seg */
|
unsigned char FillVal; /* Value used to fill rest of seg */
|
||||||
MemListNode* SegList; /* List of segments for this section */
|
MemListNode* SegList; /* List of segments for this section */
|
||||||
MemListNode* SegLast; /* Last segment in this section */
|
MemListNode* SegLast; /* Last segment in this section */
|
||||||
File* F; /* File that contains the entry */
|
File* F; /* File that contains the entry */
|
||||||
char Name [1]; /* Name of the memory section */
|
char Name [1]; /* Name of the memory section */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Segment descriptor entry */
|
/* Segment descriptor entry */
|
||||||
typedef struct SegDesc_ SegDesc;
|
typedef struct SegDesc SegDesc;
|
||||||
struct SegDesc_ {
|
struct SegDesc {
|
||||||
SegDesc* Next; /* Pointer to next entry in list */
|
SegDesc* Next; /* Pointer to next entry in list */
|
||||||
Segment* Seg; /* Pointer to segment structure */
|
Segment* Seg; /* Pointer to segment structure */
|
||||||
unsigned Attr; /* Attributes for segment */
|
unsigned Attr; /* Attributes for segment */
|
||||||
unsigned Flags; /* Set of bitmapped flags */
|
unsigned Flags; /* Set of bitmapped flags */
|
||||||
Memory* Load; /* Load memory section */
|
Memory* Load; /* Load memory section */
|
||||||
Memory* Run; /* Run memory section */
|
Memory* Run; /* Run memory section */
|
||||||
unsigned long Addr; /* Start address or offset into segment */
|
unsigned long Addr; /* Start address or offset into segment */
|
||||||
unsigned char Align; /* Alignment if given */
|
unsigned char Align; /* Alignment if given */
|
||||||
char Name [1]; /* Copy of name */
|
char Name [1]; /* Copy of name */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Segment list */
|
/* Segment list */
|
||||||
@@ -107,17 +107,17 @@ extern unsigned SegDescCount; /* Number of entries in list */
|
|||||||
#define MF_RO 0x0004 /* Read only memory area */
|
#define MF_RO 0x0004 /* Read only memory area */
|
||||||
|
|
||||||
/* Segment flags */
|
/* Segment flags */
|
||||||
#define SF_RO 0x0001 /* Read only segment */
|
#define SF_RO 0x0001 /* Read only segment */
|
||||||
#define SF_BSS 0x0002 /* Segment is BSS style segment */
|
#define SF_BSS 0x0002 /* Segment is BSS style segment */
|
||||||
#define SF_ZP 0x0004 /* Zeropage segment (o65 only) */
|
#define SF_ZP 0x0004 /* Zeropage segment (o65 only) */
|
||||||
#define SF_WPROT 0x0008 /* Write protected segment */
|
#define SF_WPROT 0x0008 /* Write protected segment */
|
||||||
#define SF_DEFINE 0x0010 /* Define start and size */
|
#define SF_DEFINE 0x0010 /* Define start and size */
|
||||||
#define SF_ALIGN 0x0020 /* Align the segment */
|
#define SF_ALIGN 0x0020 /* Align the segment */
|
||||||
#define SF_OFFSET 0x0040 /* Segment has offset in memory */
|
#define SF_OFFSET 0x0040 /* Segment has offset in memory */
|
||||||
#define SF_START 0x0080 /* Segment has fixed start address */
|
#define SF_START 0x0080 /* Segment has fixed start address */
|
||||||
#define SF_LOAD_AND_RUN 0x1000 /* LOAD and RUN given */
|
#define SF_LOAD_AND_RUN 0x1000 /* LOAD and RUN given */
|
||||||
#define SF_RUN_DEF 0x2000 /* RUN symbols already defined */
|
#define SF_RUN_DEF 0x2000 /* RUN symbols already defined */
|
||||||
#define SF_LOAD_DEF 0x4000 /* LOAD symbols already defined */
|
#define SF_LOAD_DEF 0x4000 /* LOAD symbols already defined */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -145,3 +145,4 @@ void CfgWriteTarget (void);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -56,8 +56,8 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Debug symbol structure */
|
/* Debug symbol structure */
|
||||||
typedef struct DbgSym_ DbgSym;
|
typedef struct DbgSym DbgSym;
|
||||||
struct DbgSym_ {
|
struct DbgSym {
|
||||||
DbgSym* Next; /* Pool linear list link */
|
DbgSym* Next; /* Pool linear list link */
|
||||||
unsigned Flags; /* Generic flags */
|
unsigned Flags; /* Generic flags */
|
||||||
ObjData* Obj; /* Object file that exports the name */
|
ObjData* Obj; /* Object file that exports the name */
|
||||||
@@ -93,3 +93,4 @@ void PrintDbgSymLabels (ObjData* O, FILE* F);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* exports.c */
|
/* exports.c */
|
||||||
/* */
|
/* */
|
||||||
/* Exports handing for the ld65 linker */
|
/* Exports handling for the ld65 linker */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
|
|||||||
@@ -57,29 +57,29 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Import symbol structure */
|
/* Import symbol structure */
|
||||||
typedef struct Import_ Import;
|
typedef struct Import Import;
|
||||||
struct Import_ {
|
struct Import {
|
||||||
Import* Next; /* Single linked list */
|
Import* Next; /* Single linked list */
|
||||||
ObjData* Obj; /* Object file that imports the name */
|
ObjData* Obj; /* Object file that imports the name */
|
||||||
FilePos Pos; /* File position of reference */
|
FilePos Pos; /* File position of reference */
|
||||||
union {
|
union {
|
||||||
struct Export_* Exp; /* Matching export for this import */
|
struct Export* Exp; /* Matching export for this import */
|
||||||
const char* Name; /* Name if not in table */
|
const char* Name; /* Name if not in table */
|
||||||
} V;
|
} V;
|
||||||
unsigned char Type; /* Type of import */
|
unsigned char Type; /* Type of import */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Export symbol structure */
|
/* Export symbol structure */
|
||||||
typedef struct Export_ Export;
|
typedef struct Export Export;
|
||||||
struct Export_ {
|
struct Export {
|
||||||
Export* Next; /* Hash table link */
|
Export* Next; /* Hash table link */
|
||||||
unsigned Flags; /* Generic flags */
|
unsigned Flags; /* Generic flags */
|
||||||
ObjData* Obj; /* Object file that exports the name */
|
ObjData* Obj; /* Object file that exports the name */
|
||||||
unsigned ImpCount; /* How many imports for this symbol? */
|
unsigned ImpCount; /* How many imports for this symbol? */
|
||||||
Import* ImpList; /* List of imports for this symbol */
|
Import* ImpList; /* List of imports for this symbol */
|
||||||
FilePos Pos; /* File position of definition */
|
FilePos Pos; /* File position of definition */
|
||||||
ExprNode* Expr; /* Expression (0 if not def'd) */
|
ExprNode* Expr; /* Expression (0 if not def'd) */
|
||||||
unsigned char Type; /* Type of export */
|
unsigned char Type; /* Type of export */
|
||||||
char* Name; /* Name - dynamically allocated */
|
char* Name; /* Name - dynamically allocated */
|
||||||
|
|||||||
@@ -38,8 +38,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "../common/exprdefs.h"
|
/* common */
|
||||||
|
#include "exprdefs.h"
|
||||||
|
|
||||||
|
/* ld65 */
|
||||||
#include "objdata.h"
|
#include "objdata.h"
|
||||||
#include "exports.h"
|
#include "exports.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|||||||
79
src/ld65/fragment.c
Normal file
79
src/ld65/fragment.c
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* fragment.c */
|
||||||
|
/* */
|
||||||
|
/* Code/data fragment routines */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* (C) 1998-2000 Ullrich von Bassewitz */
|
||||||
|
/* Wacholderweg 14 */
|
||||||
|
/* D-70597 Stuttgart */
|
||||||
|
/* EMail: uz@musoftware.de */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* 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. */
|
||||||
|
/* */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* common */
|
||||||
|
#include "xmalloc.h"
|
||||||
|
|
||||||
|
/* ld65 */
|
||||||
|
#include "segments.h"
|
||||||
|
#include "fragment.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Code */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Fragment* NewFragment (unsigned char Type, unsigned long Size, Section* S)
|
||||||
|
/* Create a new fragment and insert it into the section S */
|
||||||
|
{
|
||||||
|
/* Allocate memory */
|
||||||
|
Fragment* F = xmalloc (sizeof (Fragment) - 1 + Size); /* Portable? */
|
||||||
|
|
||||||
|
/* Initialize the data */
|
||||||
|
F->Next = 0;
|
||||||
|
F->Obj = 0;
|
||||||
|
F->Size = Size;
|
||||||
|
F->Expr = 0;
|
||||||
|
F->Type = Type;
|
||||||
|
|
||||||
|
/* Insert the code fragment into the segment */
|
||||||
|
if (S->FragRoot == 0) {
|
||||||
|
/* First fragment */
|
||||||
|
S->FragRoot = F;
|
||||||
|
} else {
|
||||||
|
S->FragLast->Next = F;
|
||||||
|
}
|
||||||
|
S->FragLast = F;
|
||||||
|
S->Size += Size;
|
||||||
|
|
||||||
|
/* Return the new fragment */
|
||||||
|
return F;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
83
src/ld65/fragment.h
Normal file
83
src/ld65/fragment.h
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* fragment.h */
|
||||||
|
/* */
|
||||||
|
/* Code/data fragment routines */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* (C) 1998-2000 Ullrich von Bassewitz */
|
||||||
|
/* Wacholderweg 14 */
|
||||||
|
/* D-70597 Stuttgart */
|
||||||
|
/* EMail: uz@musoftware.de */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* 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 FRAGMENT_H
|
||||||
|
#define FRAGMENT_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* common */
|
||||||
|
#include "filepos.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Data */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Fragment structure */
|
||||||
|
typedef struct Fragment Fragment;
|
||||||
|
struct Fragment {
|
||||||
|
Fragment* Next; /* Next fragment in list */
|
||||||
|
struct ObjData* Obj; /* Source of fragment */
|
||||||
|
unsigned long Size; /* Size of data/expression */
|
||||||
|
struct ExprNode* Expr; /* Expression if FRAG_EXPR */
|
||||||
|
FilePos Pos; /* File position in source */
|
||||||
|
unsigned char Type; /* Type of fragment */
|
||||||
|
unsigned char LitBuf [1]; /* Dynamically alloc'ed literal buffer */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Code */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Fragment* NewFragment (unsigned char Type, unsigned long Size, struct Section* S);
|
||||||
|
/* Create a new fragment and insert it into the section S */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* End of fragment.h */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -26,6 +26,7 @@ OBJS = bin.o \
|
|||||||
expr.o \
|
expr.o \
|
||||||
extsyms.o \
|
extsyms.o \
|
||||||
fileio.o \
|
fileio.o \
|
||||||
|
fragment.o \
|
||||||
global.o \
|
global.o \
|
||||||
library.o \
|
library.o \
|
||||||
main.o \
|
main.o \
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ OBJS = bin.obj \
|
|||||||
expr.obj \
|
expr.obj \
|
||||||
extsyms.obj \
|
extsyms.obj \
|
||||||
fileio.obj \
|
fileio.obj \
|
||||||
|
fragment.obj \
|
||||||
global.obj \
|
global.obj \
|
||||||
library.obj \
|
library.obj \
|
||||||
main.obj \
|
main.obj \
|
||||||
|
|||||||
@@ -56,24 +56,24 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Internal structure holding object file data */
|
/* Internal structure holding object file data */
|
||||||
typedef struct ObjData_ ObjData;
|
typedef struct ObjData ObjData;
|
||||||
struct ObjData_ {
|
struct ObjData {
|
||||||
ObjData* Next; /* Linked list of all objects */
|
ObjData* Next; /* Linked list of all objects */
|
||||||
char* Name; /* Module name */
|
char* Name; /* Module name */
|
||||||
char* LibName; /* Name of library */
|
char* LibName; /* Name of library */
|
||||||
ObjHeader Header; /* Header of file */
|
ObjHeader Header; /* Header of file */
|
||||||
unsigned long Start; /* Start offset of data in library */
|
unsigned long Start; /* Start offset of data in library */
|
||||||
unsigned Flags;
|
unsigned Flags;
|
||||||
unsigned FileCount; /* Input file count */
|
unsigned FileCount; /* Input file count */
|
||||||
char** Files; /* List of input files */
|
char** Files; /* List of input files */
|
||||||
unsigned SectionCount; /* Count of sections in this object */
|
unsigned SectionCount; /* Count of sections in this object */
|
||||||
struct Section_** Sections; /* List of all sections */
|
struct Section** Sections; /* List of all sections */
|
||||||
unsigned ExportCount; /* Count of exports */
|
unsigned ExportCount; /* Count of exports */
|
||||||
struct Export_** Exports; /* List of all exports */
|
struct Export** Exports; /* List of all exports */
|
||||||
unsigned ImportCount; /* Count of imports */
|
unsigned ImportCount; /* Count of imports */
|
||||||
struct Import_** Imports; /* List of all imports */
|
struct Import** Imports; /* List of all imports */
|
||||||
unsigned DbgSymCount; /* Count of debug symbols */
|
unsigned DbgSymCount; /* Count of debug symbols */
|
||||||
struct DbgSym_** DbgSyms; /* List of debug symbols */
|
struct DbgSym** DbgSyms; /* List of debug symbols */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "expr.h"
|
#include "expr.h"
|
||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
|
#include "fragment.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "segments.h"
|
#include "segments.h"
|
||||||
|
|
||||||
@@ -59,20 +60,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Fragment structure */
|
|
||||||
typedef struct Fragment_ Fragment;
|
|
||||||
struct Fragment_ {
|
|
||||||
Fragment* Next; /* Next fragment in list */
|
|
||||||
ObjData* Obj; /* Source of fragment */
|
|
||||||
unsigned long Size; /* Size of data/expression */
|
|
||||||
ExprNode* Expr; /* Expression if FRAG_EXPR */
|
|
||||||
FilePos Pos; /* File position in source */
|
|
||||||
unsigned char Type; /* Type of fragment */
|
|
||||||
unsigned char LitBuf [1]; /* Dynamically alloc'ed literal buffer */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Hash table */
|
/* Hash table */
|
||||||
#define HASHTAB_SIZE 253
|
#define HASHTAB_SIZE 253
|
||||||
static Segment* HashTab [HASHTAB_SIZE];
|
static Segment* HashTab [HASHTAB_SIZE];
|
||||||
@@ -88,35 +75,6 @@ static Segment* SegRoot = 0; /* List of all segments */
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static Fragment* NewFragment (unsigned char Type, unsigned long Size, Section* S)
|
|
||||||
/* Create a new fragment and insert it into the segment S */
|
|
||||||
{
|
|
||||||
/* Allocate memory */
|
|
||||||
Fragment* F = xmalloc (sizeof (Fragment) - 1 + Size); /* Portable? */
|
|
||||||
|
|
||||||
/* Initialize the data */
|
|
||||||
F->Next = 0;
|
|
||||||
F->Obj = 0;
|
|
||||||
F->Size = Size;
|
|
||||||
F->Expr = 0;
|
|
||||||
F->Type = Type;
|
|
||||||
|
|
||||||
/* Insert the code fragment into the segment */
|
|
||||||
if (S->FragRoot == 0) {
|
|
||||||
/* First fragment */
|
|
||||||
S->FragRoot = F;
|
|
||||||
} else {
|
|
||||||
S->FragLast->Next = F;
|
|
||||||
}
|
|
||||||
S->FragLast = F;
|
|
||||||
S->Size += Size;
|
|
||||||
|
|
||||||
/* Return the new fragment */
|
|
||||||
return F;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static Segment* NewSegment (const char* Name, unsigned char Type)
|
static Segment* NewSegment (const char* Name, unsigned char Type)
|
||||||
/* Create a new segment and initialize it */
|
/* Create a new segment and initialize it */
|
||||||
{
|
{
|
||||||
@@ -413,7 +371,7 @@ void SegDump (void)
|
|||||||
while (Count--) {
|
while (Count--) {
|
||||||
if (I > 75) {
|
if (I > 75) {
|
||||||
printf ("\n ");
|
printf ("\n ");
|
||||||
I = 3;
|
I = 3;
|
||||||
}
|
}
|
||||||
printf (" %02X", *Data++);
|
printf (" %02X", *Data++);
|
||||||
I += 3;
|
I += 3;
|
||||||
@@ -435,7 +393,7 @@ void SegDump (void)
|
|||||||
|
|
||||||
case FRAG_FILL:
|
case FRAG_FILL:
|
||||||
printf (" Empty space (%lu bytes)\n", F->Size);
|
printf (" Empty space (%lu bytes)\n", F->Size);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Internal ("Invalid fragment type: %02X", F->Type);
|
Internal ("Invalid fragment type: %02X", F->Type);
|
||||||
|
|||||||
@@ -40,9 +40,8 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "../common/exprdefs.h"
|
/* common */
|
||||||
|
#include "exprdefs.h"
|
||||||
#include "objdata.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -52,34 +51,32 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Forward for the section structure (a section is a part of a segment) */
|
|
||||||
typedef struct Section_ Section;
|
|
||||||
|
|
||||||
/* Segment structure */
|
/* Segment structure */
|
||||||
typedef struct Segment_ Segment;
|
typedef struct Segment Segment;
|
||||||
struct Segment_ {
|
struct Segment {
|
||||||
Segment* Next; /* Hash list */
|
Segment* Next; /* Hash list */
|
||||||
Segment* List; /* List of all segments */
|
Segment* List; /* List of all segments */
|
||||||
Section* SecRoot; /* Section list */
|
struct Section* SecRoot; /* Section list */
|
||||||
Section* SecLast; /* Pointer to last section */
|
struct Section* SecLast; /* Pointer to last section */
|
||||||
unsigned long PC; /* PC were this segment is located */
|
unsigned long PC; /* PC were this segment is located */
|
||||||
unsigned long Size; /* Size of data so far */
|
unsigned long Size; /* Size of data so far */
|
||||||
ObjData* AlignObj; /* Module that requested the alignment */
|
struct ObjData* AlignObj; /* Module that requested the alignment */
|
||||||
unsigned char Align; /* Alignment needed */
|
unsigned char Align; /* Alignment needed */
|
||||||
unsigned char FillVal; /* Value to use for fill bytes */
|
unsigned char FillVal; /* Value to use for fill bytes */
|
||||||
unsigned char Type; /* Type of segment */
|
unsigned char Type; /* Type of segment */
|
||||||
char Dumped; /* Did we dump this segment? */
|
char Dumped; /* Did we dump this segment? */
|
||||||
char Name [1]; /* Name, dynamically allocated */
|
char Name [1]; /* Name, dynamically allocated */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Section structure (a section is a part of a segment) */
|
/* Section structure (a section is a part of a segment) */
|
||||||
struct Section_ {
|
typedef struct Section Section;
|
||||||
Section* Next; /* List of sections in a segment */
|
struct Section {
|
||||||
Segment* Seg; /* Segment that contains the section */
|
Section* Next; /* List of sections in a segment */
|
||||||
struct Fragment_* FragRoot; /* Fragment list */
|
Segment* Seg; /* Segment that contains the section */
|
||||||
struct Fragment_* FragLast; /* Pointer to last fragment */
|
struct Fragment* FragRoot; /* Fragment list */
|
||||||
|
struct Fragment* FragLast; /* Pointer to last fragment */
|
||||||
unsigned long Offs; /* Offset into the segment */
|
unsigned long Offs; /* Offset into the segment */
|
||||||
unsigned long Size; /* Size of the section */
|
unsigned long Size; /* Size of the section */
|
||||||
unsigned char Align; /* Alignment */
|
unsigned char Align; /* Alignment */
|
||||||
@@ -97,10 +94,10 @@ struct Section_ {
|
|||||||
#define SEG_EXPR_TOO_COMPLEX 2 /* Expression too complex */
|
#define SEG_EXPR_TOO_COMPLEX 2 /* Expression too complex */
|
||||||
|
|
||||||
typedef unsigned (*SegWriteFunc) (ExprNode* E, /* The expression to write */
|
typedef unsigned (*SegWriteFunc) (ExprNode* E, /* The expression to write */
|
||||||
int Signed, /* Signed expression? */
|
int Signed, /* Signed expression? */
|
||||||
unsigned Size, /* Size (=range) */
|
unsigned Size, /* Size (=range) */
|
||||||
unsigned long Offs, /* File offset */
|
unsigned long Offs, /* File offset */
|
||||||
void* Data); /* Callers data */
|
void* Data); /* Callers data */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -110,7 +107,7 @@ typedef unsigned (*SegWriteFunc) (ExprNode* E, /* The expression to write
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Section* ReadSection (FILE* F, ObjData* O);
|
Section* ReadSection (FILE* F, struct ObjData* O);
|
||||||
/* Read a section from a file */
|
/* Read a section from a file */
|
||||||
|
|
||||||
Segment* SegFind (const char* Name);
|
Segment* SegFind (const char* Name);
|
||||||
@@ -150,3 +147,4 @@ void CheckSegments (void);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user