diff options
author | Chris Johns <chrisj@rtems.org> | 2012-12-31 18:29:10 +1100 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2012-12-31 18:29:10 +1100 |
commit | 63506145398b59151ceb85ab79382c2c063f0c75 (patch) | |
tree | ca7bbb14d3ae31dcb0e7b2d1ad9f8ce82ab3b77d /rld-rap.cpp | |
parent | 0d1e75013910cd58a08f4942f5ed44ff08ce2435 (diff) |
Sort the relocation records by offset for a section.
Diffstat (limited to 'rld-rap.cpp')
-rw-r--r-- | rld-rap.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/rld-rap.cpp b/rld-rap.cpp index fc95d9b..d09a90a 100644 --- a/rld-rap.cpp +++ b/rld-rap.cpp @@ -74,7 +74,19 @@ namespace rld /** * Relocation records. */ - typedef std::list < relocation > relocations; + typedef std::vector < relocation > relocations; + + /** + * Relocation offset sorter for the relocations container. + */ + class reloc_offset_compare + { + public: + bool operator () (const relocation& lhs, + const relocation& rhs) const { + return lhs.offset < rhs.offset; + } + }; /** * An object section's offset, size and alignment. @@ -669,6 +681,10 @@ namespace rld sec.relocs.push_back (relocation (freloc, offset)); } + std::stable_sort (sec.relocs.begin (), + sec.relocs.end (), + reloc_offset_compare ()); + sec.rela = fsec.rela; } |