1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

Fix an off-by-one bug in the target independent llvm-objdump.

It would prevent the display of a single byte instruction before a label.

Patch by Steve King!

llvm-svn: 215837
This commit is contained in:
Rafael Espindola 2014-08-17 16:31:39 +00:00
parent 42246e7f06
commit c4b48a6a79
3 changed files with 15 additions and 10 deletions

Binary file not shown.

View File

@ -0,0 +1,10 @@
RUN: llvm-objdump -d %p/../Inputs/trivial-label-test.elf-x86-64 \
RUN: | FileCheck %s -check-prefix ELF-x86-64
ELF-x86-64: file format ELF64-x86-64
ELF-x86-64: Disassembly of section .text:
ELF-x86-64: foo:
ELF-x86-64: 0: 90 nop
ELF-x86-64: bum:
ELF-x86-64: 1: 90 nop

View File

@ -494,17 +494,12 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
std::vector<RelocationRef>::const_iterator rel_end = Rels.end(); std::vector<RelocationRef>::const_iterator rel_end = Rels.end();
// Disassemble symbol by symbol. // Disassemble symbol by symbol.
for (unsigned si = 0, se = Symbols.size(); si != se; ++si) { for (unsigned si = 0, se = Symbols.size(); si != se; ++si) {
uint64_t Start = Symbols[si].first; uint64_t Start = Symbols[si].first;
uint64_t End; // The end is either the section end or the beginning of the next symbol.
// The end is either the size of the section or the beginning of the next uint64_t End = (si == se - 1) ? SectSize : Symbols[si + 1].first;
// symbol. // If this symbol has the same address as the next symbol, then skip it.
if (si == se - 1) if (Start == End)
End = SectSize;
// Make sure this symbol takes up space.
else if (Symbols[si + 1].first != Start)
End = Symbols[si + 1].first - 1;
else
// This symbol has the same address as the next symbol. Skip it.
continue; continue;
outs() << '\n' << Symbols[si].second << ":\n"; outs() << '\n' << Symbols[si].second << ":\n";