Merging r277868:
------------------------------------------------------------------------
r277868 | compnerd | 2016-08-05 14:35:28 -0700 (Fri, 05 Aug 2016) | 4 lines

unwind: disable executable stacks

Similar to compiler-rt, ensure that we disable executable stacks for the custom
assembly.
------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/libunwind/branches/release_39@278023 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/src/UnwindRegistersRestore.S b/src/UnwindRegistersRestore.S
index 6f99623..b2f6914 100644
--- a/src/UnwindRegistersRestore.S
+++ b/src/UnwindRegistersRestore.S
@@ -479,3 +479,6 @@
    l.nop
 
 #endif
+
+NO_EXEC_STACK_DIRECTIVE
+
diff --git a/src/UnwindRegistersSave.S b/src/UnwindRegistersSave.S
index 4f4b261..6425bf6 100644
--- a/src/UnwindRegistersSave.S
+++ b/src/UnwindRegistersSave.S
@@ -464,3 +464,6 @@
   l.sw     120(r3), r30
   l.sw     124(r3), r31
 #endif
+
+NO_EXEC_STACK_DIRECTIVE
+
diff --git a/src/assembly.h b/src/assembly.h
index f46a24d..06b29b3 100644
--- a/src/assembly.h
+++ b/src/assembly.h
@@ -35,19 +35,34 @@
 #define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)
 
 #if defined(__APPLE__)
+
 #define SYMBOL_IS_FUNC(name)
+#define NO_EXEC_STACK_DIRECTIVE
+
 #elif defined(__ELF__)
+
 #if defined(__arm__)
 #define SYMBOL_IS_FUNC(name) .type name,%function
 #else
 #define SYMBOL_IS_FUNC(name) .type name,@function
 #endif
+
+#if defined(__GNU__) || defined(__ANDROID__) || defined(__FreeBSD__)
+#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits
 #else
+#define NO_EXEC_STACK_DIRECTIVE
+#endif
+
+#else
+
 #define SYMBOL_IS_FUNC(name)                                                   \
   .def name SEPARATOR                                                          \
     .scl 2 SEPARATOR                                                           \
     .type 32 SEPARATOR                                                         \
   .endef
+
+#define NO_EXEC_STACK_DIRECTIVE
+
 #endif
 
 #define DEFINE_LIBUNWIND_FUNCTION(name)                   \