summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeng Fan <van.freenix@gmail.com>2013-07-22 00:39:21 +0800
committerPeng Fan <van.freenix@gmail.com>2013-07-22 00:39:21 +0800
commita4c7d9d46600a6bb4b0fea0de60c7736ed558a9f (patch)
treef4f95a7aa93dc22e9c7931b8e0d9b954ed4fad5e
parenta2b1d16bd059010bb92e9164e693cb97c61dcc01 (diff)
fix relocation records order
-rw-r--r--rld-rap.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/rld-rap.cpp b/rld-rap.cpp
index 2b805cf..5150935 100644
--- a/rld-rap.cpp
+++ b/rld-rap.cpp
@@ -81,6 +81,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.
*/
class reloc_offset_compare
@@ -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;
}
};
@@ -683,6 +697,9 @@ namespace rld
std::stable_sort (sec.relocs.begin (),
sec.relocs.end (),
+ reloc_symname_compare ());
+ std::stable_sort (sec.relocs.begin (),
+ sec.relocs.end (),
reloc_offset_compare ());
if (fsec.rela == true)