[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 05:56:22 PDT 2016


tberghammer created this revision.
tberghammer added reviewers: labath, compnerd.
tberghammer added a subscriber: lldb-commits.
Herald added subscribers: srhines, danalbert, tberghammer, rengolin, aemerson.

Fix ARM attribute parsing for Android after rL267291

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,27 @@
     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 or EABIHF 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::EABIHF))
+        return true;
+    if (rhs == llvm::Triple::Android && (lhs == llvm::Triple::EABI || lhs == llvm::Triple::EABIHF))
+        return true;
+
+    return false;
+}
+
 bool
 ArchSpec::IsEqualTo (const ArchSpec& rhs, bool exact_match) const
 {
@@ -1056,14 +1077,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;


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


More information about the lldb-commits mailing list