summaryrefslogtreecommitdiff
path: root/rld-outputter.cpp
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2012-11-20 19:53:24 +1100
committerChris Johns <chrisj@rtems.org>2012-11-20 19:53:24 +1100
commit256c1455227fd1421e7c71b2902df6a07cd290f2 (patch)
tree46d193d73b30b891f2777394c9422deb8f3d3fae /rld-outputter.cpp
parentd0a1bded76293012fbdb9af05bc9b333cf09398b (diff)
Add support to write a metadata ELF file.
This also adds support to the ELF classes that wrap libelf. While this is now done and seems to work I will not be using an ELF file to hold the metadata after all.
Diffstat (limited to 'rld-outputter.cpp')
-rw-r--r--rld-outputter.cpp58
1 files changed, 57 insertions, 1 deletions
diff --git a/rld-outputter.cpp b/rld-outputter.cpp
index bdd9dfa..518bbec 100644
--- a/rld-outputter.cpp
+++ b/rld-outputter.cpp
@@ -82,6 +82,58 @@ namespace rld
return out.str ();
}
+ const std::string
+ metadata_object (const std::string& name,
+ rld::files::object_list& dependents,
+ rld::files::cache& cache)
+ {
+ const std::string script = script_text (dependents, cache);
+
+ std::string ext = files::extension (name);
+ std::string mdname =
+ name.substr (0, name.length () - ext.length ()) + "-metadata.o";
+
+ if (rld::verbose () >= RLD_VERBOSE_INFO)
+ std::cout << "metadata: " << mdname << std::endl;
+
+ files::object metadata (mdname);
+
+ metadata.open (true);
+ metadata.begin ();
+
+ elf::file& elf = metadata.elf ();
+
+ std::cout << "class: " << elf::object_class () << std::endl;
+
+ elf.set_header (ET_EXEC,
+ elf::object_class (),
+ elf::object_datatype (),
+ elf::object_machine_type ());
+
+ elf::section md (elf,
+ elf.section_count () + 1,
+ ".rtemsmd",
+ SHT_STRTAB,
+ 1,
+ 0,
+ 0,
+ 0,
+ script.length ());
+
+ md.add_data (ELF_T_BYTE,
+ 1,
+ script.length (),
+ (void*) script.c_str ());
+
+ elf.add (md);
+ elf.write ();
+
+ metadata.end ();
+ metadata.close ();
+
+ return mdname;
+ }
+
void
archive (const std::string& name,
rld::files::object_list& dependents,
@@ -90,7 +142,11 @@ namespace rld
if (rld::verbose () >= RLD_VERBOSE_INFO)
std::cout << "outputter:archive: " << name << std::endl;
- rld::files::object_list objects;
+ std::string metadata = metadata_object (name,
+ dependents,
+ cache);
+
+ files::object_list objects;
cache.get_objects (objects);
for (rld::files::object_list::iterator oi = dependents.begin ();