summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2014-01-25 17:38:19 +0000
committerMark Seaborn <mseaborn@chromium.org>2014-01-25 17:38:19 +0000
commit0929d3d8551edfb09a7f8ab98f854dad466276a7 (patch)
tree543a41b6f637434b1104f2f0d8844a538d0008ce /llvm/tools/llvm-objdump/llvm-objdump.cpp
parent336e1f117932dd1845a30e242803ee1b0e77b106 (diff)
downloadbcm5719-llvm-0929d3d8551edfb09a7f8ab98f854dad466276a7.tar.gz
bcm5719-llvm-0929d3d8551edfb09a7f8ab98f854dad466276a7.zip
Fix "llvm-objdump -d -r" to show relocations inline for ELF files
This fixes a regression introduced by r182908, which broke llvm-objdump's ability to display relocations inline in a disassembly dump for ELF object files. That change removed a SectionRelocMap from Object/ELF.h, which we recreate in llvm-objdump.cpp. I discovered this regression via an out-of-tree test (test/NaCl/X86/pnacl-hides-sandbox-x86-64.ll) which used llvm-objdump. Note that the "Unknown" string in the test output on i386 isn't quite right, but this appears to be a pre-existing bug. Differential Revision: http://llvm-reviews.chandlerc.com/D2559 llvm-svn: 200090
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 5efb74f11fd..9a56bf9b4c0 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -382,7 +382,19 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
}
}
+ // Create a mapping, RelocSecs = SectionRelocMap[S], where sections
+ // in RelocSecs contain the relocations for section S.
error_code EC;
+ std::map<SectionRef, SmallVector<SectionRef, 1> > SectionRelocMap;
+ for (section_iterator I = Obj->begin_sections(), E = Obj->end_sections();
+ I != E; I.increment(EC)) {
+ if (error(EC))
+ break;
+ section_iterator Sec2 = I->getRelocatedSection();
+ if (Sec2 != Obj->end_sections())
+ SectionRelocMap[*Sec2].push_back(*I);
+ }
+
for (section_iterator I = Obj->begin_sections(), E = Obj->end_sections();
I != E; I.increment(EC)) {
if (error(EC))
@@ -423,12 +435,17 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
// Make a list of all the relocations for this section.
std::vector<RelocationRef> Rels;
if (InlineRelocs) {
- for (relocation_iterator RI = I->begin_relocations(),
- RE = I->end_relocations();
- RI != RE; RI.increment(EC)) {
- if (error(EC))
- break;
- Rels.push_back(*RI);
+ SmallVectorImpl<SectionRef> *RelocSecs = &SectionRelocMap[*I];
+ for (SmallVectorImpl<SectionRef>::iterator RelocSec = RelocSecs->begin(),
+ E = RelocSecs->end();
+ RelocSec != E; ++RelocSec) {
+ for (relocation_iterator RI = RelocSec->begin_relocations(),
+ RE = RelocSec->end_relocations();
+ RI != RE; RI.increment(EC)) {
+ if (error(EC))
+ break;
+ Rels.push_back(*RI);
+ }
}
}
OpenPOWER on IntegriCloud