Browse Source

Improved Linker: take file names from offers section

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7007 8c9fc860-2736-0410-a75d-ab315db34111
felixf 8 years ago
parent
commit
7f62baa338
2 changed files with 12 additions and 7 deletions
  1. 2 2
      source/Release.Tool
  2. 10 5
      source/StaticLinker.Mod

+ 2 - 2
source/Release.Tool

@@ -48,7 +48,7 @@
 #
 #
 # WINAOS generic
 # WINAOS generic
 #	Release.Build WinAosNewObjectFile ~
 #	Release.Build WinAosNewObjectFile ~
-#	StaticLinker.Link --fileFormat=PE32 --fileName=A2.exe --extension=GofW --displacement=401000H --path="../obg/" Runtime Trace Kernel32 Machine Heaps Modules Objects Kernel KernelLog Streams Commands FIles WinFS Clock Dates Reals Strings Diagnostics BitSets StringPool ObjectFile GenericLinker Reflection  GenericLoader  BootConsole ~
+#	StaticLinker.Link --fileFormat=PE32 --fileName=A2.exe --extension=GofW --displacement=401000H --path="../obg/" Runtime Trace Kernel32 Machine Heaps Modules Objects Kernel KernelLog Streams Commands Files WinFS Clock Dates Reals Strings Diagnostics BitSets StringPool ObjectFile GenericLinker Reflection  GenericLoader  BootConsole ~
 #  Do not forget to add the object file path to the path and to add ObjectFileExtension= ".ObfW" to your .ini file in order to configure the loader.
 #  Do not forget to add the object file path to the path and to add ObjectFileExtension= ".ObfW" to your .ini file in order to configure the loader.
 # 
 # 
 #
 #
@@ -61,7 +61,7 @@
 #
 #
 # WINAOS Cooperative
 # WINAOS Cooperative
 #	Release.Build  --path="./" WinAosCooperative ~
 #	Release.Build  --path="./" WinAosCooperative ~
-#	StaticLinker.Link --fileFormat=PE32 --fileName=a2.exe --extension=GofCW --displacement=401000H --path="./" Trace CPU Runtime Counters Kernel32 Processors Queues BaseTypes Timer Activities ExclusiveBlocks Environment Mutexes Interrupts Machine Heaps Modules GarbageCollector Objects Kernel KernelLog Streams Commands FIles WinFS Clock Dates Reals Strings Diagnostics BitSets StringPool ObjectFile GenericLinker Reflection GenericLoader BootConsole ~
+#	StaticLinker.Link --fileFormat=PE32 --fileName=a2.exe --extension=GofCW --displacement=401000H --path="./" Trace CPU Runtime Counters Kernel32 Processors Queues BaseTypes Timer Activities ExclusiveBlocks Environment Mutexes Interrupts Machine Heaps Modules GarbageCollector Objects Kernel KernelLog Streams Commands Files WinFS Clock Dates Reals Strings Diagnostics BitSets StringPool ObjectFile GenericLinker Reflection GenericLoader BootConsole ~
 #	FSTools.CloseFiles A2.exe ~
 #	FSTools.CloseFiles A2.exe ~
 # 
 # 
 # Notes:
 # Notes:

+ 10 - 5
source/StaticLinker.Mod

@@ -183,11 +183,13 @@ PROCEDURE ReadObjectFile*(CONST moduleName, path, extension: ARRAY OF CHAR; link
 VAR fileName: Files.FileName; file: Files.File; reader: Files.Reader; i: LONGINT;
 VAR fileName: Files.FileName; file: Files.File; reader: Files.Reader; i: LONGINT;
 offers, requires: ObjectFile.NameList;name: ARRAY 256 OF CHAR; sn: ObjectFile.SegmentedName;
 offers, requires: ObjectFile.NameList;name: ARRAY 256 OF CHAR; sn: ObjectFile.SegmentedName;
 BEGIN
 BEGIN
-	linker.Information (moduleName, "processing");
 	sn := moduleName;
 	sn := moduleName;
 	IF (moduleList # NIL) & (moduleList.Get(sn) = finished) THEN
 	IF (moduleList # NIL) & (moduleList.Get(sn) = finished) THEN
 		linker.Warning(moduleName, "duplicate");
 		linker.Warning(moduleName, "duplicate");
 		RETURN;
 		RETURN;
+	ELSIF (moduleList # NIL) & (moduleList.Get(sn) = processing) THEN
+		linker.Error(moduleName, "cyclic import");
+		RETURN;
 	END;
 	END;
 	
 	
 	IF path # "" THEN Files.JoinPath (path, moduleName, fileName); ELSE COPY(moduleName,fileName); END;
 	IF path # "" THEN Files.JoinPath (path, moduleName, fileName); ELSE COPY(moduleName,fileName); END;
@@ -204,15 +206,15 @@ BEGIN
 	
 	
 	GenericLinker.OffersRequires(reader, offers, requires);
 	GenericLinker.OffersRequires(reader, offers, requires);
 	reader.SetPos(0);
 	reader.SetPos(0);
-	IF moduleList # NIL THEN
-		moduleList.Put(sn,processing);
+	FOR i := 0 TO LEN(offers)-1 DO
+		moduleList.Put(offers[i],processing);
 	END;
 	END;
 	
 	
 	IF (moduleList # NIL) & (requires # NIL) THEN
 	IF (moduleList # NIL) & (requires # NIL) THEN
 		FOR i := 0 TO LEN(requires)-1 DO
 		FOR i := 0 TO LEN(requires)-1 DO
 			IF moduleList.Get(requires[i]) = NIL THEN 
 			IF moduleList.Get(requires[i]) = NIL THEN 
 				name := requires[i];
 				name := requires[i];
-				TRACE(name);
+				(*linker.Information(name, "auto");*)
 				ReadObjectFile(name,path,extension, linker, moduleList);
 				ReadObjectFile(name,path,extension, linker, moduleList);
 				IF linker.error THEN RETURN END;
 				IF linker.error THEN RETURN END;
 			ELSIF moduleList.Get(requires[i]) = processing THEN
 			ELSIF moduleList.Get(requires[i]) = processing THEN
@@ -223,9 +225,12 @@ BEGIN
 			END;
 			END;
 		END;
 		END;
 	END;
 	END;
+	linker.Information (moduleName, "processing");
 	GenericLinker.Process (reader, linker);
 	GenericLinker.Process (reader, linker);
 	IF moduleList # NIL THEN
 	IF moduleList # NIL THEN
-		moduleList.Put(sn,finished);
+		FOR i := 0 TO LEN(offers)-1 DO
+			moduleList.Put(offers[i],finished);
+		END;
 	END;
 	END;
 	IF reader.res # Files.Ok THEN linker.Error (fileName, "failed to parse"); END;
 	IF reader.res # Files.Ok THEN linker.Error (fileName, "failed to parse"); END;
 END ReadObjectFile;
 END ReadObjectFile;