diff lwlink/lwlink.h @ 139:106c2fe3c9d9

repo reorg
author lost
date Wed, 28 Jan 2009 05:59:14 +0000
parents lwlink-old/trunk/src/lwlink.h@050864a47b38
children d610b8aef91b
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lwlink/lwlink.h	Wed Jan 28 05:59:14 2009 +0000
@@ -0,0 +1,130 @@
+/*
+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
+};
+
+typedef struct fileinfo_s fileinfo_t;
+
+#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
+	int processed;			// was the section processed yet?
+		
+	symtab_t *localsyms;	// local symbol table
+	symtab_t *exportedsyms;	// exported symbols table
+	
+	reloc_t *incompletes;	// table of incomplete references
+	
+	fileinfo_t *file;		// the file we are in
+} section_t;
+
+struct fileinfo_s
+{
+	char *filename;
+	unsigned char *filedata;
+	long filesize;
+	section_t *sections;
+	int nsections;
+	
+};
+
+struct section_list
+{
+	section_t *ptr;		// ptr to section structure
+	int forceaddr;		// was this force to an address by the link script?
+};
+
+#ifndef __link_c_seen__
+extern struct section_list *sectlist;
+extern int nsects;
+#endif
+
+
+#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
+	char *execsym;				// entry point symbol
+	int execaddr;				// execution address (entry point)
+} linkscript_t;
+
+#ifndef __script_c_seen__
+extern linkscript_t linkscript;
+#endif
+
+#endif //__lwlink_h_seen__