[Lldb-commits] [PATCH] Fix load address resolution on Windows

Zachary Turner zturner at google.com
Wed Jan 21 22:08:15 PST 2015


Hi clayborg, jingham,

When loading a module as a result of the "target create" command, there is the potential for ObjectFilePECOFF to stomp the triple.  This can confuse later code which depends on the triple.  Ultimately this fixes load address resolution on Windows because the correct triple is plumbed all the way through, so DynamicLoaderWindows can now correctly recognize that it should be used.

http://reviews.llvm.org/D7120

Files:
  source/Core/Module.cpp
  source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp

Index: source/Core/Module.cpp
===================================================================
--- source/Core/Module.cpp
+++ source/Core/Module.cpp
@@ -1306,8 +1306,19 @@
             {
                 // 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 overwrite those fields that
+                // are unknown.
+                ArchSpec new_arch;
+                m_objfile_sp->GetArchitecture (new_arch);
+                if (m_arch.GetTriple().getVendor() == llvm::Triple::UnknownVendor)
+                    m_arch.GetTriple().setVendor(new_arch.GetTriple().getVendor());
+                if (m_arch.GetTriple().getOS() == llvm::Triple::UnknownOS)
+                    m_arch.GetTriple().setOS(new_arch.GetTriple().getOS());
+                if (m_arch.GetTriple().getArch() == llvm::Triple::UnknownArch)
+                    m_arch.GetTriple().setArch(new_arch.GetTriple().getArch());
+                if (m_arch.GetTriple().getEnvironment() == llvm::Triple::UnknownEnvironment)
+                    m_arch.GetTriple().setEnvironment(new_arch.GetTriple().getEnvironment());
             }
             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.18586.patch
Type: text/x-patch
Size: 2424 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150122/7898f5ed/attachment.bin>


More information about the lldb-commits mailing list