view src/lwlink.h @ 300:48945dac8178

Fixed copyright year
author lost
date Wed, 21 Jan 2009 05:13:36 +0000
parents 460d96987670
children 376cc55361c7
line wrap: on
line source

/*
lwlink.h
Copyright © 2009 William Astle

This file is part of LWLINK.

LWLINK is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.

You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.

Contains the main defs used by the linker
*/


#ifndef __lwlink_h_seen__
#define __lwlink_h_seen__

#include "expr.h"

#define OUTPUT_DECB		0	// DECB multirecord format
#define OUTPUT_RAW		1	// raw sequence of bytes

typedef struct symtab_s symtab_t;
struct symtab_s
{
	unsigned char *sym;		// symbol name
	int offset;				// local offset
	int realval;			// resolved value
	symtab_t *next;			// next symbol
};

typedef struct reloc_s reloc_t;
struct reloc_s
{
	int offset;				// where in the section
	lw_expr_stack_t *expr;	// the expression to calculate it
	reloc_t *next;			// ptr to next relocation
};

#define SECTION_BSS		1
typedef struct
{
	unsigned char *name;	// name of the section
	int flags;				// section flags
	int codesize;			// size of the code
	unsigned char *code;	// pointer to the code
	int loadaddress;		// the actual load address of the section
	
	symtab_t *localsyms;	// local symbol table
	symtab_t *exportedsyms;	// exported symbols table
	
	reloc_t *incompletes;	// table of incomplete references
} section_t;

typedef struct
{
	char *filename;
	unsigned char *filedata;
	long filesize;
	section_t *sections;
	int nsections;
	
} fileinfo_t;



#ifndef __lwlink_c_seen__

extern int debug_level;
extern int outformat;
extern char *outfile;
extern int ninputfiles;
extern fileinfo_t **inputfiles;
extern char *scriptfile;

#define __lwlink_E__ extern
#else
#define __lwlink_E__
#endif // __lwlink_c_seen__

__lwlink_E__ void add_input_file(char *fn);

#undef __lwlink_E__

struct scriptline_s
{
	char *sectname;				// name of section, NULL for wildcard
	int loadat;					// address to load at (or -1)
	int noflags;				// flags to NOT have
	int yesflags;				// flags to HAVE
};

typedef struct
{
	int nlines;					// number of lines in the script
	struct scriptline_s *lines;	// the parsed script lines (section)
	int padsize;				// the size to pad to, -1 for none
} linkscript_t;

#ifndef __script_c_seen__
extern linkscript_t linkscript;
#endif

#endif //__lwlink_h_seen__