bdf7af5
From 51d003033bc15d215a6860714190edacecd724ab Mon Sep 17 00:00:00 2001
5d60b03
From: "Richard W.M. Jones" <rjones@redhat.com>
5d60b03
Date: Thu, 11 Sep 2014 14:49:54 +0100
c5cb967
Subject: [PATCH 14/16] ppc, ppc64, ppc64le: Mark stack as non-executable.
5d60b03
5d60b03
The same fix as this one, which was only fully applied to
5d60b03
i686 & x86-64:
5d60b03
5d60b03
http://caml.inria.fr/mantis/view.php?id=4564
5d60b03
---
4c52516
 asmcomp/power/emit.mlp     | 3 ++-
4c52516
 asmcomp/power64/emit.mlp   | 3 ++-
4c52516
 asmcomp/power64le/emit.mlp | 3 ++-
4c52516
 asmrun/power-elf.S         | 3 +++
4c52516
 asmrun/power64-elf.S       | 2 ++
4c52516
 5 files changed, 11 insertions(+), 3 deletions(-)
5d60b03
4c52516
diff --git a/asmcomp/power/emit.mlp b/asmcomp/power/emit.mlp
c5cb967
index 4344085..717ab12 100644
4c52516
--- a/asmcomp/power/emit.mlp
4c52516
+++ b/asmcomp/power/emit.mlp
c5cb967
@@ -927,4 +927,5 @@ let end_assembly() =
4c52516
                            `	.long	({emit_label lbl} - .) + {emit_int32 ofs}\n`);
4c52516
       efa_def_label = (fun l -> `{emit_label l}:\n`);
4c52516
       efa_string = (fun s -> emit_bytes_directive "	.byte	" (s ^ "\000"))
4c52516
-     }
4c52516
+     };
4c52516
+  `.section .note.GNU-stack,\"\",%progbits; .previous\n`
4c52516
diff --git a/asmcomp/power64/emit.mlp b/asmcomp/power64/emit.mlp
4c52516
index 9fd59b2..4e0317a 100644
4c52516
--- a/asmcomp/power64/emit.mlp
4c52516
+++ b/asmcomp/power64/emit.mlp
4c52516
@@ -990,4 +990,5 @@ let end_assembly() =
4c52516
   `{emit_symbol lbl}:\n`;
4c52516
   `    .quad   {emit_int (List.length !frame_descriptors)}\n`;
4c52516
   List.iter emit_frame !frame_descriptors;
4c52516
-  frame_descriptors := []
4c52516
+  frame_descriptors := [];
4c52516
+  `.section .note.GNU-stack,\"\",%progbits; .previous\n`
4c52516
diff --git a/asmcomp/power64le/emit.mlp b/asmcomp/power64le/emit.mlp
4c52516
index 3f34102..60df72c 100644
4c52516
--- a/asmcomp/power64le/emit.mlp
4c52516
+++ b/asmcomp/power64le/emit.mlp
4c52516
@@ -983,4 +983,5 @@ let end_assembly() =
4c52516
   `{emit_symbol lbl}:\n`;
4c52516
   `    .quad   {emit_int (List.length !frame_descriptors)}\n`;
4c52516
   List.iter emit_frame !frame_descriptors;
4c52516
-  frame_descriptors := []
4c52516
+  frame_descriptors := [];
4c52516
+  `.section .note.GNU-stack,\"\",%progbits; .previous\n`
5d60b03
diff --git a/asmrun/power-elf.S b/asmrun/power-elf.S
5d60b03
index facbfbf..14d28a0 100644
5d60b03
--- a/asmrun/power-elf.S
5d60b03
+++ b/asmrun/power-elf.S
5d60b03
@@ -478,3 +478,6 @@ caml_system__frametable:
5d60b03
         .long   .L105 + 4       /* return address into callback */
5d60b03
         .short  -1              /* negative size count => use callback link */
5d60b03
         .short  0               /* no roots here */
5d60b03
+
5d60b03
+/* Mark stack as non-executable, PR#4564 */
5d60b03
+        .section .note.GNU-stack,"",%progbits
5d60b03
diff --git a/asmrun/power64-elf.S b/asmrun/power64-elf.S
5d60b03
index 98c42e2..b7bfce4 100644
5d60b03
--- a/asmrun/power64-elf.S
5d60b03
+++ b/asmrun/power64-elf.S
5d60b03
@@ -577,3 +577,5 @@ caml_system__frametable:
5d60b03
         .short  0               /* no roots here */
5d60b03
         .align  3
5d60b03
 
5d60b03
+/* Mark stack as non-executable, PR#4564 */
5d60b03
+        .section .note.GNU-stack,"",%progbits
5d60b03
-- 
23620d4
2.3.1
5d60b03