summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2018-05-08 15:09:43 +1000
committerChris Johns <chrisj@rtems.org>2018-06-15 15:54:25 +1000
commit3618a62faf8c4a8cad51779368d091f0480450fd (patch)
treeb4f07abdfbc7861fed577e68e358372bcfea171a
parentcovoar: Add libdwarf to the include path. (diff)
downloadrtems-tools-3618a62faf8c4a8cad51779368d091f0480450fd.tar.bz2
rtemstoolkit/elf: Add data size and endian support to the ELF interface.
-rw-r--r--rtemstoolkit/rld-elf.cpp22
-rw-r--r--rtemstoolkit/rld-elf.h10
2 files changed, 32 insertions, 0 deletions
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:
/**