summaryrefslogtreecommitdiff
path: root/linkers
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
commitf2915943d15c33f8448eef5558be62505816cf51 (patch)
treeb0fa68c2cf79df935b1a00c2a89579d5cd6e2085 /linkers
parentc14133efafd2c09e228a74d9d1f491bcad966e6e (diff)
fix relocation records order
Diffstat (limited to 'linkers')
-rw-r--r--linkers/rld-rap.cpp19
1 files changed, 18 insertions, 1 deletions
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
@@ -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)