[Lldb-commits] [lldb] r267422 - Fix ARM attribute parsing for Android after rL267291

Tamas Berghammer via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 25 08:51:47 PDT 2016


Author: tberghammer
Date: Mon Apr 25 10:51:45 2016
New Revision: 267422

URL: http://llvm.org/viewvc/llvm-project?rev=267422&view=rev
Log:
Fix ARM attribute parsing for Android after rL267291

Differential revision: http://reviews.llvm.org/D19480

Modified:
    lldb/trunk/source/Core/ArchSpec.cpp
    lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=267422&r1=267421&r2=267422&view=diff
==============================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Mon Apr 25 10:51:45 2016
@@ -1002,6 +1002,26 @@ ArchSpec::IsCompatibleMatch (const ArchS
     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 @@ ArchSpec::IsEqualTo (const ArchSpec& rhs
 
         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;

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=267422&r1=267421&r2=267422&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Mon Apr 25 10:51:45 2016
@@ -1740,12 +1740,9 @@ ObjectFileELF::GetSectionHeaderInfo(Sect
                 {
                     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)




More information about the lldb-commits mailing list