[llvm] r215837 - Fix an off-by-one bug in the target independent llvm-objdump.
Rafael Espindola
rafael.espindola at gmail.com
Sun Aug 17 09:31:39 PDT 2014
Author: rafael
Date: Sun Aug 17 11:31:39 2014
New Revision: 215837
URL: http://llvm.org/viewvc/llvm-project?rev=215837&view=rev
Log:
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!
Added:
llvm/trunk/test/Object/Inputs/trivial-label-test.elf-x86-64
llvm/trunk/test/Object/X86/objdump-label.test
Modified:
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
Added: llvm/trunk/test/Object/Inputs/trivial-label-test.elf-x86-64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/trivial-label-test.elf-x86-64?rev=215837&view=auto
==============================================================================
Binary files llvm/trunk/test/Object/Inputs/trivial-label-test.elf-x86-64 (added) and llvm/trunk/test/Object/Inputs/trivial-label-test.elf-x86-64 Sun Aug 17 11:31:39 2014 differ
Added: llvm/trunk/test/Object/X86/objdump-label.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/X86/objdump-label.test?rev=215837&view=auto
==============================================================================
--- llvm/trunk/test/Object/X86/objdump-label.test (added)
+++ llvm/trunk/test/Object/X86/objdump-label.test Sun Aug 17 11:31:39 2014
@@ -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
+
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=215837&r1=215836&r2=215837&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Sun Aug 17 11:31:39 2014
@@ -494,17 +494,12 @@ static void DisassembleObject(const Obje
std::vector<RelocationRef>::const_iterator rel_end = Rels.end();
// Disassemble symbol by symbol.
for (unsigned si = 0, se = Symbols.size(); si != se; ++si) {
+
uint64_t Start = Symbols[si].first;
- uint64_t End;
- // The end is either the size of the section or the beginning of the next
- // symbol.
- if (si == se - 1)
- 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.
+ // The end is either the section end or the beginning of the next symbol.
+ uint64_t End = (si == se - 1) ? SectSize : Symbols[si + 1].first;
+ // If this symbol has the same address as the next symbol, then skip it.
+ if (Start == End)
continue;
outs() << '\n' << Symbols[si].second << ":\n";
More information about the llvm-commits
mailing list