From a4c7d9d46600a6bb4b0fea0de60c7736ed558a9f Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Mon, 22 Jul 2013 00:39:21 +0800 Subject: fix relocation records order --- rld-rap.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/rld-rap.cpp b/rld-rap.cpp index 2b805cf..5150935 100644 --- a/rld-rap.cpp +++ b/rld-rap.cpp @@ -80,6 +80,18 @@ namespace rld */ typedef std::vector < relocation > relocations; + /** + * Relocation symname sorter for the relocations container. + */ + class reloc_symname_compare + { + public: + bool operator () (const relocation& lhs, + const relocation& rhs) const { + return lhs.symname < rhs.symname; + } + }; + /** * Relocation offset sorter for the relocations container. */ @@ -88,7 +100,9 @@ namespace rld public: bool operator () (const relocation& lhs, const relocation& rhs) const { - return lhs.offset < rhs.offset; + if (lhs.symname == rhs.symname) + return lhs.offset < rhs.offset; + else return false; } }; @@ -681,6 +695,9 @@ namespace rld sec.relocs.push_back (relocation (freloc, offset)); } + std::stable_sort (sec.relocs.begin (), + sec.relocs.end (), + reloc_symname_compare ()); std::stable_sort (sec.relocs.begin (), sec.relocs.end (), reloc_offset_compare ()); -- cgit v1.2.3