diff -Nuar a/gcc/output.h b/gcc/output.h
--- a/gcc/output.h	2022-08-19 11:09:52.000000000 +0300
+++ b/gcc/output.h	2023-01-28 19:08:24.361651050 +0300
@@ -616,6 +616,7 @@
 extern void default_file_start (void);
 extern void file_end_indicate_exec_stack (void);
 extern void file_end_indicate_split_stack (void);
+extern void pisilinux_file_end_indicate_optflags (void);

 extern void default_elf_asm_output_external (FILE *file, tree,
 					     const char *);
diff -Nuar a/gcc/toplev.cc b/gcc/toplev.cc
--- a/gcc/toplev.cc	2022-08-19 11:09:54.000000000 +0300
+++ b/gcc/toplev.cc	2023-01-28 19:09:28.469849588 +0300
@@ -582,6 +582,8 @@
   /* Invoke registered plugin callbacks.  */
   invoke_plugin_callbacks (PLUGIN_FINISH_UNIT, NULL);

+  pisilinux_file_end_indicate_optflags ();
+
   /* This must be at the end.  Some target ports emit end of file directives
      into the assembly file here, and hence we cannot output anything to the
      assembly file after this point.  */
diff -Nuar a/gcc/varasm.cc b/gcc/varasm.cc
--- a/gcc/varasm.cc	2022-08-19 11:09:54.000000000 +0300
+++ b/gcc/varasm.cc	2023-01-28 19:11:30.730321121 +0300
@@ -7762,14 +7762,34 @@
   switch_to_section (get_section (".note.GNU-stack", flags, NULL));
 }

-/* Emit a special section directive to indicate that this object file
-   was compiled with -fsplit-stack.  This is used to let the linker
-   detect calls between split-stack code and non-split-stack code, so
-   that it can modify the split-stack code to allocate a sufficiently
-   large stack.  We emit another special section if there are any
-   functions in this file which have the no_split_stack attribute, to
-   prevent the linker from warning about being unable to convert the
-   functions if they call non-split-stack code.  */
+/* This is a generic routine emitting a PisiLinux specific section for
+   QA check marks. */
+
+void
+pisilinux_file_end_indicate_optflags (void)
+{
+  unsigned int flags = SECTION_DEBUG | SECTION_STRINGS | SECTION_MERGE | (SECTION_ENTSIZE & 1);
+
+  /*
+     o/O: optimize was off/on
+     s/S: size optimisation was off/on
+     p/P: stack-protector was off/on
+     w/W: warnings were off/on
+     g/G: debug was off/on
+     */
+
+  char opts_buffer[6];
+
+  opts_buffer[0] = (optimize >= 2) ? 'O' : 'o';
+  opts_buffer[1] = (optimize >= 1 && optimize_size) ? 'S' : 's';
+  opts_buffer[2] = (flag_stack_protect >= 1) ? 'P' : 'p';
+  opts_buffer[3] = (warn_uninitialized >= 1 && warn_sequence_point >= 1) ? 'W' : 'w';
+  opts_buffer[4] = (debug_info_level > DINFO_LEVEL_NONE) ? 'G' : 'g';
+  opts_buffer[5] = '\0';
+
+  switch_to_section (get_section (".comment.PISILINUX.OPTs", flags, NULL));
+  ASM_OUTPUT_ASCII (asm_out_file, opts_buffer, strlen (opts_buffer) + 1);
+}

 void
 file_end_indicate_split_stack (void)
