diff options
author | Chris Johns <chrisj@rtems.org> | 2012-11-26 11:07:06 +1100 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2012-11-26 11:07:06 +1100 |
commit | 7e6c3734ed95b5667cc6f94e9513aa5287c1e5e5 (patch) | |
tree | b7168330c75310d4ea05fc3b4fc6f902305180c1 | |
parent | 8fdabca48d74b70a5d35ea31bca09261a587b7f3 (diff) |
Add exit label, ELF application and Application.
Add an exit label that is called when removing an application.
Change the "applicatiion" to "elf_application" and add a custom
format called the RAP format for applications.
-rw-r--r-- | rld-outputter.cpp | 95 | ||||
-rw-r--r-- | rld-outputter.h | 39 |
2 files changed, 94 insertions, 40 deletions
diff --git a/rld-outputter.cpp b/rld-outputter.cpp index 0350999..680b25f 100644 --- a/rld-outputter.cpp +++ b/rld-outputter.cpp @@ -33,7 +33,7 @@ #include <string.h> #include <rld.h> -#include <rld-compression.h> +#include <rld-rap.h> namespace rld { @@ -41,6 +41,7 @@ namespace rld { const std::string script_text (const std::string& entry, + const std::string& exit, const files::object_list& dependents, const files::cache& cache, bool not_in_archive) @@ -54,9 +55,16 @@ namespace rld objects.unique (); if (rld::verbose () >= RLD_VERBOSE_INFO) - std::cout << " e: " << entry << std::endl; + std::cout << " E: " << entry << std::endl; - out << "e: " << entry << std::endl; + out << "E: " << entry << std::endl; + + if (!exit.empty ()) + { + if (rld::verbose () >= RLD_VERBOSE_INFO) + std::cout << " e: " << exit << std::endl; + out << "e: " << exit << std::endl; + } for (files::object_list::iterator oi = objects.begin (); oi != objects.end (); @@ -104,13 +112,15 @@ namespace rld void metadata_object (files::object& metadata, const std::string& entry, + const std::string& exit, const files::object_list& dependents, const files::cache& cache) { if (rld::verbose () >= RLD_VERBOSE_INFO) std::cout << "metadata: " << metadata.name ().full () << std::endl; - const std::string script = script_text (entry, dependents, cache, true); + const std::string script = + script_text (entry, exit, dependents, cache, true); metadata.open (true); metadata.begin (); @@ -147,6 +157,7 @@ namespace rld void archive (const std::string& name, const std::string& entry, + const std::string& exit, const files::object_list& dependents, const files::cache& cache) { @@ -160,7 +171,7 @@ namespace rld files::object metadata (mdname); - metadata_object (metadata, entry, dependents, cache); + metadata_object (metadata, entry, exit, dependents, cache); files::object_list dep_copy (dependents); files::object_list objects; @@ -177,6 +188,7 @@ namespace rld void script (const std::string& name, const std::string& entry, + const std::string& exit, const files::object_list& dependents, const files::cache& cache) { @@ -193,7 +205,7 @@ namespace rld try { - out << script_text (entry, dependents, cache, false); + out << script_text (entry, exit, dependents, cache, false); } catch (...) { @@ -205,10 +217,11 @@ namespace rld } void - application (const std::string& name, - const std::string& entry, - const files::object_list& dependents, - const files::cache& cache) + elf_application (const std::string& name, + const std::string& entry, + const std::string& exit, + const files::object_list& dependents, + const files::cache& cache) { if (rld::verbose () >= RLD_VERBOSE_INFO) std::cout << "outputter:application: " << name << std::endl; @@ -219,10 +232,10 @@ namespace rld std::string script; files::image app (name); - header = "RAP,00000000,01.00.00,LZ77,00000000\n"; + header = "RELF,00000000,0001,none,00000000\n"; header += '\0'; - script = script_text (entry, dependents, cache, true); + script = script_text (entry, exit, dependents, cache, true); cache.get_objects (objects); objects.merge (dep_copy); @@ -233,16 +246,12 @@ namespace rld #define APP_BUFFER_SIZE (128 * 1024) - compress::compressor compressor (app, APP_BUFFER_SIZE); - uint8_t* buffer = 0; try { buffer = new uint8_t[APP_BUFFER_SIZE]; - compressor.write (script.c_str (), script.size ()); - for (files::object_list::iterator oi = objects.begin (); oi != objects.end (); ++oi) @@ -262,9 +271,9 @@ namespace rld size_t reading = in_size < APP_BUFFER_SIZE ? in_size : APP_BUFFER_SIZE; - obj.read (buffer, reading); + app.write (buffer, obj.read (buffer, reading)); - compressor.write (buffer, reading); + in_size -= reading; } } catch (...) @@ -279,25 +288,55 @@ namespace rld catch (...) { delete [] buffer; + app.close (); throw; } - compressor.flush (); + delete [] buffer; app.close (); + } - delete [] buffer; - + void + application (const std::string& name, + const std::string& entry, + const std::string& exit, + const files::object_list& dependents, + const files::cache& cache, + const symbols::table& symbols) + { if (rld::verbose () >= RLD_VERBOSE_INFO) + std::cout << "outputter:application: " << name << std::endl; + + files::object_list dep_copy (dependents); + files::object_list objects; + std::string header; + std::string script; + files::image app (name); + + header = "RAP,00000000,0001,LZ77,00000000\n"; + header += '\0'; + + script = script_text (entry, exit, dependents, cache, true); + + cache.get_objects (objects); + objects.merge (dep_copy); + objects.unique (); + + app.open (true); + app.write (header.c_str (), header.size ()); + + try { - int pcent = (compressor.compressed () * 100) / compressor.transferred (); - int premand = (((compressor.compressed () * 1000) + 500) / - compressor.transferred ()) % 10; - std::cout << "outputter:application: objects: " << objects.size () - << ", size: " << compressor.compressed () - << ", compression: " << pcent << '.' << premand << '%' - << std::endl; + rap::write (app, script, objects, symbols); } + catch (...) + { + app.close (); + throw; + } + + app.close (); } } diff --git a/rld-outputter.h b/rld-outputter.h index 116d4b3..05e134e 100644 --- a/rld-outputter.h +++ b/rld-outputter.h @@ -32,25 +32,17 @@ namespace rld namespace outputter { /** - * The types of output. - */ - enum type - { - ot_script, - ot_archive, - ot_application - }; - - /** * Output the object file list as a string. * * @param entry The name of the entry point symbol. + * @param exit The name of the exit point symbol. * @param dependents The list of dependent object files * @param cache The file cache for the link. Includes the object list * the user requested. * @return std::string The list as a text string. */ std::string script_text (const std::string& entry, + const std::string& exit, const files::object_list& dependents, const files::cache& cache); /** @@ -59,12 +51,14 @@ namespace rld * * @param name The name of the archive. * @param entry The name of the entry point symbol. + * @param exit The name of the exit point symbol. * @param dependents The list of dependent object files * @param cache The file cache for the link. Includes the object list * the user requested. */ void archive (const std::string& name, const std::string& entry, + const std::string& exit, const files::object_list& dependents, const files::cache& cache); @@ -73,28 +67,49 @@ namespace rld * * @param name The name of the script. * @param entry The name of the entry point symbol. + * @param exit The name of the exit point symbol. * @param dependents The list of dependent object files * @param cache The file cache for the link. Includes the object list * the user requested. */ void script (const std::string& name, const std::string& entry, + const std::string& exit, const files::object_list& dependents, const files::cache& cache); /** - * Output the object files as a compressed list of files. + * Output the object files in an archive with the metadata. + * + * @param name The name of the script. + * @param entry The name of the entry point symbol. + * @param exit The name of the exit point symbol. + * @param dependents The list of dependent object files + * @param cache The file cache for the link. Includes the object list + * the user requested. + */ + void elf_application (const std::string& name, + const std::string& entry, + const std::string& exit, + const files::object_list& dependents, + const files::cache& cache); + + /** + * Output the object files in an archive with the metadata. * * @param name The name of the script. * @param entry The name of the entry point symbol. + * @param exit The name of the exit point symbol. * @param dependents The list of dependent object files * @param cache The file cache for the link. Includes the object list * the user requested. */ void application (const std::string& name, const std::string& entry, + const std::string& exit, const files::object_list& dependents, - const files::cache& cache); + const files::cache& cache, + const symbols::table& symbols); } } |