[Lldb-commits] [PATCH] D19480: Fix ARM attribute parsing for Android after rL267291

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


This revision was automatically updated to reflect the committed changes.
Closed by commit rL267422: Fix ARM attribute parsing for Android after rL267291 (authored by tberghammer).

Changed prior to commit:
  http://reviews.llvm.org/D19480?vs=54854&id=54864#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19480

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

Index: lldb/trunk/source/Core/ArchSpec.cpp
===================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp
+++ lldb/trunk/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: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ lldb/trunk/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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19480.54864.patch
Type: text/x-patch
Size: 2822 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160425/27116a17/attachment-0001.bin>


More information about the lldb-commits mailing list