diff options
author | Gaius Mulley <gaiusmod2@gmail.com> | 2023-01-17 15:39:59 +0000 |
---|---|---|
committer | Gaius Mulley <gaiusmod2@gmail.com> | 2023-01-17 15:39:59 +0000 |
commit | 1fce7d29ebb47c805ad4d38b68e00f7b1178f467 (patch) | |
tree | d72185346f3c72670fb1a3ade5400ea42d82cdf7 /gcc/m2 | |
parent | d74d84c623ea8ae394b28c26e6a9a946ff126c31 (diff) | |
download | gcc-1fce7d29ebb47c805ad4d38b68e00f7b1178f467.zip gcc-1fce7d29ebb47c805ad4d38b68e00f7b1178f467.tar.gz gcc-1fce7d29ebb47c805ad4d38b68e00f7b1178f467.tar.bz2 |
Obfuscate the copyright text in gcc/m2/mc/mcOptions.mod
Obfuscate the copyright text in gcc/m2/mc/mcOptions.mod so that the
year change script does not attempt to modify the text. The year
is determined at runtime and therefore the text requires
no modification. The middle printf (C) can be replaced by
a unicode character in the future.
gcc/m2/ChangeLog:
* mc-boot/GM2RTS.c: Rebuilt.
* mc-boot/GM2RTS.h: Rebuilt.
* mc-boot/Gdecl.c: Rebuilt.
* mc-boot/GmcOptions.c: Rebuilt.
* mc/mcOptions.mod (displayVersion):
Split first printf into three components
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diffstat (limited to 'gcc/m2')
-rw-r--r-- | gcc/m2/mc-boot/GM2RTS.c | 121 | ||||
-rw-r--r-- | gcc/m2/mc-boot/GM2RTS.h | 15 | ||||
-rw-r--r-- | gcc/m2/mc-boot/Gdecl.c | 25 | ||||
-rw-r--r-- | gcc/m2/mc-boot/GmcOptions.c | 5 | ||||
-rw-r--r-- | gcc/m2/mc/mcOptions.mod | 5 |
5 files changed, 131 insertions, 40 deletions
diff --git a/gcc/m2/mc-boot/GM2RTS.c b/gcc/m2/mc-boot/GM2RTS.c index 590656e..1b08741 100644 --- a/gcc/m2/mc-boot/GM2RTS.c +++ b/gcc/m2/mc-boot/GM2RTS.c @@ -61,6 +61,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see typedef struct M2RTS_ArgCVEnvP_p M2RTS_ArgCVEnvP; +# define stderrFd 2 typedef struct M2RTS_ProcedureList_r M2RTS_ProcedureList; typedef char *M2RTS_PtrToChar; @@ -175,10 +176,19 @@ extern "C" void M2RTS_HALT (int exitcode) __attribute__ ((noreturn)); /* Halt - provides a more user friendly version of HALT, which takes - four parameters to aid debugging. + four parameters to aid debugging. It writes an error message + to stderr and calls exit (1). */ -extern "C" void M2RTS_Halt (const char *file_, unsigned int _file_high, unsigned int line, const char *function_, unsigned int _function_high, const char *description_, unsigned int _description_high) __attribute__ ((noreturn)); +extern "C" void M2RTS_Halt (const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high, const char *description_, unsigned int _description_high) __attribute__ ((noreturn)); + +/* + HaltC - provides a more user friendly version of HALT, which takes + four parameters to aid debugging. It writes an error message + to stderr and calls exit (1). +*/ + +extern "C" void M2RTS_HaltC (void * filename, unsigned int line, void * function, void * description); /* ExitOnHalt - if HALT is executed then call exit with the exit code, e. @@ -190,7 +200,7 @@ extern "C" void M2RTS_ExitOnHalt (int e); ErrorMessage - emits an error message to stderr and then calls exit (1). */ -extern "C" void M2RTS_ErrorMessage (const char *message_, unsigned int _message_high, const char *file_, unsigned int _file_high, unsigned int line, const char *function_, unsigned int _function_high) __attribute__ ((noreturn)); +extern "C" void M2RTS_ErrorMessage (const char *message_, unsigned int _message_high, const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high) __attribute__ ((noreturn)); /* Length - returns the length of a string, a. This is called whenever @@ -246,6 +256,18 @@ static unsigned int AppendProc (M2RTS_ProcedureList *proclist, PROC proc); static void ErrorString (const char *a_, unsigned int _a_high); /* + ErrorStringC - writes a string to stderr. +*/ + +static void ErrorStringC (void * str); + +/* + ErrorMessageC - emits an error message to stderr and then calls exit (1). +*/ + +static void ErrorMessageC (void * message, void * filename, unsigned int line, void * function) __attribute__ ((noreturn)); + +/* InitProcList - initialize the head and tail pointers to NIL. */ @@ -319,7 +341,49 @@ static void ErrorString (const char *a_, unsigned int _a_high) /* make a local copy of each unbounded array. */ memcpy (a, a_, _a_high+1); - n = static_cast<int> (libc_write (2, &a, static_cast<size_t> (StrLib_StrLen ((const char *) a, _a_high)))); + n = static_cast<int> (libc_write (stderrFd, &a, static_cast<size_t> (StrLib_StrLen ((const char *) a, _a_high)))); +} + + +/* + ErrorStringC - writes a string to stderr. +*/ + +static void ErrorStringC (void * str) +{ + int len; + + len = static_cast<int> (libc_write (stderrFd, str, libc_strlen (str))); +} + + +/* + ErrorMessageC - emits an error message to stderr and then calls exit (1). +*/ + +static void ErrorMessageC (void * message, void * filename, unsigned int line, void * function) +{ + typedef struct ErrorMessageC__T2_a ErrorMessageC__T2; + + struct ErrorMessageC__T2_a { char array[10+1]; }; + ErrorMessageC__T2 buffer; + + ErrorStringC (filename); + ErrorString ((const char *) ":", 1); + NumberIO_CardToStr (line, 0, (char *) &buffer.array[0], 10); + ErrorString ((const char *) &buffer.array[0], 10); + ErrorString ((const char *) ":", 1); + if ((libc_strlen (function)) > 0) + { + ErrorString ((const char *) "in ", 3); + ErrorStringC (function); + ErrorString ((const char *) " has caused ", 12); + } + ErrorStringC (message); + buffer.array[0] = ASCII_nl; + buffer.array[1] = ASCII_nul; + ErrorString ((const char *) &buffer.array[0], 10); + libc_exit (1); } @@ -516,23 +580,34 @@ extern "C" void M2RTS_HALT (int exitcode) /* Halt - provides a more user friendly version of HALT, which takes - four parameters to aid debugging. + four parameters to aid debugging. It writes an error message + to stderr and calls exit (1). */ -extern "C" void M2RTS_Halt (const char *file_, unsigned int _file_high, unsigned int line, const char *function_, unsigned int _function_high, const char *description_, unsigned int _description_high) +extern "C" void M2RTS_Halt (const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high, const char *description_, unsigned int _description_high) { - char file[_file_high+1]; + char filename[_filename_high+1]; char function[_function_high+1]; char description[_description_high+1]; /* make a local copy of each unbounded array. */ - memcpy (file, file_, _file_high+1); + memcpy (filename, filename_, _filename_high+1); memcpy (function, function_, _function_high+1); memcpy (description, description_, _description_high+1); - M2RTS_ErrorMessage ((const char *) description, _description_high, (const char *) file, _file_high, line, (const char *) function, _function_high); - M2RTS_HALT (-1); - __builtin_unreachable (); + M2RTS_ErrorMessage ((const char *) description, _description_high, (const char *) filename, _filename_high, line, (const char *) function, _function_high); +} + + +/* + HaltC - provides a more user friendly version of HALT, which takes + four parameters to aid debugging. It writes an error message + to stderr and calls exit (1). +*/ + +extern "C" void M2RTS_HaltC (void * filename, unsigned int line, void * function, void * description) +{ + ErrorMessageC (description, filename, line, function); } @@ -551,25 +626,25 @@ extern "C" void M2RTS_ExitOnHalt (int e) ErrorMessage - emits an error message to stderr and then calls exit (1). */ -extern "C" void M2RTS_ErrorMessage (const char *message_, unsigned int _message_high, const char *file_, unsigned int _file_high, unsigned int line, const char *function_, unsigned int _function_high) +extern "C" void M2RTS_ErrorMessage (const char *message_, unsigned int _message_high, const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high) { - typedef struct ErrorMessage__T2_a ErrorMessage__T2; + typedef struct ErrorMessage__T3_a ErrorMessage__T3; - struct ErrorMessage__T2_a { char array[10+1]; }; - ErrorMessage__T2 LineNo; + struct ErrorMessage__T3_a { char array[10+1]; }; + ErrorMessage__T3 buffer; char message[_message_high+1]; - char file[_file_high+1]; + char filename[_filename_high+1]; char function[_function_high+1]; /* make a local copy of each unbounded array. */ memcpy (message, message_, _message_high+1); - memcpy (file, file_, _file_high+1); + memcpy (filename, filename_, _filename_high+1); memcpy (function, function_, _function_high+1); - ErrorString ((const char *) file, _file_high); + ErrorString ((const char *) filename, _filename_high); ErrorString ((const char *) ":", 1); - NumberIO_CardToStr (line, 0, (char *) &LineNo.array[0], 10); - ErrorString ((const char *) &LineNo.array[0], 10); + NumberIO_CardToStr (line, 0, (char *) &buffer.array[0], 10); + ErrorString ((const char *) &buffer.array[0], 10); ErrorString ((const char *) ":", 1); if (! (StrLib_StrEqual ((const char *) function, _function_high, (const char *) "", 0))) { @@ -578,9 +653,9 @@ extern "C" void M2RTS_ErrorMessage (const char *message_, unsigned int _message_ ErrorString ((const char *) " has caused ", 12); } ErrorString ((const char *) message, _message_high); - LineNo.array[0] = ASCII_nl; - LineNo.array[1] = ASCII_nul; - ErrorString ((const char *) &LineNo.array[0], 10); + buffer.array[0] = ASCII_nl; + buffer.array[1] = ASCII_nul; + ErrorString ((const char *) &buffer.array[0], 10); libc_exit (1); } diff --git a/gcc/m2/mc-boot/GM2RTS.h b/gcc/m2/mc-boot/GM2RTS.h index 698f142..5db589e 100644 --- a/gcc/m2/mc-boot/GM2RTS.h +++ b/gcc/m2/mc-boot/GM2RTS.h @@ -126,10 +126,19 @@ EXTERN void M2RTS_HALT (int exitcode) __attribute__ ((noreturn)); /* Halt - provides a more user friendly version of HALT, which takes - four parameters to aid debugging. + four parameters to aid debugging. It writes an error message + to stderr and calls exit (1). */ -EXTERN void M2RTS_Halt (const char *file_, unsigned int _file_high, unsigned int line, const char *function_, unsigned int _function_high, const char *description_, unsigned int _description_high) __attribute__ ((noreturn)); +EXTERN void M2RTS_Halt (const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high, const char *description_, unsigned int _description_high) __attribute__ ((noreturn)); + +/* + HaltC - provides a more user friendly version of HALT, which takes + four parameters to aid debugging. It writes an error message + to stderr and calls exit (1). +*/ + +EXTERN void M2RTS_HaltC (void * filename, unsigned int line, void * function, void * description); /* ExitOnHalt - if HALT is executed then call exit with the exit code, e. @@ -141,7 +150,7 @@ EXTERN void M2RTS_ExitOnHalt (int e); ErrorMessage - emits an error message to stderr and then calls exit (1). */ -EXTERN void M2RTS_ErrorMessage (const char *message_, unsigned int _message_high, const char *file_, unsigned int _file_high, unsigned int line, const char *function_, unsigned int _function_high) __attribute__ ((noreturn)); +EXTERN void M2RTS_ErrorMessage (const char *message_, unsigned int _message_high, const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high) __attribute__ ((noreturn)); /* Length - returns the length of a string, a. This is called whenever diff --git a/gcc/m2/mc-boot/Gdecl.c b/gcc/m2/mc-boot/Gdecl.c index 5a92e9a..6511cbb 100644 --- a/gcc/m2/mc-boot/Gdecl.c +++ b/gcc/m2/mc-boot/Gdecl.c @@ -293,16 +293,16 @@ typedef enum {mcComment_unknown, mcComment_procedureHeading, mcComment_inBody, m typedef struct DynamicStrings_stringRecord_r DynamicStrings_stringRecord; -typedef struct wlists__T9_r wlists__T9; - typedef struct DynamicStrings_Contents_r DynamicStrings_Contents; -typedef struct DynamicStrings__T7_a DynamicStrings__T7; +typedef struct wlists__T9_r wlists__T9; typedef struct mcPretty__T12_r mcPretty__T12; typedef struct wlists__T10_a wlists__T10; +typedef struct DynamicStrings__T7_a DynamicStrings__T7; + typedef Indexing__T5 *Indexing_Index; typedef mcComment__T6 *mcComment_commentDesc; @@ -665,8 +665,8 @@ struct mcComment__T6_r { unsigned int used; }; -struct DynamicStrings__T7_a { char array[(MaxBuf-1)+1]; }; struct wlists__T10_a { unsigned int array[maxNoOfElements-1+1]; }; +struct DynamicStrings__T7_a { char array[(MaxBuf-1)+1]; }; struct alists__T13_r { unsigned int noOfelements; alists__T14 elements; @@ -830,18 +830,18 @@ struct decl_impT_r { decl_commentPair com; }; -struct wlists__T9_r { - unsigned int noOfElements; - wlists__T10 elements; - wlists_wlist next; - }; - struct DynamicStrings_Contents_r { DynamicStrings__T7 buf; unsigned int len; DynamicStrings_String next; }; +struct wlists__T9_r { + unsigned int noOfElements; + wlists__T10 elements; + wlists_wlist next; + }; + struct mcPretty__T12_r { mcPretty_writeProc write_; mcPretty_writeLnProc writeln; @@ -1037,9 +1037,10 @@ extern "C" unsigned int M2RTS_InstallInitialProcedure (PROC p); extern "C" void M2RTS_ExecuteTerminationProcedures (void); extern "C" void M2RTS_Terminate (void) __attribute__ ((noreturn)); extern "C" void M2RTS_HALT (int exitcode) __attribute__ ((noreturn)); -extern "C" void M2RTS_Halt (const char *file_, unsigned int _file_high, unsigned int line, const char *function_, unsigned int _function_high, const char *description_, unsigned int _description_high) __attribute__ ((noreturn)); +extern "C" void M2RTS_Halt (const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high, const char *description_, unsigned int _description_high) __attribute__ ((noreturn)); +extern "C" void M2RTS_HaltC (void * filename, unsigned int line, void * function, void * description); extern "C" void M2RTS_ExitOnHalt (int e); -extern "C" void M2RTS_ErrorMessage (const char *message_, unsigned int _message_high, const char *file_, unsigned int _file_high, unsigned int line, const char *function_, unsigned int _function_high) __attribute__ ((noreturn)); +extern "C" void M2RTS_ErrorMessage (const char *message_, unsigned int _message_high, const char *filename_, unsigned int _filename_high, unsigned int line, const char *function_, unsigned int _function_high) __attribute__ ((noreturn)); extern "C" unsigned int M2RTS_Length (const char *a_, unsigned int _a_high); extern "C" void M2RTS_AssignmentException (void * filename, unsigned int line, unsigned int column, void * scope, void * message); extern "C" void M2RTS_ReturnException (void * filename, unsigned int line, unsigned int column, void * scope, void * message); diff --git a/gcc/m2/mc-boot/GmcOptions.c b/gcc/m2/mc-boot/GmcOptions.c index 3088ba4..77801c0 100644 --- a/gcc/m2/mc-boot/GmcOptions.c +++ b/gcc/m2/mc-boot/GmcOptions.c @@ -324,7 +324,10 @@ static void displayVersion (unsigned int mustExit) unsigned int year; year = getYear (); - mcPrintf_printf1 ((const char *) "Copyright (C) %d Free Software Foundation, Inc.\\n", 49, (const unsigned char *) &year, (sizeof (year)-1)); + /* These first three calls to printf hide the first line of text away from the year change script. */ + mcPrintf_printf0 ((const char *) "Copyright ", 10); + mcPrintf_printf0 ((const char *) "(C)", 3); /* A unicode char here would be good. */ + mcPrintf_printf1 ((const char *) " %d Free Software Foundation, Inc.\\n", 36, (const unsigned char *) &year, (sizeof (year)-1)); /* A unicode char here would be good. */ mcPrintf_printf0 ((const char *) "License GPLv3: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\\n", 78); mcPrintf_printf0 ((const char *) "This is free software: you are free to change and redistribute it.\\n", 68); mcPrintf_printf0 ((const char *) "There is NO WARRANTY, to the extent permitted by law.\\n", 55); diff --git a/gcc/m2/mc/mcOptions.mod b/gcc/m2/mc/mcOptions.mod index 3204b68..909d798 100644 --- a/gcc/m2/mc/mcOptions.mod +++ b/gcc/m2/mc/mcOptions.mod @@ -87,7 +87,10 @@ VAR year: CARDINAL ; BEGIN year := getYear () ; - printf1 ('Copyright (C) %d Free Software Foundation, Inc.\n', year) ; + (* These first three calls to printf hide the first line of text away from the year change script. *) + printf0 ('Copyright ') ; + printf0 ('(C)') ; (* A unicode char here would be good. *) + printf1 (' %d Free Software Foundation, Inc.\n', year) ; printf0 ('License GPLv3: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n') ; printf0 ('This is free software: you are free to change and redistribute it.\n') ; printf0 ('There is NO WARRANTY, to the extent permitted by law.\n') ; |