[Courgette] Fix ELF reference sorting.
This CL addresses 2 reference sorting issues in DisassemblerElf32:
(1) Bug fix: In ParseFile(), |abs32_locations_| (RVAs) is translated to
|abs_offsets| (file offsets), but we sort |abs32_locations_|, which
is redundant. Actually we should sort |abs_offsets|.
(2) Cleanup: |rel32_relocations_| stores rel32 references sorted by
RVA, but in ParseFile() we re-sort these in offset order. Previously
Disassemble() optimizes away redundant sorts, but this makes the
code less robust. We de-optimize this a little potentially redundant
sort-by-RVA, to assert that |rel32_locations_| is sorted by RVA
outside of ParseFile().
This CL also makes Disassemble() more uniform, to prepare for
refactoring in a follow-up. Meanwhile, DisassemblerWin32 does not
experience issue since it assumes RVA order is same as file offset
order (this assumption has not has not caused problems so far).
1 file changed