summaryrefslogtreecommitdiff
path: root/linkers
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2012-12-31 18:29:10 +1100
committerChris Johns <chrisj@rtems.org>2012-12-31 18:29:10 +1100
commitf43851acc0b2a9380c797dff8419c1acf0626dfa (patch)
treeb39441a481ad8a0bd41f255637fe0cde96abb6e8 /linkers
parent4e7ec707b08096c8e3a4ea8c826775bf4af74355 (diff)
Sort the relocation records by offset for a section.
Diffstat (limited to 'linkers')
-rw-r--r--linkers/rld-rap.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/linkers/rld-rap.cpp b/linkers/rld-rap.cpp
index fc95d9b..d09a90a 100644
--- a/linkers/rld-rap.cpp
+++ b/linkers/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;
}