[rtems-tools commit] rtemstoolkit/elf: Add data size and endian support to the ELF interface.
Chris Johns
chrisj at rtems.org
Tue Jun 19 03:43:15 UTC 2018
Module: rtems-tools
Branch: master
Commit: 3618a62faf8c4a8cad51779368d091f0480450fd
Changeset: http://git.rtems.org/rtems-tools/commit/?id=3618a62faf8c4a8cad51779368d091f0480450fd
Author: Chris Johns <chrisj at rtems.org>
Date: Tue May 8 15:09:43 2018 +1000
rtemstoolkit/elf: Add data size and endian support to the ELF interface.
---
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:
/**
More information about the vc
mailing list