changeset 86:033a328a10ae

Checkpoint: object target output
author lost
date Fri, 16 Jan 2009 05:33:40 +0000
parents 918be0c02239
children 41ff4686b46b
files src/lwasm.h src/output.c src/pseudo.c
diffstat 3 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lwasm.h	Fri Jan 16 05:14:49 2009 +0000
+++ b/src/lwasm.h	Fri Jan 16 05:33:40 2009 +0000
@@ -33,6 +33,14 @@
 #define OUTPUT_RAWREL	3	// raw bytes where ORG causes a SEEK in the file
 
 // structure for tracking sections
+typedef struct section_reloc_list_s section_reloc_list_t;
+struct section_reloc_list_s
+{
+	int offset;						// offset into section
+	lwasm_expr_stack_t *expr;		// value definition
+	section_reloc_list_t *next;		// next relocation
+};
+
 #define SECTION_BSS		1	// the section contains no actual code - just uninit vars
 typedef struct sectiontab_s sectiontab_t;
 struct sectiontab_s
@@ -41,9 +49,11 @@
 	int offset;				// current offset in the section
 	int flags;				// section flags
 	sectiontab_t *next;		// next section
+	// the following are used during code output
 	unsigned char *obytes;	// output bytes
 	int oblen;				// how many bytes output so far?
 	int obsize;				// how big is output buffer so far?
+	section_reloc_list_t *rl;	// relocation list
 };
 
 // structure for tracking macros
--- a/src/output.c	Fri Jan 16 05:14:49 2009 +0000
+++ b/src/output.c	Fri Jan 16 05:33:40 2009 +0000
@@ -241,7 +241,15 @@
 			// relocation table
 			if (l -> relocoff >= 0)
 			{
-			
+				section_reloc_list_t *re;
+				
+				// build the relocation reference for the linker
+				re = lwasm_alloc(sizeof(section_reloc_list_t));
+				re -> next = l -> sect -> rl;
+				l -> sect -> rl = re;
+				
+				re -> offset = l -> codeaddr + l -> relocoff;
+				re -> expr = l -> exprs[0];
 			}
 		}
 	}
--- a/src/pseudo.c	Fri Jan 16 05:14:49 2009 +0000
+++ b/src/pseudo.c	Fri Jan 16 05:33:40 2009 +0000
@@ -720,7 +720,7 @@
 		s -> obytes = NULL;
 		s -> oblen = 0;
 		s -> obsize = 0;
-		
+		s -> rl = NULL;
 		// parse options; only one "bss"
 		if (opts && as -> passnum == 1)
 		{