Explorar o código

Patched issues with loader (entry code and exit code sections were not treated correctly)

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7628 8c9fc860-2736-0410-a75d-ab315db34111
felixf %!s(int64=7) %!d(string=hai) anos
pai
achega
be1615c3db

+ 1 - 1
source/Builds.Tool

@@ -43,7 +43,7 @@ SystemTools.FreeDownTo FoxIntermediateBackend ~
 LINUX32G -- 32 bit linux a2 using generic object files
 ================================
 
-	Release.Build -b Linux32G ~
+	Release.Build --path=NewAos/ Linux32G ~
 	
 	## X11 bootconsole ##
 		StaticLinker.Link -p=Linux32G Runtime Trace Glue Unix Machine Heaps Modules Objects Kernel 

+ 3 - 2
source/FoxIntermediateBackend.Mod

@@ -11882,7 +11882,8 @@ TYPE
 				& (symbol.type # Sections.InlineCodeSection)
 			THEN
 			*)
-			IF (symbol = NIL) OR ( (implementationVisitor.backend.cooperative) & (symbol.symbol = NIL) OR (symbol.symbol # NIL) & (symbol.type # Sections.InitCodeSection)
+			IF (symbol = NIL) OR ( (implementationVisitor.backend.cooperative) & (symbol.symbol = NIL) OR (symbol.symbol # NIL) & (symbol.type # Sections.InitCodeSection) & (symbol.type # Sections.EntryCodeSection)
+				& (symbol.type # Sections.ExitCodeSection)
 				& (symbol.type # Sections.InlineCodeSection))
 			THEN
 
@@ -11934,7 +11935,7 @@ TYPE
 
 				FOR s := 0 TO LEN(sections)-1 DO
 					symbol := sections[s];
-					IF (symbol # NIL) & (implementationVisitor.backend.cooperative) & (symbol.symbol = NIL) OR (symbol.symbol # NIL) & (symbol.type # Sections.InitCodeSection) & (symbol.type # Sections.InlineCodeSection) THEN
+					IF (symbol # NIL) & (implementationVisitor.backend.cooperative) & (symbol.symbol = NIL) OR (symbol.symbol # NIL) & (symbol.type # Sections.InitCodeSection) & (symbol.type # Sections.EntryCodeSection) & (symbol.type # Sections.ExitCodeSection) & (symbol.type # Sections.InlineCodeSection) THEN
 						this := sections[s].name;
 						level := 0;
 						WHILE  (this[level] > 0) DO

+ 4 - 2
source/FoxIntermediateLinker.Mod

@@ -202,7 +202,7 @@ TYPE
 			MarkReachabilityOfAll(FALSE);
 			IF LoadModule(filename, TRUE) THEN
 				segmentedName := sectionPrefix; 
-				MarkAsReachableStartingWith(segmentedName, {Sections.InitCodeSection, Sections.BodyCodeSection});
+				MarkAsReachableStartingWith(segmentedName, {Sections.InitCodeSection, Sections.EntryCodeSection, Sections.ExitCodeSection, Sections.BodyCodeSection});
 				
 				RETURN TRUE;
 			ELSE
@@ -962,10 +962,12 @@ TYPE
 	END SectionNameToFileName;
 
 	PROCEDURE GetPriority*(block: Sections.Section): LONGINT;
-	CONST Fixed=0; InitCode=1; BodyCode=2;Code=3; Data=4; Const=5; Empty =6;
+	CONST Fixed=0; EntryCode=1;InitCode=2; ExitCode=3; BodyCode=4;Code=5; Data=6; Const=7; Empty =8;
 	BEGIN
 		IF block.fixed THEN RETURN Fixed END;
+		IF block.type = ObjectFile.EntryCode THEN RETURN EntryCode END;
 		IF block.type = ObjectFile.InitCode THEN RETURN InitCode END;
+		IF block.type = ObjectFile.ExitCode THEN RETURN ExitCode END;
 		IF block.type = ObjectFile.BodyCode THEN RETURN Code END; (* BodyCode does not necessarily have to be in front of code *)
 		IF block.GetSize () = 0 THEN RETURN Empty END;
 		IF block.type = ObjectFile.Code THEN RETURN Code END;

+ 1 - 1
source/FoxSections.Mod

@@ -59,7 +59,7 @@ TYPE
 
 		PROCEDURE IsCode*(): BOOLEAN;
 		BEGIN
-			RETURN type IN {CodeSection, InitCodeSection, BodyCodeSection};
+			RETURN type IN {EntryCodeSection .. CodeSection};
 		END IsCode;
 
 		PROCEDURE SetReferenced*(ref: BOOLEAN);

+ 3 - 1
source/GenericLinker.Mod

@@ -9,6 +9,7 @@ CONST
 	InvalidAddress* = -1 (* MAX (Address) *);
 
 CONST
+	(* priorities -- do not coincide with ObjecFile section types *)
 	Fixed* = 0; (* placed accroding to placement *)
 	EntryCode*= 1; (* must be placed before all other code *)
 	InitCode*=2; 
@@ -19,6 +20,7 @@ CONST
 	Const* = 7; 
 	Empty* = 8; (* must be placed last *)
 	
+	(* refers to priority classes, not to ObjectFile section types *)
 	UseAll *= {Fixed .. Empty};
 	UseInitCode*={Fixed .. ExitCode};
 	UseAllButInitCode*={Fixed, BodyCode..Empty};
@@ -258,7 +260,7 @@ VAR
 		IF ~error THEN block := firstBlock;
 			WHILE (block # firstLinkedBlock) & ~error DO
 				ObjectFile.SegmentedNameToString(block.identifier.name, name);
-				used := (block.type IN usedCategories) OR (linkRoot # "") & Strings.StartsWith(linkRoot,0,name) OR (block.aliases > 0);
+				used := (block.priority IN usedCategories) OR (linkRoot # "") & Strings.StartsWith(linkRoot,0,name) OR (block.aliases > 0);
 				Reference (block, used); block := block.next;
 			END;
 		END;

+ 1 - 1
source/ObjectFile.Mod

@@ -259,7 +259,7 @@ VAR
 
 
 	PROCEDURE IsCode* (type: SectionType): BOOLEAN;
-	BEGIN RETURN (type IN {InitCode, BodyCode, Code})
+	BEGIN RETURN (type IN {EntryCode .. Code})
 	END IsCode;
 
 	PROCEDURE Matches*(CONST this, that: Identifier): BOOLEAN;