[RTEMS Tools 3/4] linkers: Allow generation of symbol map file only

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Feb 26 09:41:30 UTC 2024


If a symbol map file is specified by the user and no output file, then
just generate the symbol map file.  The user can then compile the file
using its own build jobs.
---
 linkers/rtems-syms.cpp | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/linkers/rtems-syms.cpp b/linkers/rtems-syms.cpp
index 377007d..9dd845f 100644
--- a/linkers/rtems-syms.cpp
+++ b/linkers/rtems-syms.cpp
@@ -345,6 +345,10 @@ generate_c (rld::process::tempfile& c,
             rld::symbols::symtab&   symbols,
             bool                    embed)
 {
+  if (rld::verbose ())
+    std::cout << "symbol C file: " << c.name () << std::endl;
+
+  c.open (true);
   temporary_file_paint (c, c_header);
 
   /*
@@ -390,11 +394,6 @@ generate_symmap (rld::process::tempfile& c,
                  rld::symbols::symtab&   symbols,
                  bool                    embed)
 {
-  c.open (true);
-
-  if (rld::verbose ())
-    std::cout << "symbol C file: " << c.name () << std::endl;
-
   generate_c (c, symbols, embed);
 
   if (rld::verbose ())
@@ -622,8 +621,8 @@ main (int argc, char* argv[])
       throw rld::error ("no kernel file", "options");
     if (argc != 1)
       throw rld::error ("only one kernel file", "options");
-    if (output.empty () && map.empty ())
-      throw rld::error ("no output or map", "options");
+    if (output.empty () && symc.empty() && map.empty ())
+      throw rld::error ("no output, symbol C file, or map", "options");
 
     kernel_name = *argv;
 
@@ -683,7 +682,7 @@ main (int argc, char* argv[])
       /*
        * Create an output file if asked too.
        */
-      if (!output.empty ())
+      if (!output.empty () || !symc.empty())
       {
         rld::process::tempfile c (".c");
 
@@ -694,9 +693,12 @@ main (int argc, char* argv[])
         }
 
         /*
-         * Generate and compile the symbol map.
+         * Generate and if requested compile the symbol map.
          */
-        generate_symmap (c, output, filter_symbols, embed);
+        if (output.empty())
+          generate_c (c, filter_symbols, embed);
+        else
+          generate_symmap (c, output, filter_symbols, embed);
       }
 
       kernel.close ();
-- 
2.35.3



More information about the devel mailing list