From f2915943d15c33f8448eef5558be62505816cf51 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Mon, 22 Jul 2013 00:39:21 +0800 Subject: fix relocation records order --- linkers/rld-rap.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'linkers') diff --git a/linkers/rld-rap.cpp b/linkers/rld-rap.cpp index 2b805cf..5150935 100644 --- a/linkers/rld-rap.cpp +++ b/linkers/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