diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-06 13:06:17 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-06 13:06:17 +0000 |
commit | e3a0e7f29dde261ca00835e763e26de41a8684f6 (patch) | |
tree | b3d0775b1c7e332bd720f4d991c9b9869d7b16d8 /tools | |
parent | 2ed7659b88db1b0f3e5e6e6d9920c1d149159986 (diff) | |
download | external_llvm-e3a0e7f29dde261ca00835e763e26de41a8684f6.zip external_llvm-e3a0e7f29dde261ca00835e763e26de41a8684f6.tar.gz external_llvm-e3a0e7f29dde261ca00835e763e26de41a8684f6.tar.bz2 |
Print symbol names in relocations when dumping COFF as YAML.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183403 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/obj2yaml/coff2yaml.cpp | 8 | ||||
-rw-r--r-- | tools/yaml2obj/yaml2coff.cpp | 14 |
2 files changed, 17 insertions, 5 deletions
diff --git a/tools/obj2yaml/coff2yaml.cpp b/tools/obj2yaml/coff2yaml.cpp index 909b269..0ec35bf 100644 --- a/tools/obj2yaml/coff2yaml.cpp +++ b/tools/obj2yaml/coff2yaml.cpp @@ -66,13 +66,15 @@ void COFFDumper::dumpSections(unsigned NumSections) { Obj.getSectionContents(Sect, sectionData); Sec.SectionData = object::yaml::BinaryRef(sectionData); - std::vector<COFF::relocation> Relocations; + std::vector<COFFYAML::Relocation> Relocations; for (object::relocation_iterator rIter = iter->begin_relocations(); rIter != iter->end_relocations(); rIter.increment(ec)) { const object::coff_relocation *reloc = Obj.getCOFFRelocation(rIter); - COFF::relocation Rel; + COFFYAML::Relocation Rel; + object::symbol_iterator Sym = rIter->getSymbol(); + StringRef Name; + Sym->getName(Rel.SymbolName); Rel.VirtualAddress = reloc->VirtualAddress; - Rel.SymbolTableIndex = reloc->SymbolTableIndex; Rel.Type = reloc->Type; Relocations.push_back(Rel); } diff --git a/tools/yaml2obj/yaml2coff.cpp b/tools/yaml2obj/yaml2coff.cpp index d800b90..11aae0e 100644 --- a/tools/yaml2obj/yaml2coff.cpp +++ b/tools/yaml2obj/yaml2coff.cpp @@ -219,15 +219,25 @@ bool writeCOFF(COFFParser &CP, raw_ostream &OS) { << binary_le(i->Header.Characteristics); } + unsigned CurSymbol = 0; + StringMap<unsigned> SymbolTableIndexMap; + for (std::vector<COFFYAML::Symbol>::iterator I = CP.Obj.Symbols.begin(), + E = CP.Obj.Symbols.end(); + I != E; ++I) { + SymbolTableIndexMap[I->Name] = CurSymbol; + CurSymbol += 1 + I->Header.NumberOfAuxSymbols; + } + // Output section data. for (std::vector<COFFYAML::Section>::iterator i = CP.Obj.Sections.begin(), e = CP.Obj.Sections.end(); i != e; ++i) { i->SectionData.writeAsBinary(OS); for (unsigned I2 = 0, E2 = i->Relocations.size(); I2 != E2; ++I2) { - const COFF::relocation &R = i->Relocations[I2]; + const COFFYAML::Relocation &R = i->Relocations[I2]; + uint32_t SymbolTableIndex = SymbolTableIndexMap[R.SymbolName]; OS << binary_le(R.VirtualAddress) - << binary_le(R.SymbolTableIndex) + << binary_le(SymbolTableIndex) << binary_le(R.Type); } } |