aboutsummaryrefslogtreecommitdiffstats
path: root/testing/ocaml/010_all_execstacks.patch
blob: 30cf23ec616a25eba3ca3ece1ea35e49f44c7ea3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Fix the EXEC_STACK in ocaml compiled binaries (#153382)

Index: ocaml-4.03.0+beta1/asmrun/sparc.S
===================================================================
--- ocaml-4.03.0+beta1.orig/asmrun/sparc.S
+++ ocaml-4.03.0+beta1/asmrun/sparc.S
@@ -358,3 +358,8 @@ caml_system__frametable:
         .type caml_raise_exception, #function
         .type caml_system__frametable, #object
 #endif
+
+#ifdef __ELF__
+.section .note.GNU-stack,"",%progbits
+#endif
+
Index: ocaml-4.03.0+beta1/asmcomp/sparc/emit.mlp
===================================================================
--- ocaml-4.03.0+beta1.orig/asmcomp/sparc/emit.mlp
+++ ocaml-4.03.0+beta1/asmcomp/sparc/emit.mlp
@@ -737,6 +737,12 @@ let data l =
   `	.data\n`;
   List.iter emit_item l
 
+(* Mark stack as non executable *)
+let nx_stack() =
+  if Config.system = "linux" then
+      `  .section .note.GNU-stack,\"\",%progbits\n`
+
+
 (* Beginning / end of an assembly file *)
 
 let begin_assembly() =
@@ -750,6 +756,7 @@ let begin_assembly() =
   `{emit_symbol lbl_begin}:\n`
 
 let end_assembly() =
+  nx_stack();
   `	.text\n`;
   let lbl_end = Compilenv.make_symbol (Some "code_end") in
   `	.global	{emit_symbol lbl_end}\n`;