tberghammer updated this revision to Diff 54854.
tberghammer added a comment.

I updated the diff to only address the soft-flat case (Android-EABI). This 
fixes the most important case but I would like to fix the hard-flat case as 
well in the not so distant future as we have the same problem (regression ) in 
that case as well (combined with the hard/soft mismatch)


http://reviews.llvm.org/D19480

Files:
  source/Core/ArchSpec.cpp
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1740,12 +1740,9 @@
                 {
                     DataExtractor data;
 
-                    if (sheader.sh_type != SHT_ARM_ATTRIBUTES)
-                        continue;
-                    if (section_size == 0 || set_data(data, sheader.sh_offset, 
section_size) != section_size)
-                        continue;
-
-                    ParseARMAttributes(data, section_size, arch_spec);
+                    if (sheader.sh_type == SHT_ARM_ATTRIBUTES && section_size 
!= 0 && 
+                        set_data(data, sheader.sh_offset, section_size) == 
section_size)
+                        ParseARMAttributes(data, section_size, arch_spec);
                 }
 
                 if (name == g_sect_name_gnu_debuglink)
Index: source/Core/ArchSpec.cpp
===================================================================
--- source/Core/ArchSpec.cpp
+++ source/Core/ArchSpec.cpp
@@ -1002,6 +1002,26 @@
     return IsEqualTo (rhs, false);
 }
 
+static bool
+isCompatibleEnvironment(llvm::Triple::EnvironmentType lhs, 
llvm::Triple::EnvironmentType rhs)
+{
+    if (lhs == rhs)
+        return true;
+
+    // If any of the environment is unknown then they are compatible
+    if (lhs == llvm::Triple::UnknownEnvironment || rhs == 
llvm::Triple::UnknownEnvironment)
+        return true;
+
+    // If one of the environment is Android and the other one is EABI then 
they are considered to
+    // be compatible. This is required as a workaround for shared libraries 
compiled for Android
+    // without the NOTE section indicating that they are using the Android ABI.
+    if ((lhs == llvm::Triple::Android && rhs == llvm::Triple::EABI) ||
+        (rhs == llvm::Triple::Android && lhs == llvm::Triple::EABI))
+        return true;
+
+    return false;
+}
+
 bool
 ArchSpec::IsEqualTo (const ArchSpec& rhs, bool exact_match) const
 {
@@ -1056,14 +1076,9 @@
 
         const llvm::Triple::EnvironmentType lhs_triple_env = 
lhs_triple.getEnvironment();
         const llvm::Triple::EnvironmentType rhs_triple_env = 
rhs_triple.getEnvironment();
-            
-        if (lhs_triple_env != rhs_triple_env)
-        {
-            // Only fail if both environment types are not unknown
-            if (lhs_triple_env != llvm::Triple::UnknownEnvironment &&
-                rhs_triple_env != llvm::Triple::UnknownEnvironment)
-                return false;
-        }
+        
+        if (!isCompatibleEnvironment(lhs_triple_env, rhs_triple_env))
+            return false;
         return true;
     }
     return false;


Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1740,12 +1740,9 @@
                 {
                     DataExtractor data;
 
-                    if (sheader.sh_type != SHT_ARM_ATTRIBUTES)
-                        continue;
-                    if (section_size == 0 || set_data(data, sheader.sh_offset, section_size) != section_size)
-                        continue;
-
-                    ParseARMAttributes(data, section_size, arch_spec);
+                    if (sheader.sh_type == SHT_ARM_ATTRIBUTES && section_size != 0 && 
+                        set_data(data, sheader.sh_offset, section_size) == section_size)
+                        ParseARMAttributes(data, section_size, arch_spec);
                 }
 
                 if (name == g_sect_name_gnu_debuglink)
Index: source/Core/ArchSpec.cpp
===================================================================
--- source/Core/ArchSpec.cpp
+++ source/Core/ArchSpec.cpp
@@ -1002,6 +1002,26 @@
     return IsEqualTo (rhs, false);
 }
 
+static bool
+isCompatibleEnvironment(llvm::Triple::EnvironmentType lhs, llvm::Triple::EnvironmentType rhs)
+{
+    if (lhs == rhs)
+        return true;
+
+    // If any of the environment is unknown then they are compatible
+    if (lhs == llvm::Triple::UnknownEnvironment || rhs == llvm::Triple::UnknownEnvironment)
+        return true;
+
+    // If one of the environment is Android and the other one is EABI then they are considered to
+    // be compatible. This is required as a workaround for shared libraries compiled for Android
+    // without the NOTE section indicating that they are using the Android ABI.
+    if ((lhs == llvm::Triple::Android && rhs == llvm::Triple::EABI) ||
+        (rhs == llvm::Triple::Android && lhs == llvm::Triple::EABI))
+        return true;
+
+    return false;
+}
+
 bool
 ArchSpec::IsEqualTo (const ArchSpec& rhs, bool exact_match) const
 {
@@ -1056,14 +1076,9 @@
 
         const llvm::Triple::EnvironmentType lhs_triple_env = lhs_triple.getEnvironment();
         const llvm::Triple::EnvironmentType rhs_triple_env = rhs_triple.getEnvironment();
-            
-        if (lhs_triple_env != rhs_triple_env)
-        {
-            // Only fail if both environment types are not unknown
-            if (lhs_triple_env != llvm::Triple::UnknownEnvironment &&
-                rhs_triple_env != llvm::Triple::UnknownEnvironment)
-                return false;
-        }
+        
+        if (!isCompatibleEnvironment(lhs_triple_env, rhs_triple_env))
+            return false;
         return true;
     }
     return false;
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to