Explorar o código

Patched issues with EFI boot file generation

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6567 8c9fc860-2736-0410-a75d-ab315db34111
felixf %!s(int64=9) %!d(string=hai) anos
pai
achega
68efa0a0c2
Modificáronse 2 ficheiros con 30 adicións e 2 borrados
  1. 20 0
      source/FoxBinaryObjectFile.Mod
  2. 10 2
      source/FoxIntermediateBackend.Mod

+ 20 - 0
source/FoxBinaryObjectFile.Mod

@@ -425,6 +425,9 @@ TYPE
 				WHILE fixup # NIL DO
 					next := fixup.nextFixup;
 					symbol := module.allSections.FindByName(fixup.symbol.name);
+					IF symbol = NIL THEN
+						symbol := module.importedSections.FindByName(fixup.symbol.name)
+					END;
 					IF symbol # NIL THEN
 						symbol.SetReferenced(TRUE);
 					ELSIF Trace THEN
@@ -739,6 +742,9 @@ TYPE
 					typeDeclaration := type.typeDeclaration; (* must be non-nil *)
 					typeDeclaration.GetName(name);
 					section := symbols.BySymbol(type.typeDeclaration);
+					IF section = NIL THEN 
+						section := importedSymbols.BySymbol(type.typeDeclaration);
+					END;
 					ASSERT(section # NIL);
 					w.RawNum((section.offset )); (* type descriptor section offset *)
 					IF Trace THEN
@@ -1410,6 +1416,9 @@ TYPE
 						IF type.recordScope.ownerModule = importedModule THEN (* type belongs to currently processed module *)
 							IF Trace  THEN D.Str("UseTypeFP:"); D.Str(name); D.Str("?"); D.Ln END;
 							t := symbols.BySymbol(type.typeDeclaration); (* TODO *)
+							IF t = NIL THEN 
+								t := importedSymbols.BySymbol(type.typeDeclaration);
+							END;
 							IF (t # NIL) & (t.referenced) (*(t.fixups # NIL)*) THEN
 								t.referenced := FALSE;
 
@@ -1499,6 +1508,7 @@ TYPE
 						type := typeDeclaration.declaredType;
 						IF type IS SyntaxTree.PointerType THEN type := type(SyntaxTree.PointerType).pointerBase END;
 						sym := symbols.BySymbol(typeDeclaration); (* only if has been used -- contained in module sections: alias *)
+						IF sym = NIL THEN sym := importedSymbols.BySymbol(typeDeclaration) END;
 						IF (sym # NIL) & (sym.referenced) THEN
 							UseEntry(importedModule,typeDeclaration,0,"");
 							UseType(typeDeclaration.declaredType);
@@ -2190,6 +2200,16 @@ TYPE
 				END
 			END;
 
+			(* enter unused types to local sections -- required, otherwise traps *)
+			FOR i := 0 TO module.importedSections.Length() - 1 DO
+				section := module.importedSections.GetSection(i);
+				IF (section.type = Sections.ConstSection) & (section.symbol # NIL) & (section.symbol IS SyntaxTree.TypeDeclaration) THEN
+					IF symbols.BySymbol(section.symbol) = NIL THEN 
+						ASSERT(Enter(section, symbols, symbol))
+					END;
+				END;
+			END;
+
 			IF Trace THEN
 				D.String("imported sections(module) "); D.Ln;
 				module.importedSections.Dump(D.Log); D.Ln;

+ 10 - 2
source/FoxIntermediateBackend.Mod

@@ -5868,7 +5868,11 @@ TYPE
 					IF source = NIL THEN
 						null := 0;
 						GetCodeSectionNameForSymbol(td,name);
-						source := NewSection(module.allSections, Sections.ConstSection, name,td,commentPrintout # NIL);
+						IF (td.scope = NIL) OR (td.scope.ownerModule = module.module) THEN
+							source := NewSection(module.allSections, Sections.ConstSection, name,td,commentPrintout # NIL);
+						ELSE
+							source := NewSection(module.importedSections, Sections.ConstSection, name,td,commentPrintout # NIL);
+						END;
 						IntermediateCode.InitImmediate(op,addressType,0);
 						source(IntermediateCode.Section).Emit(Data(position,op));
 						source.SetReferenced(FALSE)
@@ -12780,7 +12784,11 @@ TYPE
 					ELSE
 						(* data section in intermediate code *)
 						Global.GetSymbolSegmentedName(td,name);
-						tir := IntermediateCode.NewSection(module.allSections, Sections.ConstSection, name,td,implementationVisitor.dump # NIL);
+						IF (td.scope = NIL) OR (td.scope.ownerModule = module.module) THEN
+							tir := IntermediateCode.NewSection(module.allSections, Sections.ConstSection, name,td,implementationVisitor.dump # NIL);
+						ELSE
+							tir := IntermediateCode.NewSection(module.importedSections, Sections.ConstSection, name,td,implementationVisitor.dump # NIL);
+						END;
 						IntermediateCode.InitImmediate(op,IntermediateCode.GetType(module.system, module.system.addressType),0);
 						tir.Emit(Data(-1,op));
 					END;