Browse Source

Fix emission of calculator builtins when using pucrunch compression.

git-svn-id: file:///var/svn/tigccpp/trunk@1149 9552661e-59e3-4036-b4f2-dbe53926924f
kevinkofler 17 years ago
parent
commit
10410dc6d3

+ 18 - 0
tigcc/ld-tigcc/export/exp_def.c

@@ -38,3 +38,21 @@ BOOLEAN EmitCalcBuiltinValue (const RELOC *Reloc, ProgramCalcs DestCalc, EXP_FIL
 	
 	return FALSE;
 }
+
+#ifdef PUCRUNCH_SUPPORT
+// If the reloc can be resolved to a calculator-dependent builtin value,
+// write the value into the data segment in the buffer which starts at
+// DataStart. This function is only needed with pucrunch compression.
+BOOLEAN EmitCalcBuiltinValueBuf (const RELOC *Reloc, ProgramCalcs DestCalc, I1 *Buffer, SIZE BufferSize, OFFSET DataStart)
+{
+	IMAX Value;
+	
+	if (GetCalcBuiltinValue (Reloc, DestCalc, &Value) && (Reloc->Location >= 0) && (Reloc->Location + Reloc->Size <= BufferSize))
+	{
+		WriteTI (Buffer + DataStart + Reloc->Location, Reloc->Size, Value, FALSE, TRUE);
+		return TRUE;
+	}
+	
+	return FALSE;
+}
+#endif /* PUCRUNCH_SUPPORT */

+ 7 - 0
tigcc/ld-tigcc/export/exp_def.h

@@ -79,4 +79,11 @@ typedef BOOLEAN (*EXPORT_FILE_FUNCTION) (const PROGRAM *Program, EXP_FILE *File,
 // DataStart.
 BOOLEAN EmitCalcBuiltinValue (const RELOC *Reloc, ProgramCalcs DestCalc, EXP_FILE *File, SIZE FileSize, OFFSET DataStart);
 
+#ifdef PUCRUNCH_SUPPORT
+// If the reloc can be resolved to a calculator-dependent builtin value,
+// write the value into the data segment in the buffer which starts at
+// DataStart. This function is only needed with pucrunch compression.
+BOOLEAN EmitCalcBuiltinValueBuf (const RELOC *Reloc, ProgramCalcs DestCalc, I1 *Buffer, SIZE BufferSize, OFFSET DataStart);
+#endif /* PUCRUNCH_SUPPORT */
+
 #endif

+ 1 - 1
tigcc/ld-tigcc/export/exp_tios.c

@@ -235,7 +235,7 @@ BOOLEAN ExportPackedTIOSFile (const PROGRAM *Program, EXP_FILE *File, SIZE FileS
 			
 			// If this can be resolved to a calculator-dependent value, write the
 			// value into the section data.
-			if (EmitCalcBuiltinValue (Reloc, DestCalc, File, FileSize, DataStart))
+			if (EmitCalcBuiltinValueBuf (Reloc, DestCalc, Buffer, FileSize, DataStart))
 				continue;
 			
 			// We can only emit relocs with a target symbol in the same section.