changeset 88:6460a1fb5f1f

Checkpoint: object format output
author lost
date Sat, 17 Jan 2009 04:37:40 +0000
parents 41ff4686b46b
children 11d38c9e5095
files src/output.c
diffstat 1 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/output.c	Sat Jan 17 02:59:24 2009 +0000
+++ b/src/output.c	Sat Jan 17 04:37:40 2009 +0000
@@ -202,6 +202,8 @@
 {
 	lwasm_line_t *l;
 	sectiontab_t *s;
+	lwasm_symbol_ent_t *se;
+	
 	int i;
 	unsigned char buf[16];
 
@@ -271,6 +273,37 @@
 		writebytes("", 1, 1, of);
 		
 		
+		// now the local symbols
+		for (se = as -> symhead; se; se = se -> next)
+		{
+			// ignore symbols not in this section
+			if (se -> sect != s)
+				continue;
+			
+			if (se -> flags & SYMBOL_SET)
+				continue;
+			
+			if (se -> flags & SYMBOL_EXTERN)
+				continue;
+			
+			writebytes(se -> sym, strlen(se -> sym), 1, of);
+			if (se -> context >= 0)
+			{
+				writebytes("\x01", 1, 1, of);
+				sprintf(buf, "%d", se -> context);
+				writebytes(buf, strlen(buf), 1, of);
+			}
+			// the "" is NOT an error
+			writebytes("", 1, 1, of);
+			
+			// write the address
+			buf[0] = (se -> value >> 8) & 0xff;
+			buf[1] = se -> value & 0xff;
+			writebytes(buf, 2, 1, of);
+		}	
+		// flag end of local symbol table - "" is NOT an error
+		writebytes("", 1, 1, of);
+		
 		// now blast out the code
 		
 		// length