Przeglądaj źródła

Apply Lionel Patch (and first real commit on this marvelous fork #hehe#)

git-svn-id: file:///var/svn/tigccpp/trunk@1260 9552661e-59e3-4036-b4f2-dbe53926924f
godzil 16 lat temu
rodzic
commit
86981e77b9

Plik diff jest za duży
+ 0 - 0
tigcc/doc/System/Info/ld/symbols.hss


+ 6 - 0
tigcc/doc/System/Info/ld/symbols_ld_link_time_d.hss

@@ -0,0 +1,6 @@
+[Main]
+Title=__ld_link_time_d
+
+[Top]
+This built-in symbol represents the current day when starting the linking
+process. It's written in binary form, not in string form.

+ 6 - 0
tigcc/doc/System/Info/ld/symbols_ld_link_time_m.hss

@@ -0,0 +1,6 @@
+[Main]
+Title=__ld_link_time_m
+
+[Top]
+This built-in symbol represents the current month when starting the linking
+process. It's written in binary form, not in string form.

+ 10 - 0
tigcc/doc/System/Info/ld/symbols_ld_link_time_timestamp.hss

@@ -0,0 +1,10 @@
+[Main]
+Title=__ld_link_time_timestamp
+
+[Top]
+This built-in symbol represents the number of seconds elapsed between
+January 1st 1997 00:00:00 GMT and the beginning of the linking process.
+It's written in binary form, not in string form.<BR><BR>
+This built-in is provided so that Flash OS can define a meaningful value for
+the 0x320 cert field, 0x900 subfield contained in their header, thus mimicking
+AMS and its FlashApps.

+ 6 - 0
tigcc/doc/System/Info/ld/symbols_ld_link_time_y.hss

@@ -0,0 +1,6 @@
+[Main]
+Title=__ld_link_time_y
+
+[Top]
+This built-in symbol represents the current year when starting the linking
+process. It's written in binary form, not in string form.

+ 6 - 0
tigcc/ld-tigcc/data.h

@@ -25,6 +25,8 @@
 #include "lists.h"
 #include "intrface.h"
 
+#include <time.h>
+
 #define MAX_SYM_LEN 255
 
 struct PROGRAM;
@@ -138,6 +140,10 @@ typedef struct PROGRAM {
 #endif /* DATA_VAR_SUPPORT */
 	OPTIMIZE_INFO
 		*OptimizeInfo;    // Optimization settings and results.
+	struct {
+		time_t LinkTime;
+		unsigned short year, month, day;
+	} LinkTime;           // Time info, initialized when linking starts.
 } PROGRAM;
 
 // Section in a Program

+ 37 - 0
tigcc/ld-tigcc/main.c

@@ -39,6 +39,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
+#include <time.h>
 
 #define RESULT_OK             0
 #define RESULT_GENERAL_ERROR  1
@@ -121,6 +122,39 @@ static char CalcTolower(char Lower)
 	return c;
 }
 
+// Fill internal structures with time information
+static void ComputeTimeInformation(PROGRAM *Program)
+{
+	// Get the timestamp.
+	if (time(&Program->LinkTime.LinkTime) != (time_t)-1)
+	{
+		struct tm * broken_down_time;
+
+		broken_down_time = gmtime(&Program->LinkTime.LinkTime);
+		if (broken_down_time != NULL) {
+			// gmtime returns the number of years since 1900.
+			Program->LinkTime.year = broken_down_time->tm_year + 1900;
+			// gmtime returns the month between 0 and 11.
+			Program->LinkTime.month = broken_down_time->tm_mon + 1;
+			Program->LinkTime.day = broken_down_time->tm_mday;
+			// Convert from "seconds since Jan 1, 1970" to "seconds since Jan 1, 1997".
+			// 197x: 8x365 days, 2x366 days (leap years: 1972, 1976) => 315532800 seconds
+			// 198x: 7x365 days, 3x366 days (leap years: 1980, 1984, 1988) => 315619200 seconds
+			// 199x: 5x365 days, 2x366 days (leap years: 1992, 1996) => 220924800 seconds
+			// Total: 852076800 seconds.
+			Program->LinkTime.LinkTime -= (time_t)852076800L;
+			return;
+		}
+	}
+
+	// Failed, so set dummy values.
+	Warning (NULL, "Couldn't get current time, setting dummy values.");
+	Program->LinkTime.LinkTime = (time_t)0,
+	Program->LinkTime.year = 1997,
+	Program->LinkTime.month = 1,
+	Program->LinkTime.day = 1;
+}
+
 int main (int ArgCount, const char **Args)
 {
 	OPTIMIZE_INFO _OptimizeInfo;
@@ -169,6 +203,9 @@ int main (int ArgCount, const char **Args)
 	
 	// Initialize.
 	memset (&Program, 0, sizeof (Program));
+	
+	ComputeTimeInformation(&Program);
+	
 	Program.EntryPoint.SymbolName = "__entry_point";
 #ifdef TARGET_EMBEDDED
 	ErrorFunction = ErrorMessage;

+ 32 - 0
tigcc/ld-tigcc/special.c

@@ -756,6 +756,38 @@ BOOLEAN ResolveSpecialSymbolLocation (SECTION *Section, LOCATION *Location, BOOL
 					HasValue = TRUE;
 				}
 			}
+			else if (SymNameMatches ("link_time_y")) // Preliminary name
+			{
+				if (Program->ResolveAllBuiltins)
+				{
+					NewValue = Program->LinkTime.year;
+					HasValue = TRUE;
+				}
+			}
+			else if (SymNameMatches ("link_time_m")) // Preliminary name
+			{
+				if (Program->ResolveAllBuiltins)
+				{
+					NewValue = Program->LinkTime.month;
+					HasValue = TRUE;
+				}
+			}
+			else if (SymNameMatches ("link_time_d")) // Preliminary name
+			{
+				if (Program->ResolveAllBuiltins)
+				{
+					NewValue = Program->LinkTime.day;
+					HasValue = TRUE;
+				}
+			}
+			else if (SymNameMatches ("link_time_timestamp")) // Preliminary name
+			{
+				if (Program->ResolveAllBuiltins)
+				{
+					NewValue = Program->LinkTime.LinkTime;
+					HasValue = TRUE;
+				}
+			}
 			else if (SymNameMatches ("kernel_flags"))
 			{
 				if (Program->ResolveAllBuiltins)

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików