[PATCH v2 06/10] rtemstoolkit/elf: Add data size and endian support to the ELF interface.
Chris Johns
chrisj at rtems.org
Tue May 8 05:09:43 UTC 2018
---
rtemstoolkit/rld-elf.cpp | 22 ++++++++++++++++++++++
rtemstoolkit/rld-elf.h | 10 ++++++++++
2 files changed, 32 insertions(+)
diff --git a/rtemstoolkit/rld-elf.cpp b/rtemstoolkit/rld-elf.cpp
index 2d3d090..60ba484 100644
--- a/rtemstoolkit/rld-elf.cpp
+++ b/rtemstoolkit/rld-elf.cpp
@@ -1082,6 +1082,28 @@ namespace rld
return writable;
}
+ size_t
+ file::machine_size () const
+ {
+ size_t bytes;
+ switch (object_class ())
+ {
+ case ELFCLASS64:
+ bytes = sizeof (uint64_t);
+ break;
+ default:
+ bytes = sizeof (uint32_t);
+ break;
+ }
+ return bytes;
+ }
+
+ bool
+ file::is_little_endian () const
+ {
+ return data_type () == ELFDATA2LSB;
+ }
+
void
file::check (const char* where) const
{
diff --git a/rtemstoolkit/rld-elf.h b/rtemstoolkit/rld-elf.h
index 92e92c1..4919135 100644
--- a/rtemstoolkit/rld-elf.h
+++ b/rtemstoolkit/rld-elf.h
@@ -655,6 +655,16 @@ namespace rld
*/
void reference_release ();
+ /**
+ * Get the machine size in bytes.
+ */
+ size_t machine_size () const;
+
+ /**
+ * Returns true if little endian.
+ */
+ bool is_little_endian () const;
+
private:
/**
--
2.15.1
More information about the devel
mailing list