changeset 123:6084a3859fb4

Added basic raw output module
author lost
date Thu, 22 Jan 2009 02:14:52 +0000
parents 2ece9adb4e4b
children 4ac96c697ef0
files lwlink/trunk/src/output.c
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lwlink/trunk/src/output.c	Thu Jan 22 02:05:30 2009 +0000
+++ b/lwlink/trunk/src/output.c	Thu Jan 22 02:14:52 2009 +0000
@@ -100,4 +100,23 @@
 
 void do_output_raw(FILE *of)
 {
+	int nskips = 0;		// used to output blanks for BSS inline
+	int sn;
+	
+	for (sn = 0; sn < nsects; sn++)
+	{
+		if (sectlist[sn].ptr -> flags & SECTION_BSS)
+		{
+			// no output for a BSS section
+			nskips += sectlist[sn].ptr -> codesize;
+			continue;
+		}
+		while (nskips > 0)
+		{
+			// the "" is not an error - it turns into a single NUL byte!
+			writebytes("", 1, 1, of);
+			nskips--;
+		}
+		writebytes(sectlist[sn].ptr -> code, 1, sectlist[sn].ptr -> codesize, of);
+	}
 }