[Lldb-commits] [PATCH] Fix load address resolution on Windows
Zachary Turner
zturner at google.com
Thu Jan 22 10:19:52 PST 2015
Fixed suggested issues, and moved the logic into a function in ArchSpec, since I thought it might be useful.
I reversed your conditional though because it looked like a thinko.
LMK if this looks good.
http://reviews.llvm.org/D7120
Files:
include/lldb/Core/ArchSpec.h
source/Core/ArchSpec.cpp
source/Core/Module.cpp
source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
Index: include/lldb/Core/ArchSpec.h
===================================================================
--- include/lldb/Core/ArchSpec.h
+++ include/lldb/Core/ArchSpec.h
@@ -276,6 +276,9 @@
return !m_triple.getOSName().empty();
}
+ void
+ MergeFrom(const ArchSpec &other);
+
//------------------------------------------------------------------
/// Sets this ArchSpec according to the given architecture name.
///
Index: source/Core/ArchSpec.cpp
===================================================================
--- source/Core/ArchSpec.cpp
+++ source/Core/ArchSpec.cpp
@@ -765,6 +765,19 @@
return IsValid();
}
+void
+ArchSpec::MergeFrom(const ArchSpec &other)
+{
+ if (GetTriple().getVendor() == llvm::Triple::UnknownVendor && !TripleVendorWasSpecified())
+ GetTriple().setVendor(other.GetTriple().getVendor());
+ if (GetTriple().getOS() == llvm::Triple::UnknownOS && !TripleOSWasSpecified())
+ GetTriple().setOS(other.GetTriple().getOS());
+ if (GetTriple().getArch() == llvm::Triple::UnknownArch)
+ GetTriple().setArch(other.GetTriple().getArch());
+ if (GetTriple().getEnvironment() == llvm::Triple::UnknownEnvironment)
+ GetTriple().setEnvironment(other.GetTriple().getEnvironment());
+}
+
bool
ArchSpec::SetArchitecture (ArchitectureType arch_type, uint32_t cpu, uint32_t sub)
{
Index: source/Core/Module.cpp
===================================================================
--- source/Core/Module.cpp
+++ source/Core/Module.cpp
@@ -1306,8 +1306,12 @@
{
// Once we get the object file, update our module with the object file's
// architecture since it might differ in vendor/os if some parts were
- // unknown.
- m_objfile_sp->GetArchitecture (m_arch);
+ // unknown. But since the matching arch might already be more specific
+ // than the generic COFF architecture, only merge in those values that
+ // overwrite unspecified unknown values.
+ ArchSpec new_arch;
+ m_objfile_sp->GetArchitecture (new_arch);
+ m_arch.MergeFrom(new_arch);
}
else
{
Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
===================================================================
--- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -130,10 +130,17 @@
{
ArchSpec spec;
if (coff_header.machine == MachineAmd64)
+ {
spec.SetTriple("x86_64-pc-windows");
+ specs.Append(ModuleSpec(file, spec));
+ }
else if (coff_header.machine == MachineX86)
+ {
spec.SetTriple("i386-pc-windows");
- specs.Append(ModuleSpec(file, spec));
+ specs.Append(ModuleSpec(file, spec));
+ spec.SetTriple("i686-pc-windows");
+ specs.Append(ModuleSpec(file, spec));
+ }
}
}
}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7120.18624.patch
Type: text/x-patch
Size: 3195 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150122/65e66e09/attachment.bin>
More information about the lldb-commits
mailing list