From 06a2cf6eb32e24c532ac3ca5c793a110dc42a5a5 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Mon, 31 Dec 2012 18:11:47 +1100 Subject: Sort the relocations by offset to make the overlay work. --- linkers/rtems-rapper.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'linkers') diff --git a/linkers/rtems-rapper.cpp b/linkers/rtems-rapper.cpp index 9c539f2..a5abac9 100644 --- a/linkers/rtems-rapper.cpp +++ b/linkers/rtems-rapper.cpp @@ -73,6 +73,18 @@ namespace rap 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; + } + }; + /** * A RAP section. */ @@ -285,6 +297,8 @@ namespace rap relocs.push_back (reloc); } + + std::stable_sort (relocs.begin (), relocs.end (), reloc_offset_compare ()); } } @@ -647,7 +661,10 @@ rap_show (rld::files::paths& raps, int count = 0; while (offset < r.strtab_size) { - std::cout << std::setw (16) << count++ << ": " + std::cout << std::setw (16) << count++ + << std::hex << std::setfill ('0') + << " (0x" << std::setw (6) << offset << "): " + << std::dec << std::setfill (' ') << (char*) &r.strtab[offset] << std::endl; offset += ::strlen ((char*) &r.strtab[offset]) + 1; } @@ -724,7 +741,6 @@ rap_show (rld::files::paths& raps, std::cout << std::setw (16) << " " << "No relocation table found." << std::endl; } - } } -- cgit v1.2.3