diff options
author | Chris Johns <chrisj@rtems.org> | 2012-11-29 19:02:28 +1100 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2012-11-29 19:02:28 +1100 |
commit | 8485a331346f2729c835f03f6bd6939780bccbe5 (patch) | |
tree | 0c8f001619ec847291fe724a193714c613e6a76d | |
parent | 14ba72fd1b30dfbe8a0635e0ae78a812b1dd4a46 (diff) |
Add the index to the section.
The index is referenced in the symbol and relocation records of ELF files
therefore we need to search for them.
-rw-r--r-- | rld-files.cpp | 17 | ||||
-rw-r--r-- | rld-files.h | 6 |
2 files changed, 23 insertions, 0 deletions
diff --git a/rld-files.cpp b/rld-files.cpp index 05f54b3..94508a1 100644 --- a/rld-files.cpp +++ b/rld-files.cpp @@ -902,6 +902,7 @@ namespace rld section::section (const elf::section& es) : name (es.name ()), + index (es.index ()), type (es.type ()), size (es.size ()), alignment (es.alignment ()), @@ -930,6 +931,22 @@ namespace rld return size; } + const section* + find (const sections& secs, const int index) + { + for (sections::const_iterator si = secs.begin (); + si != secs.end (); + ++si) + { + const section& sec = *si; + + if (index == sec.index) + return &sec; + } + + return 0; + } + object::object (archive& archive_, file& name_) : image (name_), archive_ (&archive_), diff --git a/rld-files.h b/rld-files.h index fb8c644..de49b4c 100644 --- a/rld-files.h +++ b/rld-files.h @@ -518,6 +518,7 @@ namespace rld struct section { const std::string name; //< The name of the section. + const int index; //< The section's index in the object file. const uint32_t type; //< The type of section. const size_t size; //< The size of the section. const uint32_t alignment; //< The alignment of the section. @@ -550,6 +551,11 @@ namespace rld size_t sum_sizes (const sections& secs); /** + * Find the section that matches the index in the sections provided. + */ + const section* find (const sections& secs, const int index); + + /** * The object file cab be in an archive or a file. */ class object: |